icn3d 3.21.0 → 3.21.2

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
@@ -15321,7 +15321,7 @@ class Html {
15321
15321
 
15322
15322
  //this.baseUrl = "https://structure.ncbi.nlm.nih.gov/";
15323
15323
  this.baseUrl = (window && window.location && window.location.hostname == 'structure.ncbi.nlm.nih.gov')
15324
- ? "https://structure.ncbi.nlm.nih.gov/Structure/" : "https://test.ncbi.nlm.nih.gov/Structure/";
15324
+ ? "https://structure.ncbi.nlm.nih.gov/Structure/" : "https://www.ncbi.nlm.nih.gov/Structure/";
15325
15325
  this.divStr = "<div id='" + this.icn3dui.pre;
15326
15326
  this.divNowrapStr = "<div style='white-space:nowrap'>";
15327
15327
  this.spanNowrapStr = "<span style='white-space:nowrap'>";
@@ -34138,7 +34138,7 @@ class AnnoCddSite {
34138
34138
  for(let s = 0, sl = segArray.length; s < sl; ++s) {
34139
34139
  let domainFrom = Math.round(segArray[s].from);
34140
34140
  let domainTo = Math.round(segArray[s].to);
34141
-
34141
+
34142
34142
  // if(ic.bNCBI) {
34143
34143
  // fromArray.push(domainFrom);
34144
34144
  // toArray.push(domainTo);
@@ -34148,8 +34148,11 @@ class AnnoCddSite {
34148
34148
  // toArray.push(thisClass.getAdjustedResi(domainTo, chnid, ic.matchedPos, ic.chainsSeq, ic.baseResi) - 1);
34149
34149
  // }
34150
34150
 
34151
- fromArray.push(ic.ParserUtilsCls.getResi(chnid, domainFrom));
34152
- toArray.push(ic.ParserUtilsCls.getResi(chnid, domainTo));
34151
+ // fromArray.push(ic.ParserUtilsCls.getResi(chnid, domainFrom));
34152
+ // toArray.push(ic.ParserUtilsCls.getResi(chnid, domainTo));
34153
+
34154
+ fromArray.push(domainFrom);
34155
+ toArray.push(domainTo);
34153
34156
 
34154
34157
  for(let i = domainFrom; i <= domainTo; ++i) {
34155
34158
  resiHash[i] = 1;
@@ -38859,7 +38862,8 @@ class ShowAnno {
38859
38862
  if(me.cfg.blast_rep_id === undefined) {
38860
38863
  if(ic.bFullUi) {
38861
38864
  if(me.cfg.mmtfid !== undefined) { // mmtf data do NOT have the missing residues
38862
- let id = chainArray[0].substr(0, chainArray[0].indexOf('_'));
38865
+ //let id = chainArray[0].substr(0, chainArray[0].indexOf('_'));
38866
+ let id = Object.keys(ic.structures)[0];
38863
38867
 
38864
38868
  await ic.mmcifParserCls.downloadMmcifSymmetry(id, 'mmtfid');
38865
38869
  }
@@ -40408,7 +40412,7 @@ class HlSeq {
40408
40412
  to = parseInt(toArray[i]);
40409
40413
 
40410
40414
  for(let j = from; j <= to; ++j) {
40411
- // if(ic.bNCBI && ($(that).attr('domain') !== undefined || $(that).attr('feat') !== undefined || $(that).attr('3ddomain') !== undefined) ) {
40415
+ /*
40412
40416
  if( ($(that).attr('domain') !== undefined || $(that).attr('feat') !== undefined || $(that).attr('3ddomain') !== undefined) ) {
40413
40417
  let residNCBI = chainid + '_' + (j+1).toString();
40414
40418
  // AlphaFold domains calculated on-the-fly have no conversion
@@ -40424,6 +40428,12 @@ class HlSeq {
40424
40428
 
40425
40429
  residueid = ic.ncbi2resid[residNCBI];
40426
40430
  }
40431
+ */
40432
+
40433
+ if(($(that).attr('domain') !== undefined || $(that).attr('feat') !== undefined) || $(that).attr('3ddomain') !== undefined) {
40434
+ let residNCBI = chainid + '_' + (j+1).toString();
40435
+ residueid = ic.ncbi2resid[residNCBI];
40436
+ }
40427
40437
  else {
40428
40438
  residueid = chainid + '_' + (j+1).toString();
40429
40439
  }
@@ -40861,7 +40871,7 @@ class HlUpdate {
40861
40871
  // update annotation windows and alignment sequences
40862
40872
  let chainHash = {};
40863
40873
  for(let i = 0, il = residueArray.length; i < il; ++i) {
40864
- let pickedResidue = residueArray[i];
40874
+ let pickedResidue = residueArray[i].trim();
40865
40875
  //[id$= is expensive to search id ending with
40866
40876
  //var resElem = $("[id$=" + ic.pre + pickedResidue + "]");
40867
40877
  let resElem = $("[id=giseq_" + ic.pre + pickedResidue + "]");
@@ -45814,6 +45824,16 @@ class MmdbParser {
45814
45824
  }
45815
45825
  }
45816
45826
 
45827
+ //Ajax call was used to get the atom data from the NCBI "gi". This function was deferred so that
45828
+ //it can be chained together with other deferred functions for sequential execution. Note that
45829
+ //only one structure corresponding to the gi will be shown. If there is no structures available
45830
+ //for the gi, a warning message will be shown.
45831
+ async downloadGi(gi) { let ic = this.icn3d; ic.icn3dui;
45832
+ ic.bCid = undefined;
45833
+ let bGi = true;
45834
+ await this.downloadMmdb(gi, bGi);
45835
+ }
45836
+
45817
45837
  //Ajax call was used to get the atom data from "sequence_id_comma_structure_id", comma-separated
45818
45838
  //NCBI protein accessions of a protein sequence and a chain of a 3D structure (e.g., 23491729,1TUP_A).
45819
45839
  //This function was deferred so that it can be chained together with other deferred functions for
@@ -46974,7 +46994,7 @@ class PdbParser {
46974
46994
  ic.InputfileType = type;
46975
46995
 
46976
46996
  if(type === 'pdb') {
46977
- await thisClass.loadPdbData(data);
46997
+ await this.loadPdbData(data);
46978
46998
  await ic.loadScriptCls.loadScript(command, undefined, true);
46979
46999
  }
46980
47000
  else if(type === 'mmcif') {
@@ -52125,12 +52145,11 @@ class LoadPDB {
52125
52145
  //let chainMissingResidueArray = {}
52126
52146
 
52127
52147
  let id = (pdbid) ? pdbid : 'stru';
52148
+ let structure = id;
52128
52149
 
52129
52150
  let prevMissingChain = '';
52130
52151
  let CSerial, prevCSerial, OSerial, prevOSerial;
52131
-
52132
- let structure = "stru";
52133
-
52152
+
52134
52153
  let bHeader = false;
52135
52154
 
52136
52155
  for (let i in lines) {
@@ -52181,7 +52200,7 @@ class LoadPDB {
52181
52200
 
52182
52201
  if(j === startResi) helixStart.push(resid);
52183
52202
  if(j === endResi) helixEnd.push(resid);
52184
- }
52203
+ }
52185
52204
  } else if (record === 'SHEET ') {
52186
52205
  //ic.bSecondaryStructure = true;
52187
52206
  if(bOpm === undefined || !bOpm) ic.bSecondaryStructure = true;
@@ -52243,10 +52262,7 @@ class LoadPDB {
52243
52262
  //let chain = line.substr(19, 1);
52244
52263
  let chain = line.substr(18, 2).trim();
52245
52264
  //let resi = parseInt(line.substr(21, 5));
52246
- let resi = line.substr(21, 5);
52247
-
52248
- //var structure = parseInt(line.substr(13, 1));
52249
- //if(line.substr(13, 1) == ' ') structure = 1;
52265
+ let resi = line.substr(21, 5).trim();
52250
52266
 
52251
52267
  //var chainNum = structure + '_' + chain;
52252
52268
  let chainNum = id + '_' + chain;
@@ -52718,73 +52734,81 @@ class LoadPDB {
52718
52734
  for(let chainNum in ic.chainsSeq) {
52719
52735
  if(chainMissingResidueArray[chainNum] === undefined) continue;
52720
52736
 
52721
- //let A = ic.chainsSeq[chainNum];
52722
- //let B = chainMissingResidueArray[chainNum];
52723
-
52724
- let A = chainMissingResidueArray[chainNum];
52725
- let B = ic.chainsSeq[chainNum];
52726
-
52727
- let m = A.length;
52728
- let n = B.length;
52729
-
52730
- let C = new Array(m + n);
52731
- //var C2 = new Array(m + n);
52732
- //var C3 = new Array(m + n);
52733
-
52734
- // http://www.algolist.net/Algorithms/Merge/Sorted_arrays
52735
- // m - size of A
52736
- // n - size of B
52737
- // size of C array must be equal or greater than m + n
52738
- let i, j, k;
52739
- i = 0;
52740
- j = 0;
52741
- k = 0;
52742
- while (i < m && j < n) {
52743
- if (parseInt(A[i].resi) <= parseInt(B[j].resi)) {
52744
- C[k] = A[i];
52745
- //C2[k] = A2[i];
52746
- //C3[k] = A3[i];
52747
- i++;
52748
- } else {
52749
- C[k] = B[j];
52750
- //if(B[j].resi % 10 === 0) {
52751
- // C2[k] = B[j].resi.toString();
52752
- //}
52753
- //else {
52754
- // C2[k] = '';
52755
- //}
52756
- //C3[k] = '-';
52757
- j++;
52737
+ ic.chainsSeq[chainNum] = this.mergeTwoSequences(chainMissingResidueArray[chainNum], ic.chainsSeq[chainNum]);
52738
+ }
52739
+
52740
+ this.setResidMapping();
52741
+ }
52742
+
52743
+ mergeTwoSequences(A, B) {
52744
+ let m = A.length; // missing residues
52745
+ let n = B.length; // residues with coord
52746
+
52747
+ // inserted domain such as PRK150 in the R chain of PDB 6WW2
52748
+ let lastResiA = parseInt(A[m - 1].resi);
52749
+ let lastResiB = parseInt(B[n - 1].resi);
52750
+ let lastResi = (lastResiA >= lastResiB) ? lastResiA : lastResiB;
52751
+
52752
+ let C = new Array(m + n);
52753
+ // http://www.algolist.net/Algorithms/Merge/Sorted_arrays
52754
+ // m - size of A
52755
+ // n - size of B
52756
+ // size of C array must be equal or greater than m + n
52757
+ let i = 0, j = 0, k = 0;
52758
+ let bInsertion = false;
52759
+
52760
+ while (i < m && j < n) {
52761
+ let aResi = parseInt(A[i].resi), bResi = parseInt(B[j].resi);
52762
+ if(aResi > lastResi && bResi > lastResi) bInsertion = true;
52763
+
52764
+ if(aResi <= lastResi && bResi > lastResi) {
52765
+ if (aResi > bResi || bInsertion) {
52766
+ C[k] = B[j];
52767
+ j++;
52758
52768
  }
52759
- k++;
52760
- }
52761
- if (i < m) {
52762
- for (let p = i; p < m; p++) {
52763
- C[k] = A[p];
52764
- //C2[k] = A2[p];
52765
- //C3[k] = A3[p];
52766
- k++;
52769
+ else {
52770
+ C[k] = A[i];
52771
+ i++;
52767
52772
  }
52768
- } else {
52769
- for (let p = j; p < n; p++) {
52770
- C[k] = B[p];
52771
- //if(B[p].resi % 10 === 0) {
52772
- // C2[k] = B[p].resi.toString();
52773
- //}
52774
- //else {
52775
- // C2[k] = '';
52776
- //}
52777
- //C3[k] = '-';
52778
- k++;
52773
+ }
52774
+ else if(aResi > lastResi && bResi <= lastResi) {
52775
+ if (aResi <= bResi || bInsertion) {
52776
+ C[k] = A[i];
52777
+ i++;
52779
52778
  }
52780
- }
52779
+ else {
52780
+ C[k] = B[j];
52781
+ j++;
52782
+ }
52783
+ }
52784
+ else {
52785
+ if (aResi <= bResi) {
52786
+ C[k] = A[i];
52787
+ i++;
52788
+ }
52789
+ else {
52790
+ C[k] = B[j];
52791
+ j++;
52792
+ }
52793
+ }
52781
52794
 
52782
- ic.chainsSeq[chainNum] = C;
52783
- //ic.chainsAn[chainNum][0] = C2;
52784
- //ic.chainsAn[chainNum][1] = C3;
52785
- }
52795
+ k++;
52796
+ }
52786
52797
 
52787
- this.setResidMapping();
52798
+ if (i < m) {
52799
+ for (let p = i; p < m; p++) {
52800
+ C[k] = A[p];
52801
+ k++;
52802
+ }
52803
+ }
52804
+ else {
52805
+ for (let p = j; p < n; p++) {
52806
+ C[k] = B[p];
52807
+ k++;
52808
+ }
52809
+ }
52810
+
52811
+ return C;
52788
52812
  }
52789
52813
 
52790
52814
  setResidMapping() { let ic = this.icn3d; ic.icn3dui;
@@ -56582,6 +56606,10 @@ class LoadScript {
56582
56606
 
56583
56607
  await ic.chainalignParserCls.downloadMmdbAf(id);
56584
56608
  }
56609
+ else if(command.indexOf('load gi') !== -1) {
56610
+ me.cfg.gi = id;
56611
+ await ic.mmdbParserCls.downloadGi(id);
56612
+ }
56585
56613
  else if(command.indexOf('load refseq') !== -1) {
56586
56614
  me.cfg.refseqid = id;
56587
56615
  await ic.mmdbParserCls.downloadRefseq(id);
@@ -67388,7 +67416,7 @@ class iCn3DUI {
67388
67416
  //even when multiple iCn3D viewers are shown together.
67389
67417
  this.pre = this.cfg.divid + "_";
67390
67418
 
67391
- this.REVISION = '3.21.0';
67419
+ this.REVISION = '3.21.1';
67392
67420
 
67393
67421
  // In nodejs, iCn3D defines "window = {navigator: {}}"
67394
67422
  this.bNode = (Object.keys(window).length < 2) ? true : false;
@@ -67665,6 +67693,12 @@ iCn3DUI.prototype.show3DStructure = async function(pdbStr) { let me = this;
67665
67693
  me.htmlCls.clickMenuCls.setLogCmd(ic.loadCmd, true);
67666
67694
  await ic.mmdbParserCls.downloadMmdb(me.cfg.mmdbid);
67667
67695
  }
67696
+ else if(me.cfg.gi !== undefined) {
67697
+ // ic.bNCBI = true;
67698
+ ic.loadCmd = 'load gi ' + me.cfg.gi;
67699
+ me.htmlCls.clickMenuCls.setLogCmd(ic.loadCmd, true);
67700
+ await ic.mmdbParserCls.downloadGi(me.cfg.gi);
67701
+ }
67668
67702
  else if(me.cfg.refseqid !== undefined) {
67669
67703
  ic.inputid = me.cfg.refseqid;
67670
67704