1 Clazz.declarePackage ("MCview");
2 Clazz.load (["jalview.io.AlignFile"], "MCview.PDBfile", ["MCview.Atom", "$.PDBChain", "jalview.analysis.AlignSeq", "jalview.datamodel.Alignment", "$.AlignmentI", "$.PDBEntry", "jalview.io.FileParse", "jalview.util.MessageManager", "java.awt.Color", "java.io.IOException", "java.util.ArrayList", "$.Hashtable", "$.Vector"], function () {
3 c$ = Clazz.decorateAsClass (function () {
6 this.visibleChainAnnotation = false;
7 this.$predictSecondaryStructure = true;
8 this.externalSecondaryStructure = false;
9 Clazz.instantialize (this, arguments);
10 }, MCview, "PDBfile", jalview.io.AlignFile);
11 Clazz.makeConstructor (c$,
12 function (addAlignmentAnnotations, predictSecondaryStructure, externalSecStr) {
13 Clazz.superConstructor (this, MCview.PDBfile);
14 this.visibleChainAnnotation = addAlignmentAnnotations;
15 this.$predictSecondaryStructure = predictSecondaryStructure;
16 this.externalSecondaryStructure = externalSecStr;
18 Clazz.makeConstructor (c$,
19 function (addAlignmentAnnotations, predictSecondaryStructure, externalSecStr, file, protocol) {
20 Clazz.superConstructor (this, MCview.PDBfile, [false, file, protocol]);
21 this.visibleChainAnnotation = addAlignmentAnnotations;
22 this.$predictSecondaryStructure = predictSecondaryStructure;
23 this.externalSecondaryStructure = externalSecStr;
26 Clazz.makeConstructor (c$,
27 function (addAlignmentAnnotations, predictSecondaryStructure, externalSecStr, source) {
28 Clazz.superConstructor (this, MCview.PDBfile, [false, source]);
29 this.visibleChainAnnotation = addAlignmentAnnotations;
30 this.$predictSecondaryStructure = predictSecondaryStructure;
31 this.externalSecondaryStructure = externalSecStr;
33 }, "~B,~B,~B,jalview.io.FileParse");
34 Clazz.overrideMethod (c$, "print",
38 Clazz.overrideMethod (c$, "parse",
40 this.id = this.safeName (this.getDataName ());
41 this.chains = new java.util.Vector ();
42 var rna = new java.util.ArrayList ();
43 var prot = new java.util.ArrayList ();
46 var modelFlag = false;
52 while ((line = this.nextLine ()) != null) {
53 if (line.indexOf ("HEADER") == 0) {
54 if (line.length > 62) {
56 if (line.length > 67) {
57 tid = line.substring (62, 67).trim ();
59 tid = line.substring (62).trim ();
60 }if (tid.length > 0) {
63 }}if (line.indexOf ("SEQRES") == 0) {
64 }if (line.indexOf ("MODEL") == 0) {
66 }if (line.indexOf ("TER") == 0) {
68 }if (modelFlag && line.indexOf ("ENDMDL") == 0) {
70 }if (line.indexOf ("ATOM") == 0 || (line.indexOf ("HETATM") == 0 && !terFlag)) {
72 atomnam = line.substring (12, 15).trim ();
73 if (!atomnam.equals ("CA") && !atomnam.equals ("P")) {
75 }var tmpatom = new MCview.Atom (line);
76 tmpchain = this.findChain (tmpatom.chain);
77 if (tmpchain != null) {
78 if (tmpatom.resNumIns.trim ().equals (lastID)) {
80 }tmpchain.atoms.addElement (tmpatom);
82 tmpchain = new MCview.PDBChain (this.id, tmpatom.chain);
83 this.chains.addElement (tmpchain);
84 tmpchain.atoms.addElement (tmpatom);
85 }lastID = tmpatom.resNumIns.trim ();
88 this.makeResidueList ();
89 this.makeCaBondList ();
90 if (this.id == null) {
91 this.id = this.inFile.getName ();
92 }for (var chain, $chain = this.chains.iterator (); $chain.hasNext () && ((chain = $chain.next ()) || true);) {
93 var chainseq = this.postProcessChain (chain);
94 if (MCview.PDBfile.isRNA (chainseq)) {
99 if (this.$predictSecondaryStructure) {
100 this.predictSecondaryStructure (rna, prot);
102 if (Clazz.exceptionOf (e$$, OutOfMemoryError)) {
105 System.out.println ("OUT OF MEMORY LOADING PDB FILE");
106 throw new java.io.IOException (jalview.util.MessageManager.getString ("exception.outofmemory_loading_pdb_file"));
108 } else if (Clazz.exceptionOf (e$$, NumberFormatException)) {
112 System.err.println ("Couldn't read number from line:");
113 System.err.println (line);
121 Clazz.defineMethod (c$, "predictSecondaryStructure",
122 function (rnaSequences, proteinSequences) {
123 if (this.externalSecondaryStructure && rnaSequences.size () > 0) {
125 this.processPdbFileWithAnnotate3d (rnaSequences);
127 if (Clazz.exceptionOf (x, Exception)) {
128 System.err.println ("Exceptions when dealing with RNA in pdb file");
129 x.printStackTrace ();
134 }if (proteinSequences.size () > 0) {
136 this.processPdbFileWithJmol (proteinSequences);
138 if (Clazz.exceptionOf (x, Exception)) {
139 System.err.println ("Exceptions from Jmol when processing data in pdb file");
140 x.printStackTrace ();
145 }}, "java.util.List,java.util.List");
146 Clazz.defineMethod (c$, "postProcessChain",
148 var dataset = chain.sequence;
149 dataset.setName (this.id + "|" + dataset.getName ());
150 var entry = new jalview.datamodel.PDBEntry ();
151 entry.setId (this.id);
152 entry.setType (jalview.datamodel.PDBEntry.Type.PDB);
153 entry.setProperty ( new java.util.Hashtable ());
154 if (chain.id != null) {
155 entry.setChainCode (String.valueOf (chain.id));
156 }if (this.inFile != null) {
157 entry.setFile (this.inFile.getAbsolutePath ());
159 entry.setFile (this.getDataName ());
160 }dataset.addPDBId (entry);
161 var chainseq = dataset.deriveSequence ();
162 this.seqs.addElement (chainseq);
163 var chainannot = chainseq.getAnnotation ();
164 if (chainannot != null && this.visibleChainAnnotation) {
165 for (var ai = 0; ai < chainannot.length; ai++) {
166 chainannot[ai].visible = this.visibleChainAnnotation;
167 this.annotations.addElement (chainannot[ai]);
170 }, "MCview.PDBChain");
171 c$.isCalcIdHandled = Clazz.defineMethod (c$, "isCalcIdHandled",
173 return calcId != null && (MCview.PDBfile.CALC_ID_PREFIX.equals (calcId));
175 c$.isCalcIdForFile = Clazz.defineMethod (c$, "isCalcIdForFile",
176 function (alan, pdbFile) {
177 return alan.getCalcId () != null && MCview.PDBfile.CALC_ID_PREFIX.equals (alan.getCalcId ()) && pdbFile.equals (alan.getProperty ("PDBID"));
178 }, "jalview.datamodel.AlignmentAnnotation,~S");
179 c$.relocateCalcId = Clazz.defineMethod (c$, "relocateCalcId",
180 function (calcId, alreadyLoadedPDB) {
181 var s = MCview.PDBfile.CALC_ID_PREFIX.length;
182 var end = calcId.indexOf (MCview.PDBfile.CALC_ID_PREFIX, s);
183 var between = calcId.substring (s, end - 1);
184 return MCview.PDBfile.CALC_ID_PREFIX + alreadyLoadedPDB.get (between) + ":" + calcId.substring (end);
185 }, "~S,java.util.Hashtable");
186 Clazz.defineMethod (c$, "markCalcIds",
188 for (var sq, $sq = this.seqs.iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) {
189 if (sq.getAnnotation () != null) {
190 for (var aa, $aa = 0, $$aa = sq.getAnnotation (); $aa < $$aa.length && ((aa = $$aa[$aa]) || true); $aa++) {
191 var oldId = aa.getCalcId ();
194 }aa.setCalcId (MCview.PDBfile.CALC_ID_PREFIX);
195 aa.setProperty ("PDBID", this.id);
196 aa.setProperty ("oldCalcId", oldId);
199 }, $fz.isPrivate = true, $fz));
200 Clazz.defineMethod (c$, "processPdbFileWithJmol",
201 ($fz = function (prot) {
203 var cl = Class.forName ("jalview.ext.jmol.PDBFileWithJmol");
205 var constructor = cl.getConstructor ( Clazz.newArray (-1, [jalview.io.FileParse]));
206 var args = Clazz.newArray (-1, [ new jalview.io.FileParse (this.getDataName (), this.type)]);
207 var jmf = constructor.newInstance (args);
208 var al = new jalview.datamodel.Alignment (cl.getMethod ("getSeqsAsArray", Clazz.newArray (-1, [])).invoke (jmf, []));
209 cl.getMethod ("addAnnotations", Clazz.newArray (-1, [jalview.datamodel.AlignmentI])).invoke (jmf, [al]);
210 for (var sq, $sq = al.getSequences ().iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) {
211 if (sq.getDatasetSequence () != null) {
212 sq.getDatasetSequence ().getPDBId ().clear ();
214 sq.getPDBId ().clear ();
216 this.replaceAndUpdateChains (prot, al, "pep", false);
218 if (Clazz.exceptionOf (q, ClassNotFoundException)) {
223 }, $fz.isPrivate = true, $fz), "java.util.List");
224 Clazz.defineMethod (c$, "replaceAndUpdateChains",
225 ($fz = function (prot, al, pep, b) {
226 var replaced = jalview.analysis.AlignSeq.replaceMatchingSeqsWith (this.seqs, this.annotations, prot, al, pep, false);
227 for (var ch, $ch = this.chains.iterator (); $ch.hasNext () && ((ch = $ch.next ()) || true);) {
229 for (var sq, $sq = replaced.get (0).iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) {
231 if (sq === ch.sequence || sq.getDatasetSequence () === ch.sequence) {
237 ch.shadow = replaced.get (1).get (p);
238 ch.shadowMap = (replaced.get (2).get (p)).getMappingFromS1 (false);
240 }, $fz.isPrivate = true, $fz), "java.util.List,jalview.datamodel.AlignmentI,~S,~B");
241 Clazz.defineMethod (c$, "processPdbFileWithAnnotate3d",
242 ($fz = function (rna) {
244 var cl = Class.forName ("jalview.ws.jws1.Annotate3D");
246 var annotate3d = cl.getConstructor ( Clazz.newArray (-1, [])).newInstance ( Clazz.newArray (-1, []));
247 var al = (cl.getMethod ("getRNAMLFor", Clazz.newArray (-1, [jalview.io.FileParse])).invoke (annotate3d, Clazz.newArray (-1, [ new jalview.io.FileParse (this.getDataName (), this.type)])));
248 for (var sq, $sq = al.getSequences ().iterator (); $sq.hasNext () && ((sq = $sq.next ()) || true);) {
249 if (sq.getDatasetSequence () != null) {
250 if (sq.getDatasetSequence ().getPDBId () != null) {
251 sq.getDatasetSequence ().getPDBId ().clear ();
253 if (sq.getPDBId () != null) {
254 sq.getPDBId ().clear ();
256 this.replaceAndUpdateChains (rna, al, "dna", false);
258 if (Clazz.exceptionOf (x, ClassNotFoundException)) {
263 ;}, $fz.isPrivate = true, $fz), "java.util.List");
264 Clazz.defineMethod (c$, "safeName",
265 ($fz = function (dataName) {
267 while ((p = dataName.indexOf ("/")) > -1 && p < dataName.length) {
268 dataName = dataName.substring (p + 1);
271 }, $fz.isPrivate = true, $fz), "~S");
272 Clazz.defineMethod (c$, "makeResidueList",
274 for (var i = 0; i < this.chains.size (); i++) {
275 this.chains.elementAt (i).makeResidueList (this.visibleChainAnnotation);
278 Clazz.defineMethod (c$, "makeCaBondList",
280 for (var i = 0; i < this.chains.size (); i++) {
281 this.chains.elementAt (i).makeCaBondList ();
284 Clazz.defineMethod (c$, "findChain",
286 for (var i = 0; i < this.chains.size (); i++) {
287 if (this.chains.elementAt (i).id.equals (id)) {
288 return this.chains.elementAt (i);
292 Clazz.defineMethod (c$, "setChargeColours",
294 for (var i = 0; i < this.chains.size (); i++) {
295 this.chains.elementAt (i).setChargeColours ();
298 Clazz.defineMethod (c$, "setColours",
300 for (var i = 0; i < this.chains.size (); i++) {
301 this.chains.elementAt (i).setChainColours (cs);
303 }, "jalview.schemes.ColourSchemeI");
304 Clazz.defineMethod (c$, "setChainColours",
306 for (var i = 0; i < this.chains.size (); i++) {
307 this.chains.elementAt (i).setChainColours (java.awt.Color.getHSBColor (1.0 / i, .4, 1.0));
310 c$.isRNA = Clazz.defineMethod (c$, "isRNA",
312 for (var c, $c = 0, $$c = seq.getSequence (); $c < $$c.length && ((c = $$c[$c]) || true); $c++) {
313 if ((c != 'A') && (c != 'C') && (c != 'G') && (c != 'U')) {
317 }, "jalview.datamodel.SequenceI");
318 Clazz.defineStatics (c$,
319 "CALC_ID_PREFIX", "JalviewPDB");