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