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