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