-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathChainAtoms.cs
More file actions
243 lines (228 loc) · 4.95 KB
/
Copy pathChainAtoms.cs
File metadata and controls
243 lines (228 loc) · 4.95 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
using System;
using System.Collections;
namespace betaBarrelProgram.AtomParser
{
/// <summary>
/// A protein chain
/// </summary>
public class ChainAtoms
{
internal string authAsymChain = "";
internal string asymChain = "";
internal string entityId = "";
internal string polymerType = "";
// store the list of atoms for this asymmetric chain
public ArrayList cartnAtoms = null;
public ChainAtoms()
{
cartnAtoms = new ArrayList ();
}
public ChainAtoms(ChainAtoms extChain)
{
this.authAsymChain = extChain.AuthAsymChain;
this.asymChain = extChain.AsymChain;
this.entityId = extChain.entityId;
this.polymerType = extChain.PolymerType;
foreach (AtomInfo atom in extChain.CartnAtoms)
{
this.cartnAtoms.Add (atom.Clone ());
}
}
#region properties
// asymmetric chain id
public string AsymChain
{
get
{
return asymChain;
}
set
{
asymChain = value;
}
}
// entity id
public string EntityID
{
get
{
return entityId;
}
set
{
entityId = value;
}
}
public string PolymerType
{
get
{
return polymerType;
}
set
{
polymerType = value;
}
}
public string AuthAsymChain
{
get
{
return authAsymChain;
}
set
{
authAsymChain = value;
}
}
// the list of atoms for this asymmetric chain
public AtomInfo [] CartnAtoms
{
get
{
AtomInfo[] atomInfoList = new AtomInfo[cartnAtoms.Count];
cartnAtoms.CopyTo (atomInfoList);
return atomInfoList;
}
set
{
if (value == null)
{
return;
}
AtomInfo[] atomInfoList = (AtomInfo[]) value;
cartnAtoms.Clear ();
cartnAtoms.AddRange (atomInfoList);
}
}
#endregion
#region atom types
/// <summary>
/// c-alpha atoms
/// </summary>
public AtomInfo[] CalphaAtoms ()
{
ArrayList calphaList = new ArrayList ();
foreach (AtomInfo atom in cartnAtoms)
{
if (atom.atomName.ToUpper () == "CA")
{
calphaList.Add (new AtomInfo(atom));
}
}
AtomInfo[] calphaArray = new AtomInfo [calphaList.Count];
calphaList.CopyTo (calphaArray);
return calphaArray;
}
/// <summary>
/// c-beta atoms
/// </summary>
public AtomInfo[] CbetaAtoms ()
{
ArrayList cbetaList = new ArrayList ();
foreach (AtomInfo atom in cartnAtoms)
{
if (atom.atomName.ToUpper () == "CB")
{
cbetaList.Add (new AtomInfo(atom));
}
}
AtomInfo[] cbetaArray = new AtomInfo [cbetaList.Count];
cbetaList.CopyTo (cbetaArray);
return cbetaArray;
}
/// <summary>
/// c-beta and C-alpha atoms
/// </summary>
public AtomInfo[] CalphaCbetaAtoms ()
{
ArrayList calphaCbetaList = new ArrayList ();
foreach (AtomInfo atom in cartnAtoms)
{
if (atom.atomName.ToUpper () == "CB" || atom.atomName.ToUpper () == "CA")
{
calphaCbetaList.Add (new AtomInfo(atom));
}
}
// for some PDB entries, there is only Calpha
/* if (calphaCbetaList.Count == 0)
{
foreach (AtomInfo atom in cartnAtoms)
{
if (atom.atomName.ToUpper () == "CA")
{
calphaCbetaList.Add (new AtomInfo(atom));
}
}
}*/
AtomInfo[] calphaCbetaArray = new AtomInfo [calphaCbetaList.Count];
calphaCbetaList.CopyTo (calphaCbetaArray);
return calphaCbetaArray;
}
/// <summary>
/// get backbone atoms
/// </summary>
public AtomInfo[] BackboneAtoms ()
{
ArrayList backboneList = new ArrayList ();
foreach (AtomInfo atom in cartnAtoms)
{
if (atom.atomName == "CA" || atom.atomName == "N" ||
atom.atomName == "C" || atom.atomName == "O" || atom.atomName == "OXT")
{
backboneList.Add (new AtomInfo(atom));
}
}
AtomInfo[] backboneArray = new AtomInfo [backboneList.Count];
backboneList.CopyTo (backboneArray);
return backboneArray;
}
#endregion
/// <summary>
/// add an atom to the list
/// </summary>
/// <param name="atom"></param>
/// <returns></returns>
public int AddAtom(AtomInfo atom)
{
return cartnAtoms.Add (atom);
}
/// <summary>
/// number of residues based on number of C-alpha
/// </summary>
/// <returns></returns>
public int GetNumOfResidues ()
{
return this.CalphaAtoms ().Length;
}
#region sort by atom ID
/// <summary>
/// sort chains by atom ID
/// </summary>
public void SortByAtomId ()
{
if (cartnAtoms == null)
{
return ;
}
AtomInfo[] chain = this.CartnAtoms;
Hashtable seqHash = new Hashtable ();
foreach (AtomInfo atom in chain)
{
// sould have unique atom id
seqHash.Add (atom.atomId, atom);
}
ArrayList atomIdList = new ArrayList (seqHash.Keys);
atomIdList.Sort ();
AtomInfo[] sortedChain = new AtomInfo [chain.Length];
int count = 0;
foreach (object atomId in atomIdList)
{
sortedChain[count] = (AtomInfo)seqHash[atomId];
count ++;
}
this.CartnAtoms = sortedChain;
}
#endregion
}
}