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.module.js CHANGED
@@ -109006,12 +109006,15 @@ class OpmParser {
109006
109006
 
109007
109007
  async loadOpmData(data, pdbid, bFull, type, pdbid2, bText) { let ic = this.icn3d, me = ic.icn3dui;
109008
109008
  try {
109009
- if(!pdbid) pdbid = ic.defaultPdbId;
109010
- let url = me.htmlCls.baseUrl + "mmdb/mmdb_strview.cgi?v=2&program=icn3d&opm&uid=" + pdbid.toLowerCase();
109009
+ if(!pdbid) pdbid = ic.defaultPdbId;
109011
109010
 
109012
- let opmdata = await me.getAjaxPromise(url, 'jsonp', false);
109013
-
109014
- this.setOpmData(opmdata); // set ic.bOpm
109011
+ if(me.cfg.mmtfid === undefined && me.cfg.bcifid === undefined) { // skip opm for bcif files
109012
+ let url = me.htmlCls.baseUrl + "mmdb/mmdb_strview.cgi?v=2&program=icn3d&opm&uid=" + pdbid.toLowerCase();
109013
+
109014
+ let opmdata = await me.getAjaxPromise(url, 'jsonp', false);
109015
+
109016
+ this.setOpmData(opmdata); // set ic.bOpm
109017
+ }
109015
109018
 
109016
109019
  await this.parseAtomData(data, pdbid, bFull, type, pdbid2, bText);
109017
109020
  }
@@ -117188,6 +117191,36 @@ class LoadCIF {
117188
117191
  this.icn3d = icn3d;
117189
117192
  }
117190
117193
 
117194
+ // Fast replacements for ic.loadPDBCls.isSecondary(), which does a linear scan
117195
+ // ($.inArray, or a hand-rolled loop with a substr() per comparison for bNMR) over
117196
+ // residArray - and gets called up to 6 times per atom in the main atom loop below.
117197
+ // buildSecondarySet() precomputes, once per model, exactly what isSecondary would
117198
+ // have compared against on every call (the raw resid strings for non-NMR, or the
117199
+ // structure-prefix-stripped "chain_resi" strings for NMR - matching isSecondary's
117200
+ // two branches exactly), so membership becomes an O(1) Set lookup instead of an
117201
+ // O(residArray.length) scan repeated for every atom. isSecondary's 4th parameter
117202
+ // (bNonFull) is intentionally not replicated here: in the actual implementation
117203
+ // it's dead (the only reference to it is commented out), so it has no behavior to
117204
+ // preserve.
117205
+ buildSecondarySet(residArray, bNMR) {
117206
+ let s = new Set();
117207
+ if(!bNMR) {
117208
+ for(let i = 0, il = residArray.length; i < il; ++i) s.add(residArray[i]);
117209
+ }
117210
+ else {
117211
+ for(let i = 0, il = residArray.length; i < il; ++i) {
117212
+ let r = residArray[i];
117213
+ s.add(r.substr(r.indexOf('_') + 1));
117214
+ }
117215
+ }
117216
+ return s;
117217
+ }
117218
+
117219
+ isSecondaryFast(resid, secondarySet, bNMR) {
117220
+ if(!bNMR) return secondarySet.has(resid);
117221
+ return secondarySet.has(resid.substr(resid.indexOf('_') + 1));
117222
+ }
117223
+
117191
117224
  loadCIF(bcifData, bcifid, bText, bAppend) { let ic = this.icn3d, me = ic.icn3dui;
117192
117225
  let hAtoms = {};
117193
117226
 
@@ -117564,7 +117597,10 @@ class LoadCIF {
117564
117597
  // check 3QUM
117565
117598
  let chainArray = atom_site.getColumn("auth_asym_id");
117566
117599
 
117567
- let resiArray = atom_site.getColumn("label_seq_id");
117600
+ // label_seq_id used to be fetched into "resiArray" here and decoded into
117601
+ // "resi" below, but that value was always immediately overwritten by
117602
+ // auth_seq_id (oriResi) before being used anywhere - decoding it per atom
117603
+ // was pure wasted work, so it is no longer fetched at all.
117568
117604
  let resiOriArray = atom_site.getColumn("auth_seq_id");
117569
117605
  let altArray = atom_site.getColumn("label_alt_id");
117570
117606
 
@@ -117577,6 +117613,14 @@ class LoadCIF {
117577
117613
  let autochainArray = atom_site.getColumn("label_asym_id");
117578
117614
  let modelNumArray = atom_site.getColumn("pdbx_PDB_model_num");
117579
117615
 
117616
+ // built once per model instead of scanned per atom - see isSecondaryFast()
117617
+ let sheetSet = this.buildSecondarySet(sheetArray, bNMR);
117618
+ let sheetStartSet = this.buildSecondarySet(sheetStart, bNMR);
117619
+ let sheetEndSet = this.buildSecondarySet(sheetEnd, bNMR);
117620
+ let helixSet = this.buildSecondarySet(helixArray, bNMR);
117621
+ let helixStartSet = this.buildSecondarySet(helixStart, bNMR);
117622
+ let helixEndSet = this.buildSecondarySet(helixEnd, bNMR);
117623
+
117580
117624
  // get the bond info
117581
117625
  let ligSeqHash = {}, prevAutochain = '';
117582
117626
  let prevResn;
@@ -117603,14 +117647,13 @@ class LoadCIF {
117603
117647
  let atom = nameArray.getString(i);
117604
117648
  let entityid = entiyidArray.getString(i);
117605
117649
  let chain = chainArray.getString(i);
117606
- let resi = resiArray.getString(i);
117607
117650
  let oriResi = resiOriArray.getString(i);
117608
117651
  let alt = altArray.getString(i);
117609
117652
  let bFactor = bArray.getString(i);
117610
117653
 
117611
117654
  let autochain = autochainArray.getString(i);
117612
117655
 
117613
- resi = oriResi;
117656
+ let resi = oriResi;
117614
117657
 
117615
117658
  let molecueType;
117616
117659
  if(atom_hetatm == "ATOM") {
@@ -117765,26 +117808,26 @@ class LoadCIF {
117765
117808
 
117766
117809
  // Assign secondary structures from the input
117767
117810
  // if a residue is assigned both sheet and helix, it is assigned as sheet
117768
- if(ic.loadPDBCls.isSecondary(residueNum, sheetArray, bNMR, !bFull)) {
117811
+ if(this.isSecondaryFast(residueNum, sheetSet, bNMR)) {
117769
117812
  ic.atoms[serial].ss = 'sheet';
117770
- if(ic.loadPDBCls.isSecondary(residueNum, sheetStart, bNMR, !bFull)) {
117813
+ if(this.isSecondaryFast(residueNum, sheetStartSet, bNMR)) {
117771
117814
  ic.atoms[serial].ssbegin = true;
117772
117815
  }
117773
117816
 
117774
117817
  // do not use else if. Some residues are both start and end of secondary structure
117775
- if(ic.loadPDBCls.isSecondary(residueNum, sheetEnd, bNMR, !bFull)) {
117818
+ if(this.isSecondaryFast(residueNum, sheetEndSet, bNMR)) {
117776
117819
  ic.atoms[serial].ssend = true;
117777
117820
  }
117778
117821
  }
117779
- else if(ic.loadPDBCls.isSecondary(residueNum, helixArray, bNMR, !bFull)) {
117822
+ else if(this.isSecondaryFast(residueNum, helixSet, bNMR)) {
117780
117823
  ic.atoms[serial].ss = 'helix';
117781
117824
 
117782
- if(ic.loadPDBCls.isSecondary(residueNum, helixStart, bNMR, !bFull)) {
117825
+ if(this.isSecondaryFast(residueNum, helixStartSet, bNMR)) {
117783
117826
  ic.atoms[serial].ssbegin = true;
117784
117827
  }
117785
117828
 
117786
117829
  // do not use else if. Some residues are both start and end of secondary structure
117787
- if(ic.loadPDBCls.isSecondary(residueNum, helixEnd, bNMR, !bFull)) {
117830
+ if(this.isSecondaryFast(residueNum, helixEndSet, bNMR)) {
117788
117831
  ic.atoms[serial].ssend = true;
117789
117832
  }
117790
117833
  }
@@ -117902,7 +117945,7 @@ class LoadCIF {
117902
117945
  */
117903
117946
 
117904
117947
  // clear memory
117905
- atom_hetatmArray = resnArray = elemArray = nameArray = chainArray = resiArray = resiOriArray
117948
+ atom_hetatmArray = resnArray = elemArray = nameArray = chainArray = resiOriArray
117906
117949
  = altArray = bArray = xArray = yArray = zArray = autochainArray = [];
117907
117950
 
117908
117951
  let mChainSeq = {};
@@ -118074,7 +118117,6 @@ class LoadCIF {
118074
118117
  // check the bonds between chemicals and all other atoms
118075
118118
  let processedChemicals = {};
118076
118119
  for(let i in ic.chemicals) {
118077
- console.log(" i = ", i, " processedChemicals = ", processedChemicals);
118078
118120
  if(processedChemicals.hasOwnProperty(i)) continue;
118079
118121
 
118080
118122
  let atom = ic.atoms[i];
@@ -136776,7 +136818,7 @@ class iCn3DUI {
136776
136818
  //even when multiple iCn3D viewers are shown together.
136777
136819
  this.pre = this.cfg.divid + "_";
136778
136820
 
136779
- this.REVISION = '3.51.2';
136821
+ this.REVISION = '3.52.0';
136780
136822
 
136781
136823
  // In nodejs, iCn3D defines "window = {navigator: {}}", and added window = {navigator: {}, "__THREE__":"177"}
136782
136824
  this.bNode = (Object.keys(window).length < 3) ? true : false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icn3d",
3
- "version": "3.51.4",
3
+ "version": "3.52.1",
4
4
  "main": "./icn3d.js",
5
5
  "exports": {
6
6
  ".": {