icn3d 3.51.4 → 3.52.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/icn3d.js CHANGED
@@ -108105,12 +108105,15 @@ class OpmParser {
108105
108105
 
108106
108106
  async loadOpmData(data, pdbid, bFull, type, pdbid2, bText) { let ic = this.icn3d, me = ic.icn3dui;
108107
108107
  try {
108108
- if(!pdbid) pdbid = ic.defaultPdbId;
108109
- let url = me.htmlCls.baseUrl + "mmdb/mmdb_strview.cgi?v=2&program=icn3d&opm&uid=" + pdbid.toLowerCase();
108108
+ if(!pdbid) pdbid = ic.defaultPdbId;
108110
108109
 
108111
- let opmdata = await me.getAjaxPromise(url, 'jsonp', false);
108112
-
108113
- this.setOpmData(opmdata); // set ic.bOpm
108110
+ if(me.cfg.mmtfid === undefined && me.cfg.bcifid === undefined) { // skip opm for bcif files
108111
+ let url = me.htmlCls.baseUrl + "mmdb/mmdb_strview.cgi?v=2&program=icn3d&opm&uid=" + pdbid.toLowerCase();
108112
+
108113
+ let opmdata = await me.getAjaxPromise(url, 'jsonp', false);
108114
+
108115
+ this.setOpmData(opmdata); // set ic.bOpm
108116
+ }
108114
108117
 
108115
108118
  await this.parseAtomData(data, pdbid, bFull, type, pdbid2, bText);
108116
108119
  }
@@ -116287,6 +116290,36 @@ class LoadCIF {
116287
116290
  this.icn3d = icn3d;
116288
116291
  }
116289
116292
 
116293
+ // Fast replacements for ic.loadPDBCls.isSecondary(), which does a linear scan
116294
+ // ($.inArray, or a hand-rolled loop with a substr() per comparison for bNMR) over
116295
+ // residArray - and gets called up to 6 times per atom in the main atom loop below.
116296
+ // buildSecondarySet() precomputes, once per model, exactly what isSecondary would
116297
+ // have compared against on every call (the raw resid strings for non-NMR, or the
116298
+ // structure-prefix-stripped "chain_resi" strings for NMR - matching isSecondary's
116299
+ // two branches exactly), so membership becomes an O(1) Set lookup instead of an
116300
+ // O(residArray.length) scan repeated for every atom. isSecondary's 4th parameter
116301
+ // (bNonFull) is intentionally not replicated here: in the actual implementation
116302
+ // it's dead (the only reference to it is commented out), so it has no behavior to
116303
+ // preserve.
116304
+ buildSecondarySet(residArray, bNMR) {
116305
+ let s = new Set();
116306
+ if(!bNMR) {
116307
+ for(let i = 0, il = residArray.length; i < il; ++i) s.add(residArray[i]);
116308
+ }
116309
+ else {
116310
+ for(let i = 0, il = residArray.length; i < il; ++i) {
116311
+ let r = residArray[i];
116312
+ s.add(r.substr(r.indexOf('_') + 1));
116313
+ }
116314
+ }
116315
+ return s;
116316
+ }
116317
+
116318
+ isSecondaryFast(resid, secondarySet, bNMR) {
116319
+ if(!bNMR) return secondarySet.has(resid);
116320
+ return secondarySet.has(resid.substr(resid.indexOf('_') + 1));
116321
+ }
116322
+
116290
116323
  loadCIF(bcifData, bcifid, bText, bAppend) { let ic = this.icn3d, me = ic.icn3dui;
116291
116324
  let hAtoms = {};
116292
116325
 
@@ -116663,7 +116696,10 @@ class LoadCIF {
116663
116696
  // check 3QUM
116664
116697
  let chainArray = atom_site.getColumn("auth_asym_id");
116665
116698
 
116666
- let resiArray = atom_site.getColumn("label_seq_id");
116699
+ // label_seq_id used to be fetched into "resiArray" here and decoded into
116700
+ // "resi" below, but that value was always immediately overwritten by
116701
+ // auth_seq_id (oriResi) before being used anywhere - decoding it per atom
116702
+ // was pure wasted work, so it is no longer fetched at all.
116667
116703
  let resiOriArray = atom_site.getColumn("auth_seq_id");
116668
116704
  let altArray = atom_site.getColumn("label_alt_id");
116669
116705
 
@@ -116676,6 +116712,14 @@ class LoadCIF {
116676
116712
  let autochainArray = atom_site.getColumn("label_asym_id");
116677
116713
  let modelNumArray = atom_site.getColumn("pdbx_PDB_model_num");
116678
116714
 
116715
+ // built once per model instead of scanned per atom - see isSecondaryFast()
116716
+ let sheetSet = this.buildSecondarySet(sheetArray, bNMR);
116717
+ let sheetStartSet = this.buildSecondarySet(sheetStart, bNMR);
116718
+ let sheetEndSet = this.buildSecondarySet(sheetEnd, bNMR);
116719
+ let helixSet = this.buildSecondarySet(helixArray, bNMR);
116720
+ let helixStartSet = this.buildSecondarySet(helixStart, bNMR);
116721
+ let helixEndSet = this.buildSecondarySet(helixEnd, bNMR);
116722
+
116679
116723
  // get the bond info
116680
116724
  let ligSeqHash = {}, prevAutochain = '';
116681
116725
  let prevResn;
@@ -116702,14 +116746,13 @@ class LoadCIF {
116702
116746
  let atom = nameArray.getString(i);
116703
116747
  let entityid = entiyidArray.getString(i);
116704
116748
  let chain = chainArray.getString(i);
116705
- let resi = resiArray.getString(i);
116706
116749
  let oriResi = resiOriArray.getString(i);
116707
116750
  let alt = altArray.getString(i);
116708
116751
  let bFactor = bArray.getString(i);
116709
116752
 
116710
116753
  let autochain = autochainArray.getString(i);
116711
116754
 
116712
- resi = oriResi;
116755
+ let resi = oriResi;
116713
116756
 
116714
116757
  let molecueType;
116715
116758
  if(atom_hetatm == "ATOM") {
@@ -116864,26 +116907,26 @@ class LoadCIF {
116864
116907
 
116865
116908
  // Assign secondary structures from the input
116866
116909
  // if a residue is assigned both sheet and helix, it is assigned as sheet
116867
- if(ic.loadPDBCls.isSecondary(residueNum, sheetArray, bNMR, !bFull)) {
116910
+ if(this.isSecondaryFast(residueNum, sheetSet, bNMR)) {
116868
116911
  ic.atoms[serial].ss = 'sheet';
116869
- if(ic.loadPDBCls.isSecondary(residueNum, sheetStart, bNMR, !bFull)) {
116912
+ if(this.isSecondaryFast(residueNum, sheetStartSet, bNMR)) {
116870
116913
  ic.atoms[serial].ssbegin = true;
116871
116914
  }
116872
116915
 
116873
116916
  // do not use else if. Some residues are both start and end of secondary structure
116874
- if(ic.loadPDBCls.isSecondary(residueNum, sheetEnd, bNMR, !bFull)) {
116917
+ if(this.isSecondaryFast(residueNum, sheetEndSet, bNMR)) {
116875
116918
  ic.atoms[serial].ssend = true;
116876
116919
  }
116877
116920
  }
116878
- else if(ic.loadPDBCls.isSecondary(residueNum, helixArray, bNMR, !bFull)) {
116921
+ else if(this.isSecondaryFast(residueNum, helixSet, bNMR)) {
116879
116922
  ic.atoms[serial].ss = 'helix';
116880
116923
 
116881
- if(ic.loadPDBCls.isSecondary(residueNum, helixStart, bNMR, !bFull)) {
116924
+ if(this.isSecondaryFast(residueNum, helixStartSet, bNMR)) {
116882
116925
  ic.atoms[serial].ssbegin = true;
116883
116926
  }
116884
116927
 
116885
116928
  // do not use else if. Some residues are both start and end of secondary structure
116886
- if(ic.loadPDBCls.isSecondary(residueNum, helixEnd, bNMR, !bFull)) {
116929
+ if(this.isSecondaryFast(residueNum, helixEndSet, bNMR)) {
116887
116930
  ic.atoms[serial].ssend = true;
116888
116931
  }
116889
116932
  }
@@ -117001,7 +117044,7 @@ class LoadCIF {
117001
117044
  */
117002
117045
 
117003
117046
  // clear memory
117004
- atom_hetatmArray = resnArray = elemArray = nameArray = chainArray = resiArray = resiOriArray
117047
+ atom_hetatmArray = resnArray = elemArray = nameArray = chainArray = resiOriArray
117005
117048
  = altArray = bArray = xArray = yArray = zArray = autochainArray = [];
117006
117049
 
117007
117050
  let mChainSeq = {};
@@ -117173,7 +117216,6 @@ class LoadCIF {
117173
117216
  // check the bonds between chemicals and all other atoms
117174
117217
  let processedChemicals = {};
117175
117218
  for(let i in ic.chemicals) {
117176
- console.log(" i = ", i, " processedChemicals = ", processedChemicals);
117177
117219
  if(processedChemicals.hasOwnProperty(i)) continue;
117178
117220
 
117179
117221
  let atom = ic.atoms[i];
@@ -135875,7 +135917,7 @@ class iCn3DUI {
135875
135917
  //even when multiple iCn3D viewers are shown together.
135876
135918
  this.pre = this.cfg.divid + "_";
135877
135919
 
135878
- this.REVISION = '3.51.2';
135920
+ this.REVISION = '3.52.0';
135879
135921
 
135880
135922
  // In nodejs, iCn3D defines "window = {navigator: {}}", and added window = {navigator: {}, "__THREE__":"177"}
135881
135923
  this.bNode = (Object.keys(window).length < 3) ? true : false;