icn3d 3.51.0 → 3.51.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
@@ -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
 
@@ -108149,11 +108203,11 @@ class BcifParser {
108149
108203
 
108150
108204
  let chain1Array = struct_conn.getColumn("ptnr1_auth_asym_id");
108151
108205
  let name1Array = struct_conn.getColumn("ptnr1_label_atom_id");
108152
- let resi1Array = struct_conn.getColumn("ptnr1_label_seq_id");
108206
+ let resi1Array = struct_conn.getColumn("ptnr1_auth_seq_id");
108153
108207
 
108154
108208
  let chain2Array = struct_conn.getColumn("ptnr2_auth_asym_id");
108155
108209
  let name2Array = struct_conn.getColumn("ptnr2_label_atom_id");
108156
- let resi2Array = struct_conn.getColumn("ptnr2_label_seq_id");
108210
+ let resi2Array = struct_conn.getColumn("ptnr2_auth_seq_id");
108157
108211
 
108158
108212
  let connSize = struct_conn.rowCount;
108159
108213
  for (let i = 0; i < connSize; ++i) {
@@ -108345,7 +108399,7 @@ class BcifParser {
108345
108399
  else {
108346
108400
  // bond between this atom and all other atom in the same residue
108347
108401
  for(let j in mResi2Atoms[currResi]) { // j is atom.id
108348
- if(this.hasCovalentBond(atom, mResi2Atoms[currResi][j], para)) {
108402
+ if(this.hasCovalentBond2(atom, mResi2Atoms[currResi][j], para)) {
108349
108403
  if(!mId2Set.hasOwnProperty(atom.id)) mId2Set[atom.id] = {};
108350
108404
  if(!mId2Set.hasOwnProperty(mResi2Atoms[currResi][j].id)) mId2Set[mResi2Atoms[currResi][j].id] = {};
108351
108405
  mId2Set[atom.id][mResi2Atoms[currResi][j].id] = 1;
@@ -108358,7 +108412,7 @@ class BcifParser {
108358
108412
 
108359
108413
  // bond between N and previous C
108360
108414
  if(name == "N" && prevC.id != "") {
108361
- if(this.hasCovalentBond(atom, prevC, para)) {
108415
+ if(this.hasCovalentBond2(atom, prevC, para)) {
108362
108416
  if(!mId2Set.hasOwnProperty(atom.id)) mId2Set[atom.id] = {};
108363
108417
  if(!mId2Set.hasOwnProperty(prevC.id)) mId2Set[prevC.id] = {};
108364
108418
  mId2Set[atom.id][prevC.id] = 1;
@@ -108699,7 +108753,7 @@ class BcifParser {
108699
108753
  return text;
108700
108754
  }
108701
108755
 
108702
- hasCovalentBond(atom1, atom2, para) { let ic = this.icn3d; ic.icn3dui;
108756
+ hasCovalentBond2(atom1, atom2, para) { let ic = this.icn3d; ic.icn3dui;
108703
108757
  let r = this.mElem2Radius[atom1.elem] + this.mElem2Radius[atom2.elem];
108704
108758
 
108705
108759
  let dx = (atom1.x - atom2.x);
@@ -116973,6 +117027,10 @@ class LoadPDB {
116973
117027
  setResidMapping() { let ic = this.icn3d; ic.icn3dui;
116974
117028
  // set ic.ncbi2resid and ic.resid2ncbi
116975
117029
  for(let chainid in ic.chainsSeq) {
117030
+ if(!ic.chainsSeq[chainid]) {
117031
+ continue;
117032
+ }
117033
+
116976
117034
  for(let j = 0, jl = ic.chainsSeq[chainid].length; j < jl; ++j) {
116977
117035
  // NCBI residue number starts from 1 and increases continuously
116978
117036
  let residNCBI = chainid + '_' + (j+1).toString();
@@ -117322,6 +117380,7 @@ class LoadCIF {
117322
117380
  chain1Array = resi1Array = resi2Array = [];
117323
117381
  }
117324
117382
 
117383
+ // let vBonds = [];
117325
117384
  if(block.getCategory("_struct_conn")) {
117326
117385
  ic.bSsbondProvided = true;
117327
117386
 
@@ -117332,11 +117391,13 @@ class LoadCIF {
117332
117391
 
117333
117392
  let chain1Array = struct_conn.getColumn("ptnr1_auth_asym_id");
117334
117393
  let name1Array = struct_conn.getColumn("ptnr1_label_atom_id");
117335
- let resi1Array = struct_conn.getColumn("ptnr1_label_seq_id");
117394
+ let resi1Array = struct_conn.getColumn("ptnr1_auth_seq_id");
117395
+ // let resn1Array = struct_conn.getColumn("ptnr1_auth_comp_id");
117336
117396
 
117337
117397
  let chain2Array = struct_conn.getColumn("ptnr2_auth_asym_id");
117338
117398
  let name2Array = struct_conn.getColumn("ptnr2_label_atom_id");
117339
- let resi2Array = struct_conn.getColumn("ptnr2_label_seq_id");
117399
+ let resi2Array = struct_conn.getColumn("ptnr2_auth_seq_id");
117400
+ // let resn2Array = struct_conn.getColumn("ptnr2_auth_comp_id");
117340
117401
 
117341
117402
  let connSize = struct_conn.rowCount;
117342
117403
  for (let i = 0; i < connSize; ++i) {
@@ -117345,21 +117406,24 @@ class LoadCIF {
117345
117406
  let chain1 = chain1Array.getString(i);
117346
117407
  name1Array.getString(i);
117347
117408
  let resi1 = resi1Array.getString(i);
117409
+ // let resn1 = resn1Array.getString(i);
117348
117410
  let id1 = structure + '_' + chain1 + "_" + resi1;
117411
+
117412
+ // let chain1Tmp = (me.parasCls.residueAbbrev.hasOwnProperty(resn1)) ? chain1 : resn1;
117413
+ // let bondId1 = chain1Tmp + "_" + resi1 + "_" + name1;
117349
117414
 
117350
117415
  let chain2 = chain2Array.getString(i);
117351
117416
  name2Array.getString(i);
117352
117417
  let resi2 = resi2Array.getString(i);
117418
+ // let resn2 = resn2Array.getString(i);
117353
117419
  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") {
117420
+
117421
+ // let chain2Tmp = (me.parasCls.residueAbbrev.hasOwnProperty(resn2)) ? chain2 : resn2;
117422
+ // let bondId2 = chain2Tmp + "_" + resi2 + "_" + name2;
117423
+
117424
+ // Verify that the linkage is covalent, as indicated by the conn_type_id attribute2
117425
+ if (conn_type_id == "covale") ;
117426
+ else if(conn_type_id == "disulf") {
117363
117427
  if(ic.ssbondpnts[structure] === undefined) ic.ssbondpnts[structure] = [];
117364
117428
 
117365
117429
  ic.ssbondpnts[structure].push(id1);
@@ -117492,6 +117556,7 @@ class LoadCIF {
117492
117556
  let nameArray = atom_site.getColumn("label_atom_id");
117493
117557
  let entiyidArray = atom_site.getColumn("label_entity_id");
117494
117558
 
117559
+ // check 3QUM
117495
117560
  let chainArray = atom_site.getColumn("auth_asym_id");
117496
117561
 
117497
117562
  let resiArray = atom_site.getColumn("label_seq_id");
@@ -117513,7 +117578,6 @@ class LoadCIF {
117513
117578
  let sChain = {};
117514
117579
  let prevModelNum = '';
117515
117580
  if(!ic.molid2chain) ic.molid2chain = {};
117516
-
117517
117581
  for (let i = 0; i < atomSize; ++i) {
117518
117582
  let modelNum = modelNumArray.getString(i);
117519
117583
  if(i > 0 && modelNum != prevModelNum) {
@@ -117541,7 +117605,6 @@ class LoadCIF {
117541
117605
 
117542
117606
  let autochain = autochainArray.getString(i);
117543
117607
 
117544
-
117545
117608
  resi = oriResi;
117546
117609
 
117547
117610
  let molecueType;
@@ -117560,7 +117623,7 @@ class LoadCIF {
117560
117623
  }
117561
117624
  else {
117562
117625
  molecueType = "ligand"; // ligands or ions
117563
- chain = resn;
117626
+ if(chain == "?" || chain == ".") chain = resn; // check 3QUM
117564
117627
  }
117565
117628
  }
117566
117629
  if(chain === '') chain = 'A';
@@ -117650,6 +117713,8 @@ class LoadCIF {
117650
117713
  let z = zArray.getFloat(i);
117651
117714
  let coord = new Vector3$1(x, y, z);
117652
117715
 
117716
+ let id = serial.toString();
117717
+
117653
117718
  let atomDetails = {
117654
117719
  het: (atom_hetatm == "HETATM"), // optional, used to determine chemicals, water, ions, etc
117655
117720
  serial: serial, // required, unique atom id
@@ -117806,6 +117871,30 @@ class LoadCIF {
117806
117871
  ic.residues[residueNum] = residuesTmp;
117807
117872
  if(ic.chains[chainNum] === undefined) ic.chains[chainNum] = {};
117808
117873
  ic.chains[chainNum] = me.hashUtilsCls.unionHash2Atoms(ic.chains[chainNum], chainsTmp, ic.atoms);
117874
+ /*
117875
+ /// add the defined bonds
117876
+ for(let i = 0; i < vBonds.length; i = i + 2) {
117877
+ let id1 = mName2Serial[vBonds[i]];
117878
+ let id2 = mName2Serial[vBonds[i+1]];
117879
+
117880
+ if(!mId2Set.hasOwnProperty(id1)) mId2Set[id1] = {};
117881
+ if(!mId2Set.hasOwnProperty(id2)) mId2Set[id2] = {};
117882
+ mId2Set[id1][id2] = 1;
117883
+ mId2Set[id2][id1] = 1;
117884
+ }
117885
+
117886
+ for(let id in mId2Set) {
117887
+ let sConnId = mId2Set[id];
117888
+ let vConnId = Object.keys(sConnId);
117889
+ let serial = parseInt(id);
117890
+
117891
+ for(let j = 0, jl = vConnId.length; j < jl; ++j) {
117892
+ if(vConnId[j] === 'undefined' || !ic.atoms[serial]) continue;
117893
+ if(!ic.atoms[serial].bonds) ic.atoms[serial].bonds = [];
117894
+ ic.atoms[serial].bonds.push(parseInt(vConnId[j]));
117895
+ }
117896
+ }
117897
+ */
117809
117898
 
117810
117899
  // clear memory
117811
117900
  atom_hetatmArray = resnArray = elemArray = nameArray = chainArray = resiArray = resiOriArray
@@ -117977,6 +118066,41 @@ class LoadCIF {
117977
118066
  }
117978
118067
  }
117979
118068
 
118069
+ // check the bonds between chemicals and all other atoms
118070
+ let processedChemicals = {};
118071
+ for(let i in ic.chemicals) {
118072
+ console.log(" i = ", i, " processedChemicals = ", processedChemicals);
118073
+ if(processedChemicals.hasOwnProperty(i)) continue;
118074
+
118075
+ let atom = ic.atoms[i];
118076
+ let resid = atom.structure + '_' + atom.chain + '_' + atom.resi;
118077
+
118078
+ let radius = 4;
118079
+ let residueAtoms = ic.residues[resid];
118080
+ let otherAtoms = me.hashUtilsCls.exclHash(ic.atoms, residueAtoms);
118081
+ let neighborAtoms = ic.contactCls.getAtomsWithinAtom(otherAtoms, residueAtoms, radius);
118082
+
118083
+ for(let j in residueAtoms) {
118084
+ let startAtom = ic.atoms[j];
118085
+ for(let k in neighborAtoms) {
118086
+ let neighborAtom = ic.atoms[k];
118087
+ let neighborResid = neighborAtom.structure + '_' + neighborAtom.chain + '_' + neighborAtom.resi;
118088
+ if(resid === neighborResid) continue;
118089
+
118090
+ if(me.utilsCls.hasCovalentBond(startAtom, neighborAtom)) {
118091
+ // Handle covalent bond
118092
+ if(!startAtom.bonds) startAtom.bonds = [];
118093
+ if(!neighborAtom.bonds) neighborAtom.bonds = [];
118094
+
118095
+ startAtom.bonds.push(neighborAtom.serial);
118096
+ neighborAtom.bonds.push(startAtom.serial);
118097
+ }
118098
+ }
118099
+ }
118100
+
118101
+ processedChemicals = me.hashUtilsCls.unionHash(processedChemicals, ic.residues[resid]);
118102
+ }
118103
+
117980
118104
  ic.pmin = pmin;
117981
118105
  ic.pmax = pmax;
117982
118106
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icn3d",
3
- "version": "3.51.0",
3
+ "version": "3.51.1",
4
4
  "main": "./icn3d.js",
5
5
  "exports": {
6
6
  ".": {