1 Clazz.declarePackage ("MCview");
2 Clazz.load (["java.util.Vector"], "MCview.PDBChain", ["MCview.Bond", "$.Residue", "jalview.datamodel.AlignmentAnnotation", "$.Annotation", "$.Sequence", "$.SequenceFeature", "jalview.schemes.ResidueProperties", "java.awt.Color", "java.lang.StringBuilder"], function () {
3 c$ = Clazz.decorateAsClass (function () {
12 this.isVisible = true;
19 this.shadowMap = null;
20 Clazz.instantialize (this, arguments);
21 }, MCview, "PDBChain");
22 Clazz.prepareFields (c$, function () {
23 this.bonds = new java.util.Vector ();
24 this.atoms = new java.util.Vector ();
25 this.residues = new java.util.Vector ();
26 this.newline = System.getProperty ("line.separator");
28 Clazz.makeConstructor (c$,
29 function (pdbid, id) {
30 this.pdbid = pdbid.toLowerCase ();
33 Clazz.defineMethod (c$, "setNewlineString",
37 Clazz.defineMethod (c$, "getNewlineString",
41 Clazz.defineMethod (c$, "print",
43 var tmp = new StringBuilder (256);
44 for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) {
45 tmp.append (b.at1.resName).append (" ").append (b.at1.resNumber).append (" ").append (this.offset).append (this.newline);
47 return tmp.toString ();
49 Clazz.defineMethod (c$, "makeExactMapping",
51 var pdbpos = as.getSeq2Start () - 2;
52 var alignpos = s1.getStart () + as.getSeq1Start () - 3;
53 for (var atom, $atom = this.atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) {
54 atom.alignmentMapping = -1;
56 for (var i = 0; i < as.astr1.length; i++) {
57 if (as.astr1.charAt (i) != '-') {
59 }if (as.astr2.charAt (i) != '-') {
61 }if (as.astr1.charAt (i) == as.astr2.charAt (i)) {
62 var res = this.residues.elementAt (pdbpos);
63 for (var atom, $atom = res.atoms.iterator (); $atom.hasNext () && ((atom = $atom.next ()) || true);) {
64 atom.alignmentMapping = alignpos;
67 }, "jalview.analysis.AlignSeq,jalview.datamodel.SequenceI");
68 Clazz.defineMethod (c$, "transferRESNUMFeatures",
69 function (seq, status) {
71 while (sq != null && sq.getDatasetSequence () != null) {
72 sq = sq.getDatasetSequence ();
73 if (sq === this.sequence) {
77 status = "IEA:jalview";
78 }var features = this.sequence.getSequenceFeatures ();
79 for (var i = 0; i < features.length; i++) {
80 if (features[i].getFeatureGroup ().equals (this.pdbid)) {
81 var tx = new jalview.datamodel.SequenceFeature (features[i]);
82 tx.setBegin (1 + this.residues.elementAt (tx.getBegin () - this.offset).atoms.elementAt (0).alignmentMapping);
83 tx.setEnd (1 + this.residues.elementAt (tx.getEnd () - this.offset).atoms.elementAt (0).alignmentMapping);
84 tx.setStatus (status + ((tx.getStatus () == null || tx.getStatus ().length == 0) ? "" : ":" + tx.getStatus ()));
85 if (tx.begin != 0 && tx.end != 0) {
86 sq.addSequenceFeature (tx);
89 }, "jalview.datamodel.SequenceI,~S");
90 Clazz.defineMethod (c$, "makeCaBondList",
94 for (var i = 0; i < (this.residues.size () - 1); i++) {
95 var tmpres = this.residues.elementAt (i);
96 var tmpres2 = this.residues.elementAt (i + 1);
97 var at1 = tmpres.findAtom ("CA");
98 var at2 = tmpres2.findAtom ("CA");
100 if ((at1 == null) && (at2 == null)) {
102 at1 = tmpres.findAtom ("P");
103 at2 = tmpres2.findAtom ("P");
104 }if ((at1 != null) && (at2 != null)) {
105 if (at1.chain.equals (at2.chain)) {
108 }this.makeBond (at1, at2);
110 System.out.println ("not found " + i);
112 if (this.residues.size () > 0 && (Clazz.doubleToInt (numNa / (this.residues.size () - 1)) > 0.99)) {
115 Clazz.defineMethod (c$, "makeBond",
116 function (at1, at2) {
117 this.bonds.addElement ( new MCview.Bond (at1, at2));
118 }, "MCview.Atom,MCview.Atom");
119 Clazz.defineMethod (c$, "makeResidueList",
120 function (visibleChainAnnotation) {
124 var nucleotide = false;
125 var seq = new StringBuilder (256);
126 var resFeatures = new java.util.Vector ();
127 var resAnnotation = new java.util.Vector ();
129 var iSize = this.atoms.size () - 1;
131 for (i = 0; i <= iSize; i++) {
132 var tmp = this.atoms.elementAt (i);
133 resNumber = tmp.resNumber;
136 this.offset = resNumber;
137 }var resAtoms = new java.util.Vector ();
138 while ((resNumber == res) && (i < this.atoms.size ())) {
139 resAtoms.add (this.atoms.elementAt (i));
141 if (i < this.atoms.size ()) {
142 resNumber = this.atoms.elementAt (i).resNumber;
147 this.residues.addElement ( new MCview.Residue (resAtoms, resNumber - 1, count));
148 var tmpres = this.residues.lastElement ();
149 var tmpat = tmpres.atoms.get (0);
150 var sf = new jalview.datamodel.SequenceFeature ("RESNUM", tmpat.resName + ":" + tmpat.resNumIns + " " + this.pdbid + this.id, "", this.offset + count, this.offset + count, this.pdbid);
151 resFeatures.addElement (sf);
152 resAnnotation.addElement ( new jalview.datamodel.Annotation (tmpat.tfactor));
153 if ((symbol = jalview.schemes.ResidueProperties.getAA3Hash ().get (tmpat.resName)) == null) {
154 var nucname = tmpat.resName.trim ();
155 deoxyn = nucname.length == 2 && jalview.schemes.ResidueProperties.aaIndex[nucname.charCodeAt (0)] == jalview.schemes.ResidueProperties.aaIndex['D'.charCodeAt (0)];
156 if (tmpat.name.equalsIgnoreCase ("CA") || jalview.schemes.ResidueProperties.nucleotideIndex[nucname.charCodeAt ((deoxyn ? 1 : 0))] == -1) {
160 seq.append (nucname.charAt ((deoxyn ? 1 : 0)));
163 System.err.println ("Warning: mixed nucleotide and amino acid chain.. its gonna do bad things to you!");
164 }seq.append (jalview.schemes.ResidueProperties.aa[(symbol).intValue ()]);
167 if (this.id.length < 1) {
169 }this.isNa = nucleotide;
170 this.sequence = new jalview.datamodel.Sequence (this.id, seq.toString (), this.offset, resNumber - 1);
171 for (i = 0, iSize = resFeatures.size (); i < iSize; i++) {
172 this.sequence.addSequenceFeature (resFeatures.elementAt (i));
173 resFeatures.setElementAt (null, i);
175 if (visibleChainAnnotation) {
176 var annots = new Array (resAnnotation.size ());
178 for (i = 0, iSize = annots.length; i < iSize; i++) {
179 annots[i] = resAnnotation.elementAt (i);
180 if (annots[i].value > max) {
181 max = annots[i].value;
182 }resAnnotation.setElementAt (null, i);
184 var tfactorann = new jalview.datamodel.AlignmentAnnotation ("Temperature Factor", "Temperature Factor for " + this.pdbid + this.id, annots, 0, max, 2);
185 tfactorann.setSequenceRef (this.sequence);
186 this.sequence.addAlignmentAnnotation (tfactorann);
188 Clazz.defineMethod (c$, "setChargeColours",
190 for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) {
191 if (b.at1 != null && b.at2 != null) {
192 b.startCol = MCview.PDBChain.getChargeColour (b.at1.resName);
193 b.endCol = MCview.PDBChain.getChargeColour (b.at2.resName);
195 b.startCol = java.awt.Color.gray;
196 b.endCol = java.awt.Color.gray;
199 c$.getChargeColour = Clazz.defineMethod (c$, "getChargeColour",
201 var result = java.awt.Color.lightGray;
202 if ("ASP".equals (resName) || "GLU".equals (resName)) {
203 result = java.awt.Color.red;
204 } else if ("LYS".equals (resName) || "ARG".equals (resName)) {
205 result = java.awt.Color.blue;
206 } else if ("CYS".equals (resName)) {
207 result = java.awt.Color.yellow;
210 Clazz.defineMethod (c$, "setChainColours",
213 for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) {
215 index = jalview.schemes.ResidueProperties.aa3Hash.get (b.at1.resName).intValue ();
216 b.startCol = cs.findColour (jalview.schemes.ResidueProperties.aa[index].charAt (0));
217 index = jalview.schemes.ResidueProperties.aa3Hash.get (b.at2.resName).intValue ();
218 b.endCol = cs.findColour (jalview.schemes.ResidueProperties.aa[index].charAt (0));
220 if (Clazz.exceptionOf (e, Exception)) {
221 b.startCol = java.awt.Color.gray;
222 b.endCol = java.awt.Color.gray;
228 }, "jalview.schemes.ColourSchemeI");
229 Clazz.defineMethod (c$, "setChainColours",
231 for (var b, $b = this.bonds.iterator (); $b.hasNext () && ((b = $b.next ()) || true);) {
235 }, "java.awt.Color");
236 Clazz.defineMethod (c$, "transferResidueAnnotation",
237 function (mapping, sqmpping) {
238 var sq = mapping.getSequence ();
241 while (dsq.getDatasetSequence () != null) {
242 dsq = dsq.getDatasetSequence ();
244 if (this.shadow != null && this.shadow.getAnnotation () != null) {
245 for (var ana, $ana = 0, $$ana = this.shadow.getAnnotation (); $ana < $$ana.length && ((ana = $$ana[$ana]) || true); $ana++) {
246 var transfer = sq.getAlignmentAnnotations (ana.getCalcId (), ana.label);
247 if (transfer == null || transfer.size () == 0) {
248 ana = new jalview.datamodel.AlignmentAnnotation (ana);
249 ana.liftOver (this.sequence, this.shadowMap);
250 ana.liftOver (dsq, sqmpping);
251 dsq.addAlignmentAnnotation (ana);
256 if (this.sequence != null && this.sequence.getAnnotation () != null) {
257 for (var ana, $ana = 0, $$ana = this.sequence.getAnnotation (); $ana < $$ana.length && ((ana = $$ana[$ana]) || true); $ana++) {
258 var transfer = sq.getAlignmentAnnotations (ana.getCalcId (), ana.label);
259 if (transfer == null || transfer.size () == 0) {
260 ana = new jalview.datamodel.AlignmentAnnotation (ana);
261 ana.liftOver (dsq, sqmpping);
268 var an = new Array (sq.getEnd () - sq.getStart () + 1);
269 for (var i = sq.getStart (), j = sq.getEnd (), k = 0; i <= j; i++, k++) {
270 var prn = mapping.getPDBResNum (k + 1);
271 an[k] = new jalview.datamodel.Annotation (prn);
278 } else if (max < k) {
281 sq.addAlignmentAnnotation ( new jalview.datamodel.AlignmentAnnotation ("PDB.RESNUM", "PDB Residue Numbering for " + this.pdbid + ":" + this.id, an, min, max, 2));
282 }}}, "jalview.structure.StructureMapping,jalview.datamodel.Mapping");
283 Clazz.defineStatics (c$,
284 "PDBFILEFEATURE", "PDBFile",
285 "IEASTATUS", "IEA:jalview");