1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package mc_view; |
22 |
|
|
23 |
|
import java.io.IOException; |
24 |
|
import java.util.ArrayList; |
25 |
|
import java.util.Hashtable; |
26 |
|
import java.util.List; |
27 |
|
import java.util.Vector; |
28 |
|
|
29 |
|
import jalview.datamodel.AlignmentAnnotation; |
30 |
|
import jalview.datamodel.DBRefSource; |
31 |
|
import jalview.datamodel.SequenceI; |
32 |
|
import jalview.io.DataSourceType; |
33 |
|
import jalview.io.FileParse; |
34 |
|
import jalview.io.StructureFile; |
35 |
|
import jalview.util.MessageManager; |
36 |
|
|
|
|
| 72.9% |
Uncovered Elements: 36 (133) |
Complexity: 34 |
Complexity Density: 0.4 |
|
37 |
|
public class PDBfile extends StructureFile |
38 |
|
{ |
39 |
|
private static String CALC_ID_PREFIX = "JalviewPDB"; |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
41 |
0 |
public PDBfile(boolean addAlignmentAnnotations,... |
42 |
|
boolean predictSecondaryStructure, boolean externalSecStr) |
43 |
|
{ |
44 |
0 |
super(); |
45 |
0 |
addSettings(addAlignmentAnnotations, predictSecondaryStructure, |
46 |
|
externalSecStr); |
47 |
|
} |
48 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
49 |
13 |
public PDBfile(boolean addAlignmentAnnotations, boolean predictSecStr,... |
50 |
|
boolean externalSecStr, String dataObject, |
51 |
|
DataSourceType sourceType) throws IOException |
52 |
|
{ |
53 |
13 |
super(false, dataObject, sourceType); |
54 |
13 |
addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr); |
55 |
13 |
doParse(); |
56 |
|
} |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
58 |
0 |
public PDBfile(boolean addAlignmentAnnotations, boolean predictSecStr,... |
59 |
|
boolean externalSecStr, FileParse source) throws IOException |
60 |
|
{ |
61 |
0 |
super(false, source); |
62 |
0 |
addSettings(addAlignmentAnnotations, predictSecStr, externalSecStr); |
63 |
0 |
doParse(); |
64 |
|
} |
65 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
66 |
0 |
@Override... |
67 |
|
public String print(SequenceI[] seqs, boolean jvSuffix) |
68 |
|
{ |
69 |
0 |
return null; |
70 |
|
} |
71 |
|
|
|
|
| 80.4% |
Uncovered Elements: 19 (97) |
Complexity: 24 |
Complexity Density: 0.38 |
|
72 |
13 |
@Override... |
73 |
|
public void parse() throws IOException |
74 |
|
{ |
75 |
13 |
setDbRefType(DBRefSource.PDB); |
76 |
|
|
77 |
13 |
setId(safeName(getDataName())); |
78 |
|
|
79 |
13 |
setChains(new Vector<PDBChain>()); |
80 |
13 |
List<SequenceI> rna = new ArrayList<SequenceI>(); |
81 |
13 |
List<SequenceI> prot = new ArrayList<SequenceI>(); |
82 |
13 |
PDBChain tmpchain; |
83 |
13 |
String line = null; |
84 |
13 |
boolean modelFlag = false; |
85 |
13 |
boolean terFlag = false; |
86 |
13 |
String lastID = ""; |
87 |
|
|
88 |
13 |
int indexx = 0; |
89 |
13 |
String atomnam = null; |
90 |
13 |
try |
91 |
|
{ |
92 |
? |
while ((line = nextLine()) != null) |
93 |
|
{ |
94 |
52002 |
if (line.indexOf("HEADER") == 0) |
95 |
|
{ |
96 |
13 |
if (line.length() > 62) |
97 |
|
{ |
98 |
13 |
String tid; |
99 |
13 |
if (line.length() > 67) |
100 |
|
{ |
101 |
9 |
tid = line.substring(62, 67).trim(); |
102 |
|
} |
103 |
|
else |
104 |
|
{ |
105 |
4 |
tid = line.substring(62).trim(); |
106 |
|
} |
107 |
13 |
if (tid.length() > 0) |
108 |
|
{ |
109 |
13 |
setId(tid); |
110 |
|
} |
111 |
13 |
continue; |
112 |
|
} |
113 |
|
} |
114 |
|
|
115 |
51989 |
if (line.indexOf("SEQRES") == 0) |
116 |
|
{ |
117 |
|
} |
118 |
|
|
119 |
51989 |
if (line.indexOf("MODEL") == 0) |
120 |
|
{ |
121 |
0 |
modelFlag = true; |
122 |
|
} |
123 |
|
|
124 |
51989 |
if (line.indexOf("TER") == 0) |
125 |
|
{ |
126 |
23 |
terFlag = true; |
127 |
|
} |
128 |
|
|
129 |
51989 |
if (modelFlag && line.indexOf("ENDMDL") == 0) |
130 |
|
{ |
131 |
0 |
break; |
132 |
|
} |
133 |
51989 |
if (line.indexOf("ATOM") == 0 |
134 |
|
|| (line.indexOf("HETATM") == 0 && !terFlag)) |
135 |
|
{ |
136 |
44406 |
terFlag = false; |
137 |
|
|
138 |
|
|
139 |
44406 |
atomnam = line.substring(12, 15).trim(); |
140 |
44406 |
if (!atomnam.equals("CA") && !atomnam.equals("P")) |
141 |
|
{ |
142 |
37593 |
continue; |
143 |
|
} |
144 |
|
|
145 |
6813 |
Atom tmpatom = new Atom(line); |
146 |
6813 |
if (tmpatom.resNumIns.trim().equals(lastID)) |
147 |
|
{ |
148 |
|
|
149 |
3 |
continue; |
150 |
|
} |
151 |
6810 |
tmpchain = findChain(tmpatom.chain); |
152 |
6810 |
if (tmpchain != null) |
153 |
|
{ |
154 |
6778 |
tmpchain.atoms.addElement(tmpatom); |
155 |
|
} |
156 |
|
else |
157 |
|
{ |
158 |
|
|
159 |
32 |
tmpchain = new PDBChain(getId(), tmpatom.chain); |
160 |
32 |
getChains().add(tmpchain); |
161 |
32 |
tmpchain.atoms.addElement(tmpatom); |
162 |
|
} |
163 |
6810 |
lastID = tmpatom.resNumIns.trim(); |
164 |
|
} |
165 |
14393 |
index++; |
166 |
|
} |
167 |
|
|
168 |
13 |
makeResidueList(); |
169 |
13 |
makeCaBondList(); |
170 |
|
|
171 |
13 |
if (getId() == null) |
172 |
|
{ |
173 |
0 |
setId(inFile.getName()); |
174 |
|
} |
175 |
13 |
for (PDBChain chain : getChains()) |
176 |
|
{ |
177 |
32 |
SequenceI chainseq = postProcessChain(chain); |
178 |
32 |
if (isRNA(chainseq)) |
179 |
|
{ |
180 |
0 |
rna.add(chainseq); |
181 |
|
} |
182 |
|
else |
183 |
|
{ |
184 |
32 |
prot.add(chainseq); |
185 |
|
} |
186 |
|
} |
187 |
13 |
if (predictSecondaryStructure) |
188 |
|
{ |
189 |
5 |
addSecondaryStructure(rna, prot); |
190 |
|
} |
191 |
|
} catch (OutOfMemoryError er) |
192 |
|
{ |
193 |
0 |
System.out.println("OUT OF MEMORY LOADING PDB FILE"); |
194 |
0 |
throw new IOException(MessageManager |
195 |
|
.getString("exception.outofmemory_loading_pdb_file")); |
196 |
|
} catch (NumberFormatException ex) |
197 |
|
{ |
198 |
0 |
if (line != null) |
199 |
|
{ |
200 |
0 |
System.err.println("Couldn't read number from line:"); |
201 |
0 |
System.err.println(line); |
202 |
|
} |
203 |
|
} |
204 |
13 |
markCalcIds(); |
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
|
@param |
212 |
|
@return |
213 |
|
|
214 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
215 |
0 |
public static boolean isCalcIdHandled(String calcId)... |
216 |
|
{ |
217 |
0 |
return calcId != null && (CALC_ID_PREFIX.equals(calcId)); |
218 |
|
} |
219 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
220 |
8 |
public static boolean isCalcIdForFile(AlignmentAnnotation alan,... |
221 |
|
String pdbFile) |
222 |
|
{ |
223 |
8 |
return alan.getCalcId() != null |
224 |
|
&& CALC_ID_PREFIX.equals(alan.getCalcId()) |
225 |
|
&& pdbFile.equals(alan.getProperty("PDBID")); |
226 |
|
} |
227 |
|
|
|
|
| 0% |
Uncovered Elements: 3 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
228 |
0 |
public static String relocateCalcId(String calcId,... |
229 |
|
Hashtable<String, String> alreadyLoadedPDB) throws Exception |
230 |
|
{ |
231 |
0 |
int s = CALC_ID_PREFIX.length(), |
232 |
|
end = calcId.indexOf(CALC_ID_PREFIX, s); |
233 |
0 |
String between = calcId.substring(s, end - 1); |
234 |
0 |
return CALC_ID_PREFIX + alreadyLoadedPDB.get(between) + ":" |
235 |
|
+ calcId.substring(end); |
236 |
|
} |
237 |
|
|
|
|
| 84.6% |
Uncovered Elements: 2 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
238 |
13 |
private void markCalcIds()... |
239 |
|
{ |
240 |
13 |
for (SequenceI sq : seqs) |
241 |
|
{ |
242 |
32 |
if (sq.getAnnotation() != null) |
243 |
|
{ |
244 |
18 |
for (AlignmentAnnotation aa : sq.getAnnotation()) |
245 |
|
{ |
246 |
22 |
String oldId = aa.getCalcId(); |
247 |
22 |
if (oldId == null) |
248 |
|
{ |
249 |
0 |
oldId = ""; |
250 |
|
} |
251 |
22 |
aa.setCalcId(CALC_ID_PREFIX); |
252 |
22 |
aa.setProperty("PDBID", getId()); |
253 |
22 |
aa.setProperty("oldCalcId", oldId); |
254 |
|
} |
255 |
|
} |
256 |
|
} |
257 |
|
} |
258 |
|
|
259 |
|
} |