1 Clazz.declarePackage ("jalview.structures.models");
\r
2 Clazz.load (["jalview.api.StructureSelectionManagerProvider", "jalview.structure.StructureListener", "jalview.structures.models.SequenceStructureBindingModel"], "jalview.structures.models.AAStructureBindingModel", ["jalview.util.Comparison", "$.MessageManager", "java.lang.Error", "$.StringBuilder", "java.util.ArrayList", "$.Arrays"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
5 this.pdbEntry = null;
\r
6 this.sequence = null;
\r
8 this.protocol = null;
\r
9 this.colourBySequence = true;
\r
10 this.nucleotide = false;
\r
11 if (!Clazz.isClassDefined ("jalview.structures.models.AAStructureBindingModel.SuperposeData")) {
\r
12 jalview.structures.models.AAStructureBindingModel.$AAStructureBindingModel$SuperposeData$ ();
\r
14 Clazz.instantialize (this, arguments);
\r
15 }, jalview.structures.models, "AAStructureBindingModel", jalview.structures.models.SequenceStructureBindingModel, [jalview.structure.StructureListener, jalview.api.StructureSelectionManagerProvider]);
\r
16 Clazz.makeConstructor (c$,
\r
17 function (ssm, seqs) {
\r
18 Clazz.superConstructor (this, jalview.structures.models.AAStructureBindingModel, []);
\r
20 this.sequence = seqs;
\r
21 }, "jalview.structure.StructureSelectionManager,~A");
\r
22 Clazz.makeConstructor (c$,
\r
23 function (ssm, pdbentry, sequenceIs, chains, protocol) {
\r
24 Clazz.superConstructor (this, jalview.structures.models.AAStructureBindingModel, []);
\r
26 this.sequence = sequenceIs;
\r
27 this.nucleotide = jalview.util.Comparison.isNucleotide2 (sequenceIs);
\r
28 this.chains = chains;
\r
29 this.pdbEntry = pdbentry;
\r
30 this.protocol = protocol;
\r
31 if (chains == null) {
\r
32 this.chains = new Array (pdbentry.length);
\r
33 }}, "jalview.structure.StructureSelectionManager,~A,~A,~A,~S");
\r
34 Clazz.defineMethod (c$, "getSsm",
\r
38 Clazz.defineMethod (c$, "getPdbEntry",
\r
40 return (this.pdbEntry != null && this.pdbEntry.length > i) ? this.pdbEntry[i] : null;
\r
42 Clazz.defineMethod (c$, "hasPdbId",
\r
44 if (this.pdbEntry != null) {
\r
45 for (var pdb, $pdb = 0, $$pdb = this.pdbEntry; $pdb < $$pdb.length && ((pdb = $$pdb[$pdb]) || true); $pdb++) {
\r
46 if (pdb.getId ().equals (pdbId)) {
\r
51 Clazz.defineMethod (c$, "getPdbCount",
\r
53 return this.pdbEntry == null ? 0 : this.pdbEntry.length;
\r
55 Clazz.defineMethod (c$, "getSequence",
\r
57 return this.sequence;
\r
59 Clazz.defineMethod (c$, "getChains",
\r
63 Clazz.defineMethod (c$, "getProtocol",
\r
65 return this.protocol;
\r
67 Clazz.defineMethod (c$, "setPdbentry",
\r
68 function (pdbentry) {
\r
69 this.pdbEntry = pdbentry;
\r
71 Clazz.defineMethod (c$, "setSequence",
\r
72 function (sequence) {
\r
73 this.sequence = sequence;
\r
75 Clazz.defineMethod (c$, "setChains",
\r
77 this.chains = chains;
\r
79 Clazz.defineMethod (c$, "getViewerTitle",
\r
80 function (viewerName, verbose) {
\r
81 if (this.getSequence () == null || this.getSequence ().length < 1 || this.getPdbCount () < 1 || this.getSequence ()[0].length < 1) {
\r
82 return ("Jalview " + viewerName + " Window");
\r
83 }var title = new StringBuilder (64);
\r
84 var pdbEntry = this.getPdbEntry (0);
\r
85 title.append (viewerName + " view for " + this.getSequence ()[0][0].getName () + ":" + pdbEntry.getId ());
\r
87 if (pdbEntry.getProperty () != null) {
\r
88 if (pdbEntry.getProperty ().get ("method") != null) {
\r
89 title.append (" Method: ");
\r
90 title.append (pdbEntry.getProperty ().get ("method"));
\r
91 }if (pdbEntry.getProperty ().get ("chains") != null) {
\r
92 title.append (" Chain:");
\r
93 title.append (pdbEntry.getProperty ().get ("chains"));
\r
94 }}}return title.toString ();
\r
96 Clazz.defineMethod (c$, "releaseUIResources",
\r
99 Clazz.defineMethod (c$, "isColourBySequence",
\r
101 return this.colourBySequence;
\r
103 Clazz.defineMethod (c$, "setColourBySequence",
\r
104 function (colourBySequence) {
\r
105 this.colourBySequence = colourBySequence;
\r
107 Clazz.defineMethod (c$, "addSequenceAndChain",
\r
108 function (pe, seq, tchain) {
\r
109 if (pe < 0 || pe >= this.getPdbCount ()) {
\r
110 throw new Error (jalview.util.MessageManager.formatMessage ("error.implementation_error_no_pdbentry_from_index", Clazz.newArray (-1, [Integer.$valueOf (pe).toString ()])));
\r
111 }var nullChain = "TheNullChain";
\r
112 var s = new java.util.ArrayList ();
\r
113 var c = new java.util.ArrayList ();
\r
114 if (this.getChains () == null) {
\r
115 this.setChains ( new Array (this.getPdbCount ()));
\r
116 }if (this.getSequence ()[pe] != null) {
\r
117 for (var i = 0; i < this.getSequence ()[pe].length; i++) {
\r
118 s.add (this.getSequence ()[pe][i]);
\r
119 if (this.getChains ()[pe] != null) {
\r
120 if (i < this.getChains ()[pe].length) {
\r
121 c.add (this.getChains ()[pe][i]);
\r
123 c.add ("TheNullChain");
\r
125 if (tchain != null && tchain.length > 0) {
\r
126 c.add ("TheNullChain");
\r
128 }for (var i = 0; i < seq.length; i++) {
\r
129 if (!s.contains (seq[i])) {
\r
131 if (tchain != null && i < tchain.length) {
\r
132 c.add (tchain[i] == null ? "TheNullChain" : tchain[i]);
\r
134 var tmp = s.toArray ( new Array (s.size ()));
\r
135 this.getSequence ()[pe] = tmp;
\r
136 if (c.size () > 0) {
\r
137 var tch = c.toArray ( new Array (c.size ()));
\r
138 for (var i = 0; i < tch.length; i++) {
\r
139 if (tch[i] === "TheNullChain") {
\r
142 this.getChains ()[pe] = tch;
\r
144 this.getChains ()[pe] = null;
\r
146 Clazz.defineMethod (c$, "addSequenceAndChain",
\r
147 function (pdbe, seq, chns) {
\r
148 var v = new java.util.ArrayList ();
\r
149 var rtn = new java.util.ArrayList ();
\r
150 for (var i = 0; i < this.getPdbCount (); i++) {
\r
151 v.add (this.getPdbEntry (i));
\r
153 for (var i = 0; i < pdbe.length; i++) {
\r
154 var r = v.indexOf (pdbe[i]);
\r
155 if (r == -1 || r >= this.getPdbCount ()) {
\r
156 rtn.add ( Clazz.newIntArray (-1, [v.size (), i]));
\r
159 this.addSequenceAndChain (r, seq[i], chns[i]);
\r
161 pdbe = v.toArray ( new Array (v.size ()));
\r
162 this.setPdbentry (pdbe);
\r
163 if (rtn.size () > 0) {
\r
164 var sqs = new Array (this.getPdbCount ());
\r
165 var sch = new Array (this.getPdbCount ());
\r
166 System.arraycopy (this.getSequence (), 0, sqs, 0, this.getSequence ().length);
\r
167 System.arraycopy (this.getChains (), 0, sch, 0, this.getChains ().length);
\r
168 this.setSequence (sqs);
\r
169 this.setChains (sch);
\r
170 pdbe = new Array (rtn.size ());
\r
171 for (var r = 0; r < pdbe.length; r++) {
\r
172 var stri = (rtn.get (r));
\r
173 pdbe[r] = this.getPdbEntry (stri[0]);
\r
174 this.addSequenceAndChain (stri[0], seq[stri[1]], chns[stri[1]]);
\r
180 Clazz.defineMethod (c$, "addSequence",
\r
181 function (pe, seq) {
\r
182 this.addSequenceAndChain (pe, seq, null);
\r
184 Clazz.defineMethod (c$, "addSequenceForStructFile",
\r
185 function (pdbFile, seq) {
\r
186 for (var pe = 0; pe < this.getPdbCount (); pe++) {
\r
187 if (this.getPdbEntry (pe).getFile ().equals (pdbFile)) {
\r
188 this.addSequence (pe, seq);
\r
191 Clazz.defineMethod (c$, "isNucleotide",
\r
193 return this.nucleotide;
\r
195 Clazz.defineMethod (c$, "printMappings",
\r
197 if (this.pdbEntry == null) {
\r
199 }var sb = new StringBuilder (128);
\r
200 for (var pdbe = 0; pdbe < this.getPdbCount (); pdbe++) {
\r
201 var pdbfile = this.getPdbEntry (pdbe).getFile ();
\r
202 var seqs = java.util.Arrays.asList (this.getSequence ()[pdbe]);
\r
203 sb.append (this.getSsm ().printMappings (pdbfile, seqs));
\r
205 return sb.toString ();
\r
207 Clazz.defineMethod (c$, "getMappedPosition",
\r
208 function (seq, alignedPos, mapping) {
\r
209 if (alignedPos >= seq.getLength ()) {
\r
211 }if (jalview.util.Comparison.isGap (seq.getCharAt (alignedPos))) {
\r
213 }var seqPos = seq.findPosition (alignedPos);
\r
214 var pos = mapping.getPDBResNum (seqPos);
\r
216 }, "jalview.datamodel.SequenceI,~N,jalview.structure.StructureMapping");
\r
217 Clazz.defineMethod (c$, "findSuperposableResidues",
\r
218 function (alignment, matched, structures) {
\r
219 var refStructure = -1;
\r
220 var files = this.getPdbFile ();
\r
221 for (var pdbfnum = 0; pdbfnum < files.length; pdbfnum++) {
\r
222 var mappings = this.getSsm ().getMapping (files[pdbfnum]);
\r
224 var seqCountForPdbFile = this.getSequence ()[pdbfnum].length;
\r
225 for (var s = 0; s < seqCountForPdbFile; s++) {
\r
226 for (var mapping, $mapping = 0, $$mapping = mappings; $mapping < $$mapping.length && ((mapping = $$mapping[$mapping]) || true); $mapping++) {
\r
227 var theSequence = this.getSequence ()[pdbfnum][s];
\r
228 if (mapping.getSequence () === theSequence && alignment.findIndex (theSequence) > -1) {
\r
229 if (refStructure < 0) {
\r
230 refStructure = pdbfnum;
\r
231 }for (var r = 0; r < matched.length; r++) {
\r
234 }var pos = this.getMappedPosition (theSequence, r, mapping);
\r
235 if (pos < 1 || pos == lastPos) {
\r
236 matched[r] = false;
\r
239 structures[pdbfnum].pdbResNo[r] = pos;
\r
241 var chain = mapping.getChain ();
\r
242 if (chain != null && chain.trim ().length > 0) {
\r
243 structures[pdbfnum].chain = chain;
\r
244 }structures[pdbfnum].pdbId = mapping.getPdbId ();
\r
245 structures[pdbfnum].isRna = theSequence.getRNA () != null;
\r
246 s = seqCountForPdbFile;
\r
251 return refStructure;
\r
252 }, "jalview.datamodel.AlignmentI,~A,~A");
\r
253 Clazz.defineMethod (c$, "waitForFileLoad",
\r
255 var starttime = System.currentTimeMillis ();
\r
256 var endTime = 10000 + 1000 * files.length + starttime;
\r
257 var notLoaded = null;
\r
258 var waiting = true;
\r
259 while (waiting && System.currentTimeMillis () < endTime) {
\r
261 for (var file, $file = 0, $$file = files; $file < $$file.length && ((file = $$file[$file]) || true); $file++) {
\r
264 var sm = this.getSsm ().getMapping (file);
\r
265 if (sm == null || sm.length == 0) {
\r
273 System.err.println ("Timed out waiting for structure viewer to load file " + notLoaded);
\r
277 Clazz.overrideMethod (c$, "isListeningFor",
\r
279 if (this.sequence != null) {
\r
280 for (var seqs, $seqs = 0, $$seqs = this.sequence; $seqs < $$seqs.length && ((seqs = $$seqs[$seqs]) || true); $seqs++) {
\r
281 if (seqs != null) {
\r
282 for (var s, $s = 0, $$s = seqs; $s < $$s.length && ((s = $$s[$s]) || true); $s++) {
\r
288 }, "jalview.datamodel.SequenceI");
\r
289 c$.$AAStructureBindingModel$SuperposeData$ = function () {
\r
290 Clazz.pu$h(self.c$);
\r
291 c$ = Clazz.decorateAsClass (function () {
\r
292 Clazz.prepareCallback (this, arguments);
\r
293 this.filename = null;
\r
296 this.isRna = false;
\r
297 this.pdbResNo = null;
\r
298 Clazz.instantialize (this, arguments);
\r
299 }, jalview.structures.models.AAStructureBindingModel, "SuperposeData");
\r
300 Clazz.makeConstructor (c$,
\r
302 this.pdbResNo = Clazz.newIntArray (a, 0);
\r