icn3d 3.51.0 → 3.51.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.module.js CHANGED
@@ -85028,18 +85028,30 @@ class ApplyClbonds {
85028
85028
  if(clbondArray === undefined) {
85029
85029
  break;
85030
85030
  }
85031
- for(let i = 0, il = clbondArray.length; i < il; i = i + 2) {
85032
- let resid1 = clbondArray[i];
85033
- let resid2 = clbondArray[i+1];
85034
85031
 
85035
- let atom1 = ic.firstAtomObjCls.getFirstAtomObj(ic.residues[resid1]);
85036
- let atom2 = ic.firstAtomObjCls.getFirstAtomObj(ic.residues[resid2]);
85032
+ let clusterArray = this.clusterLinkedNodes(clbondArray);
85033
+
85034
+ for(let i = 0, il = clusterArray.length; i < il; ++i) {
85035
+ let rootResid = 0;
85036
+ for(let j = 0, jl = clusterArray[i].length; j < jl; ++j) {
85037
+ let resid = clusterArray[i][j];
85038
+ let atom = ic.firstAtomObjCls.getFirstAtomObj(ic.residues[resid]);
85037
85039
 
85038
- if((ic.proteins.hasOwnProperty(atom1.serial) || ic.nucleotides.hasOwnProperty(atom1.serial)) && ic.chemicals.hasOwnProperty(atom2.serial)) {
85039
- ic.residues[resid1] = me.hashUtilsCls.unionHash(ic.residues[resid1], ic.residues[resid2]);
85040
+ if(ic.proteins.hasOwnProperty(atom.serial) || ic.nucleotides.hasOwnProperty(atom.serial)) {
85041
+ rootResid = resid;
85042
+ break;
85043
+ }
85040
85044
  }
85041
- else if((ic.proteins.hasOwnProperty(atom2.serial) || ic.nucleotides.hasOwnProperty(atom2.serial)) && ic.chemicals.hasOwnProperty(atom1.serial)) {
85042
- ic.residues[resid2] = me.hashUtilsCls.unionHash(ic.residues[resid2], ic.residues[resid1]);
85045
+
85046
+ if(rootResid) {
85047
+ for(let j = 0, jl = clusterArray[i].length; j < jl; ++j) {
85048
+ let resid = clusterArray[i][j];
85049
+ let atom = ic.firstAtomObjCls.getFirstAtomObj(ic.residues[resid]);
85050
+
85051
+ if(ic.chemicals.hasOwnProperty(atom.serial)) {
85052
+ ic.residues[rootResid] = me.hashUtilsCls.unionHash(ic.residues[rootResid], ic.residues[resid]);
85053
+ }
85054
+ }
85043
85055
  }
85044
85056
  }
85045
85057
  }
@@ -85047,6 +85059,45 @@ class ApplyClbonds {
85047
85059
  return ic.residuesHashClbonds;
85048
85060
  }
85049
85061
 
85062
+ clusterLinkedNodes(clbondArray) { let ic = this.icn3d; ic.icn3dui;
85063
+ const parent = new Map();
85064
+
85065
+ // Find the root of a node, with path compression
85066
+ function find(node) {
85067
+ if (!parent.has(node)) parent.set(node, node);
85068
+ if (parent.get(node) !== node) {
85069
+ parent.set(node, find(parent.get(node))); // path compression
85070
+ }
85071
+ return parent.get(node);
85072
+ }
85073
+
85074
+ // Union two nodes into the same cluster
85075
+ function union(a, b) {
85076
+ const rootA = find(a);
85077
+ const rootB = find(b);
85078
+ if (rootA !== rootB) parent.set(rootA, rootB);
85079
+ }
85080
+
85081
+ // Process all pairs
85082
+ // for (const [a, b] of pairs) {
85083
+ // union(a, b);
85084
+ // }
85085
+
85086
+ for(let i = 0, il = clbondArray.length; i < il; i = i + 2) {
85087
+ union(clbondArray[i], clbondArray[i+1]);
85088
+ }
85089
+
85090
+ // Group nodes by their root
85091
+ const clusters = new Map();
85092
+ for (const node of parent.keys()) {
85093
+ const root = find(node);
85094
+ if (!clusters.has(root)) clusters.set(root, []);
85095
+ clusters.get(root).push(node);
85096
+ }
85097
+
85098
+ return Array.from(clusters.values());
85099
+ }
85100
+
85050
85101
  applyClbondsOptions_base(type) { let ic = this.icn3d, me = ic.icn3dui;
85051
85102
  // only apply to displayed atoms
85052
85103
  let atomHash = me.hashUtilsCls.cloneHash(ic.chemicals);
@@ -85149,6 +85200,9 @@ class ApplyMissingRes {
85149
85200
  let bStart = false;
85150
85201
  let startResid, currResid, prevResid;
85151
85202
  let bCurrCoord, bPrevCoord = false;
85203
+
85204
+ if(!ic.chainsSeq[chainid]) continue;
85205
+
85152
85206
  for(let i = 0, il = ic.chainsSeq[chainid].length; i < il; ++i) {
85153
85207
  currResid = chainid + '_' + ic.chainsSeq[chainid][i].resi;
85154
85208
 
@@ -101832,6 +101886,8 @@ class GetGraph {
101832
101886
  "#" + ic.hColor.getHexString().toUpperCase();
101833
101887
  let pos = node.id.indexOf('.');
101834
101888
  let nodeName =(pos == -1) ? node.id : node.id.substr(0, pos);
101889
+ if(nodeName.length > 4) nodeName = nodeName.substr(0, 1) + '..' + nodeName.substr(nodeName.length - 2);
101890
+
101835
101891
  let adjustx = 0, adjusty =(setName == 'a') ? -7 : 10;
101836
101892
  if(i % 2 == 1) adjusty =(setName == 'a') ? adjusty - 7 : adjusty + 7;
101837
101893
 
@@ -108149,11 +108205,11 @@ class BcifParser {
108149
108205
 
108150
108206
  let chain1Array = struct_conn.getColumn("ptnr1_auth_asym_id");
108151
108207
  let name1Array = struct_conn.getColumn("ptnr1_label_atom_id");
108152
- let resi1Array = struct_conn.getColumn("ptnr1_label_seq_id");
108208
+ let resi1Array = struct_conn.getColumn("ptnr1_auth_seq_id");
108153
108209
 
108154
108210
  let chain2Array = struct_conn.getColumn("ptnr2_auth_asym_id");
108155
108211
  let name2Array = struct_conn.getColumn("ptnr2_label_atom_id");
108156
- let resi2Array = struct_conn.getColumn("ptnr2_label_seq_id");
108212
+ let resi2Array = struct_conn.getColumn("ptnr2_auth_seq_id");
108157
108213
 
108158
108214
  let connSize = struct_conn.rowCount;
108159
108215
  for (let i = 0; i < connSize; ++i) {
@@ -108345,7 +108401,7 @@ class BcifParser {
108345
108401
  else {
108346
108402
  // bond between this atom and all other atom in the same residue
108347
108403
  for(let j in mResi2Atoms[currResi]) { // j is atom.id
108348
- if(this.hasCovalentBond(atom, mResi2Atoms[currResi][j], para)) {
108404
+ if(this.hasCovalentBond2(atom, mResi2Atoms[currResi][j], para)) {
108349
108405
  if(!mId2Set.hasOwnProperty(atom.id)) mId2Set[atom.id] = {};
108350
108406
  if(!mId2Set.hasOwnProperty(mResi2Atoms[currResi][j].id)) mId2Set[mResi2Atoms[currResi][j].id] = {};
108351
108407
  mId2Set[atom.id][mResi2Atoms[currResi][j].id] = 1;
@@ -108358,7 +108414,7 @@ class BcifParser {
108358
108414
 
108359
108415
  // bond between N and previous C
108360
108416
  if(name == "N" && prevC.id != "") {
108361
- if(this.hasCovalentBond(atom, prevC, para)) {
108417
+ if(this.hasCovalentBond2(atom, prevC, para)) {
108362
108418
  if(!mId2Set.hasOwnProperty(atom.id)) mId2Set[atom.id] = {};
108363
108419
  if(!mId2Set.hasOwnProperty(prevC.id)) mId2Set[prevC.id] = {};
108364
108420
  mId2Set[atom.id][prevC.id] = 1;
@@ -108699,7 +108755,7 @@ class BcifParser {
108699
108755
  return text;
108700
108756
  }
108701
108757
 
108702
- hasCovalentBond(atom1, atom2, para) { let ic = this.icn3d; ic.icn3dui;
108758
+ hasCovalentBond2(atom1, atom2, para) { let ic = this.icn3d; ic.icn3dui;
108703
108759
  let r = this.mElem2Radius[atom1.elem] + this.mElem2Radius[atom2.elem];
108704
108760
 
108705
108761
  let dx = (atom1.x - atom2.x);
@@ -116973,6 +117029,10 @@ class LoadPDB {
116973
117029
  setResidMapping() { let ic = this.icn3d; ic.icn3dui;
116974
117030
  // set ic.ncbi2resid and ic.resid2ncbi
116975
117031
  for(let chainid in ic.chainsSeq) {
117032
+ if(!ic.chainsSeq[chainid]) {
117033
+ continue;
117034
+ }
117035
+
116976
117036
  for(let j = 0, jl = ic.chainsSeq[chainid].length; j < jl; ++j) {
116977
117037
  // NCBI residue number starts from 1 and increases continuously
116978
117038
  let residNCBI = chainid + '_' + (j+1).toString();
@@ -117322,6 +117382,7 @@ class LoadCIF {
117322
117382
  chain1Array = resi1Array = resi2Array = [];
117323
117383
  }
117324
117384
 
117385
+ // let vBonds = [];
117325
117386
  if(block.getCategory("_struct_conn")) {
117326
117387
  ic.bSsbondProvided = true;
117327
117388
 
@@ -117332,11 +117393,13 @@ class LoadCIF {
117332
117393
 
117333
117394
  let chain1Array = struct_conn.getColumn("ptnr1_auth_asym_id");
117334
117395
  let name1Array = struct_conn.getColumn("ptnr1_label_atom_id");
117335
- let resi1Array = struct_conn.getColumn("ptnr1_label_seq_id");
117396
+ let resi1Array = struct_conn.getColumn("ptnr1_auth_seq_id");
117397
+ // let resn1Array = struct_conn.getColumn("ptnr1_auth_comp_id");
117336
117398
 
117337
117399
  let chain2Array = struct_conn.getColumn("ptnr2_auth_asym_id");
117338
117400
  let name2Array = struct_conn.getColumn("ptnr2_label_atom_id");
117339
- let resi2Array = struct_conn.getColumn("ptnr2_label_seq_id");
117401
+ let resi2Array = struct_conn.getColumn("ptnr2_auth_seq_id");
117402
+ // let resn2Array = struct_conn.getColumn("ptnr2_auth_comp_id");
117340
117403
 
117341
117404
  let connSize = struct_conn.rowCount;
117342
117405
  for (let i = 0; i < connSize; ++i) {
@@ -117345,21 +117408,24 @@ class LoadCIF {
117345
117408
  let chain1 = chain1Array.getString(i);
117346
117409
  name1Array.getString(i);
117347
117410
  let resi1 = resi1Array.getString(i);
117411
+ // let resn1 = resn1Array.getString(i);
117348
117412
  let id1 = structure + '_' + chain1 + "_" + resi1;
117413
+
117414
+ // let chain1Tmp = (me.parasCls.residueAbbrev.hasOwnProperty(resn1)) ? chain1 : resn1;
117415
+ // let bondId1 = chain1Tmp + "_" + resi1 + "_" + name1;
117349
117416
 
117350
117417
  let chain2 = chain2Array.getString(i);
117351
117418
  name2Array.getString(i);
117352
117419
  let resi2 = resi2Array.getString(i);
117420
+ // let resn2 = resn2Array.getString(i);
117353
117421
  let id2 = structure + '_' + chain2 + "_" + resi2;
117354
-
117355
- // Verify that the linkage is covalent, as indicated by the conn_type_id attribute2
117356
-
117357
- // if (conn_type_id == "covale") {
117358
- // vBonds.push(id1);
117359
- // vBonds.push(id2);
117360
- // }
117361
-
117362
- if(conn_type_id == "disulf") {
117422
+
117423
+ // let chain2Tmp = (me.parasCls.residueAbbrev.hasOwnProperty(resn2)) ? chain2 : resn2;
117424
+ // let bondId2 = chain2Tmp + "_" + resi2 + "_" + name2;
117425
+
117426
+ // Verify that the linkage is covalent, as indicated by the conn_type_id attribute2
117427
+ if (conn_type_id == "covale") ;
117428
+ else if(conn_type_id == "disulf") {
117363
117429
  if(ic.ssbondpnts[structure] === undefined) ic.ssbondpnts[structure] = [];
117364
117430
 
117365
117431
  ic.ssbondpnts[structure].push(id1);
@@ -117492,6 +117558,7 @@ class LoadCIF {
117492
117558
  let nameArray = atom_site.getColumn("label_atom_id");
117493
117559
  let entiyidArray = atom_site.getColumn("label_entity_id");
117494
117560
 
117561
+ // check 3QUM
117495
117562
  let chainArray = atom_site.getColumn("auth_asym_id");
117496
117563
 
117497
117564
  let resiArray = atom_site.getColumn("label_seq_id");
@@ -117513,7 +117580,6 @@ class LoadCIF {
117513
117580
  let sChain = {};
117514
117581
  let prevModelNum = '';
117515
117582
  if(!ic.molid2chain) ic.molid2chain = {};
117516
-
117517
117583
  for (let i = 0; i < atomSize; ++i) {
117518
117584
  let modelNum = modelNumArray.getString(i);
117519
117585
  if(i > 0 && modelNum != prevModelNum) {
@@ -117541,7 +117607,6 @@ class LoadCIF {
117541
117607
 
117542
117608
  let autochain = autochainArray.getString(i);
117543
117609
 
117544
-
117545
117610
  resi = oriResi;
117546
117611
 
117547
117612
  let molecueType;
@@ -117560,7 +117625,7 @@ class LoadCIF {
117560
117625
  }
117561
117626
  else {
117562
117627
  molecueType = "ligand"; // ligands or ions
117563
- chain = resn;
117628
+ if(chain == "?" || chain == ".") chain = resn; // check 3QUM
117564
117629
  }
117565
117630
  }
117566
117631
  if(chain === '') chain = 'A';
@@ -117650,6 +117715,8 @@ class LoadCIF {
117650
117715
  let z = zArray.getFloat(i);
117651
117716
  let coord = new Vector3$1(x, y, z);
117652
117717
 
117718
+ let id = serial.toString();
117719
+
117653
117720
  let atomDetails = {
117654
117721
  het: (atom_hetatm == "HETATM"), // optional, used to determine chemicals, water, ions, etc
117655
117722
  serial: serial, // required, unique atom id
@@ -117806,6 +117873,30 @@ class LoadCIF {
117806
117873
  ic.residues[residueNum] = residuesTmp;
117807
117874
  if(ic.chains[chainNum] === undefined) ic.chains[chainNum] = {};
117808
117875
  ic.chains[chainNum] = me.hashUtilsCls.unionHash2Atoms(ic.chains[chainNum], chainsTmp, ic.atoms);
117876
+ /*
117877
+ /// add the defined bonds
117878
+ for(let i = 0; i < vBonds.length; i = i + 2) {
117879
+ let id1 = mName2Serial[vBonds[i]];
117880
+ let id2 = mName2Serial[vBonds[i+1]];
117881
+
117882
+ if(!mId2Set.hasOwnProperty(id1)) mId2Set[id1] = {};
117883
+ if(!mId2Set.hasOwnProperty(id2)) mId2Set[id2] = {};
117884
+ mId2Set[id1][id2] = 1;
117885
+ mId2Set[id2][id1] = 1;
117886
+ }
117887
+
117888
+ for(let id in mId2Set) {
117889
+ let sConnId = mId2Set[id];
117890
+ let vConnId = Object.keys(sConnId);
117891
+ let serial = parseInt(id);
117892
+
117893
+ for(let j = 0, jl = vConnId.length; j < jl; ++j) {
117894
+ if(vConnId[j] === 'undefined' || !ic.atoms[serial]) continue;
117895
+ if(!ic.atoms[serial].bonds) ic.atoms[serial].bonds = [];
117896
+ ic.atoms[serial].bonds.push(parseInt(vConnId[j]));
117897
+ }
117898
+ }
117899
+ */
117809
117900
 
117810
117901
  // clear memory
117811
117902
  atom_hetatmArray = resnArray = elemArray = nameArray = chainArray = resiArray = resiOriArray
@@ -117977,6 +118068,41 @@ class LoadCIF {
117977
118068
  }
117978
118069
  }
117979
118070
 
118071
+ // check the bonds between chemicals and all other atoms
118072
+ let processedChemicals = {};
118073
+ for(let i in ic.chemicals) {
118074
+ console.log(" i = ", i, " processedChemicals = ", processedChemicals);
118075
+ if(processedChemicals.hasOwnProperty(i)) continue;
118076
+
118077
+ let atom = ic.atoms[i];
118078
+ let resid = atom.structure + '_' + atom.chain + '_' + atom.resi;
118079
+
118080
+ let radius = 4;
118081
+ let residueAtoms = ic.residues[resid];
118082
+ let otherAtoms = me.hashUtilsCls.exclHash(ic.atoms, residueAtoms);
118083
+ let neighborAtoms = ic.contactCls.getAtomsWithinAtom(otherAtoms, residueAtoms, radius);
118084
+
118085
+ for(let j in residueAtoms) {
118086
+ let startAtom = ic.atoms[j];
118087
+ for(let k in neighborAtoms) {
118088
+ let neighborAtom = ic.atoms[k];
118089
+ let neighborResid = neighborAtom.structure + '_' + neighborAtom.chain + '_' + neighborAtom.resi;
118090
+ if(resid === neighborResid) continue;
118091
+
118092
+ if(me.utilsCls.hasCovalentBond(startAtom, neighborAtom)) {
118093
+ // Handle covalent bond
118094
+ if(!startAtom.bonds) startAtom.bonds = [];
118095
+ if(!neighborAtom.bonds) neighborAtom.bonds = [];
118096
+
118097
+ startAtom.bonds.push(neighborAtom.serial);
118098
+ neighborAtom.bonds.push(startAtom.serial);
118099
+ }
118100
+ }
118101
+ }
118102
+
118103
+ processedChemicals = me.hashUtilsCls.unionHash(processedChemicals, ic.residues[resid]);
118104
+ }
118105
+
117980
118106
  ic.pmin = pmin;
117981
118107
  ic.pmax = pmax;
117982
118108
 
@@ -136638,7 +136764,7 @@ class iCn3DUI {
136638
136764
  //even when multiple iCn3D viewers are shown together.
136639
136765
  this.pre = this.cfg.divid + "_";
136640
136766
 
136641
- this.REVISION = '3.51.0';
136767
+ this.REVISION = '3.51.1';
136642
136768
 
136643
136769
  // In nodejs, iCn3D defines "window = {navigator: {}}", and added window = {navigator: {}, "__THREE__":"177"}
136644
136770
  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.0",
3
+ "version": "3.51.2",
4
4
  "main": "./icn3d.js",
5
5
  "exports": {
6
6
  ".": {