-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModel.pde
89 lines (77 loc) · 1.66 KB
/
Model.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
class Model{
int index;
// ArrayList<Residue> residues;
// String sequence = "";
HashMap<Character, Chain> chain_map;
Model(int index){
this.index = index;
chain_map = new HashMap<Character, Chain>();
// residues = new ArrayList<Residue>();
}
void addAtom(Atom a, char aa, char chain_id, int resIndex){
//find chain
Chain c = (Chain) chain_map.get(chain_id);
if(c == null){
//new chain
c = new Chain(chain_id);
chain_map.put(new Character(chain_id), c);
}
//find residue
Residue r = (Residue)c.residue_map.get(resIndex);
if(r == null){
//new residue
r = new Residue(resIndex, aa);
c.residue_map.put(new Integer(resIndex), r);
c.sequence += aa;
}
//add atom
r.addAtom(a);
//revise how to store residues
// if(residues.size() < resIndex){
// //new residue
// r = new Residue(resIndex, aa);
// sequence += aa;
// residues.add(r);
// }else{
// r = residues.get(resIndex-1);
// }
//add atom
// r.addAtom(a);
}
}
class Chain{
HashMap<Integer, Residue> residue_map;
char name;
String sequence = "";
Chain(char name){
this.name = name;
residue_map = new HashMap<Integer, Residue>();
}
}
class Residue{
ArrayList<Atom> atoms;
int index; //from 1 - N;
char aa;
Atom center_atom = null;
PVector center;
Residue(int index, char aa){
this.index = index;
this.aa = aa;
this.atoms = new ArrayList<Atom>();
}
void addAtom(Atom a){
atoms.add(a);
}
}
class Atom{
char element;
char chain;
PVector pos;
int index;
Atom(char element,int index, char chain, float x, float y, float z){
this.element = element;
this.chain = chain;
this.pos = new PVector(x, y, z);
this.index = index;
}
}