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.js +152 -28
- package/icn3d.min.js +2 -2
- package/icn3d.module.js +152 -28
- package/package.json +1 -1
package/icn3d.js
CHANGED
|
@@ -84127,18 +84127,30 @@ class ApplyClbonds {
|
|
|
84127
84127
|
if(clbondArray === undefined) {
|
|
84128
84128
|
break;
|
|
84129
84129
|
}
|
|
84130
|
-
for(let i = 0, il = clbondArray.length; i < il; i = i + 2) {
|
|
84131
|
-
let resid1 = clbondArray[i];
|
|
84132
|
-
let resid2 = clbondArray[i+1];
|
|
84133
84130
|
|
|
84134
|
-
|
|
84135
|
-
|
|
84131
|
+
let clusterArray = this.clusterLinkedNodes(clbondArray);
|
|
84132
|
+
|
|
84133
|
+
for(let i = 0, il = clusterArray.length; i < il; ++i) {
|
|
84134
|
+
let rootResid = 0;
|
|
84135
|
+
for(let j = 0, jl = clusterArray[i].length; j < jl; ++j) {
|
|
84136
|
+
let resid = clusterArray[i][j];
|
|
84137
|
+
let atom = ic.firstAtomObjCls.getFirstAtomObj(ic.residues[resid]);
|
|
84136
84138
|
|
|
84137
|
-
|
|
84138
|
-
|
|
84139
|
+
if(ic.proteins.hasOwnProperty(atom.serial) || ic.nucleotides.hasOwnProperty(atom.serial)) {
|
|
84140
|
+
rootResid = resid;
|
|
84141
|
+
break;
|
|
84142
|
+
}
|
|
84139
84143
|
}
|
|
84140
|
-
|
|
84141
|
-
|
|
84144
|
+
|
|
84145
|
+
if(rootResid) {
|
|
84146
|
+
for(let j = 0, jl = clusterArray[i].length; j < jl; ++j) {
|
|
84147
|
+
let resid = clusterArray[i][j];
|
|
84148
|
+
let atom = ic.firstAtomObjCls.getFirstAtomObj(ic.residues[resid]);
|
|
84149
|
+
|
|
84150
|
+
if(ic.chemicals.hasOwnProperty(atom.serial)) {
|
|
84151
|
+
ic.residues[rootResid] = me.hashUtilsCls.unionHash(ic.residues[rootResid], ic.residues[resid]);
|
|
84152
|
+
}
|
|
84153
|
+
}
|
|
84142
84154
|
}
|
|
84143
84155
|
}
|
|
84144
84156
|
}
|
|
@@ -84146,6 +84158,45 @@ class ApplyClbonds {
|
|
|
84146
84158
|
return ic.residuesHashClbonds;
|
|
84147
84159
|
}
|
|
84148
84160
|
|
|
84161
|
+
clusterLinkedNodes(clbondArray) { let ic = this.icn3d; ic.icn3dui;
|
|
84162
|
+
const parent = new Map();
|
|
84163
|
+
|
|
84164
|
+
// Find the root of a node, with path compression
|
|
84165
|
+
function find(node) {
|
|
84166
|
+
if (!parent.has(node)) parent.set(node, node);
|
|
84167
|
+
if (parent.get(node) !== node) {
|
|
84168
|
+
parent.set(node, find(parent.get(node))); // path compression
|
|
84169
|
+
}
|
|
84170
|
+
return parent.get(node);
|
|
84171
|
+
}
|
|
84172
|
+
|
|
84173
|
+
// Union two nodes into the same cluster
|
|
84174
|
+
function union(a, b) {
|
|
84175
|
+
const rootA = find(a);
|
|
84176
|
+
const rootB = find(b);
|
|
84177
|
+
if (rootA !== rootB) parent.set(rootA, rootB);
|
|
84178
|
+
}
|
|
84179
|
+
|
|
84180
|
+
// Process all pairs
|
|
84181
|
+
// for (const [a, b] of pairs) {
|
|
84182
|
+
// union(a, b);
|
|
84183
|
+
// }
|
|
84184
|
+
|
|
84185
|
+
for(let i = 0, il = clbondArray.length; i < il; i = i + 2) {
|
|
84186
|
+
union(clbondArray[i], clbondArray[i+1]);
|
|
84187
|
+
}
|
|
84188
|
+
|
|
84189
|
+
// Group nodes by their root
|
|
84190
|
+
const clusters = new Map();
|
|
84191
|
+
for (const node of parent.keys()) {
|
|
84192
|
+
const root = find(node);
|
|
84193
|
+
if (!clusters.has(root)) clusters.set(root, []);
|
|
84194
|
+
clusters.get(root).push(node);
|
|
84195
|
+
}
|
|
84196
|
+
|
|
84197
|
+
return Array.from(clusters.values());
|
|
84198
|
+
}
|
|
84199
|
+
|
|
84149
84200
|
applyClbondsOptions_base(type) { let ic = this.icn3d, me = ic.icn3dui;
|
|
84150
84201
|
// only apply to displayed atoms
|
|
84151
84202
|
let atomHash = me.hashUtilsCls.cloneHash(ic.chemicals);
|
|
@@ -84248,6 +84299,9 @@ class ApplyMissingRes {
|
|
|
84248
84299
|
let bStart = false;
|
|
84249
84300
|
let startResid, currResid, prevResid;
|
|
84250
84301
|
let bCurrCoord, bPrevCoord = false;
|
|
84302
|
+
|
|
84303
|
+
if(!ic.chainsSeq[chainid]) continue;
|
|
84304
|
+
|
|
84251
84305
|
for(let i = 0, il = ic.chainsSeq[chainid].length; i < il; ++i) {
|
|
84252
84306
|
currResid = chainid + '_' + ic.chainsSeq[chainid][i].resi;
|
|
84253
84307
|
|
|
@@ -107248,11 +107302,11 @@ class BcifParser {
|
|
|
107248
107302
|
|
|
107249
107303
|
let chain1Array = struct_conn.getColumn("ptnr1_auth_asym_id");
|
|
107250
107304
|
let name1Array = struct_conn.getColumn("ptnr1_label_atom_id");
|
|
107251
|
-
let resi1Array = struct_conn.getColumn("
|
|
107305
|
+
let resi1Array = struct_conn.getColumn("ptnr1_auth_seq_id");
|
|
107252
107306
|
|
|
107253
107307
|
let chain2Array = struct_conn.getColumn("ptnr2_auth_asym_id");
|
|
107254
107308
|
let name2Array = struct_conn.getColumn("ptnr2_label_atom_id");
|
|
107255
|
-
let resi2Array = struct_conn.getColumn("
|
|
107309
|
+
let resi2Array = struct_conn.getColumn("ptnr2_auth_seq_id");
|
|
107256
107310
|
|
|
107257
107311
|
let connSize = struct_conn.rowCount;
|
|
107258
107312
|
for (let i = 0; i < connSize; ++i) {
|
|
@@ -107444,7 +107498,7 @@ class BcifParser {
|
|
|
107444
107498
|
else {
|
|
107445
107499
|
// bond between this atom and all other atom in the same residue
|
|
107446
107500
|
for(let j in mResi2Atoms[currResi]) { // j is atom.id
|
|
107447
|
-
if(this.
|
|
107501
|
+
if(this.hasCovalentBond2(atom, mResi2Atoms[currResi][j], para)) {
|
|
107448
107502
|
if(!mId2Set.hasOwnProperty(atom.id)) mId2Set[atom.id] = {};
|
|
107449
107503
|
if(!mId2Set.hasOwnProperty(mResi2Atoms[currResi][j].id)) mId2Set[mResi2Atoms[currResi][j].id] = {};
|
|
107450
107504
|
mId2Set[atom.id][mResi2Atoms[currResi][j].id] = 1;
|
|
@@ -107457,7 +107511,7 @@ class BcifParser {
|
|
|
107457
107511
|
|
|
107458
107512
|
// bond between N and previous C
|
|
107459
107513
|
if(name == "N" && prevC.id != "") {
|
|
107460
|
-
if(this.
|
|
107514
|
+
if(this.hasCovalentBond2(atom, prevC, para)) {
|
|
107461
107515
|
if(!mId2Set.hasOwnProperty(atom.id)) mId2Set[atom.id] = {};
|
|
107462
107516
|
if(!mId2Set.hasOwnProperty(prevC.id)) mId2Set[prevC.id] = {};
|
|
107463
107517
|
mId2Set[atom.id][prevC.id] = 1;
|
|
@@ -107798,7 +107852,7 @@ class BcifParser {
|
|
|
107798
107852
|
return text;
|
|
107799
107853
|
}
|
|
107800
107854
|
|
|
107801
|
-
|
|
107855
|
+
hasCovalentBond2(atom1, atom2, para) { let ic = this.icn3d; ic.icn3dui;
|
|
107802
107856
|
let r = this.mElem2Radius[atom1.elem] + this.mElem2Radius[atom2.elem];
|
|
107803
107857
|
|
|
107804
107858
|
let dx = (atom1.x - atom2.x);
|
|
@@ -116072,6 +116126,10 @@ class LoadPDB {
|
|
|
116072
116126
|
setResidMapping() { let ic = this.icn3d; ic.icn3dui;
|
|
116073
116127
|
// set ic.ncbi2resid and ic.resid2ncbi
|
|
116074
116128
|
for(let chainid in ic.chainsSeq) {
|
|
116129
|
+
if(!ic.chainsSeq[chainid]) {
|
|
116130
|
+
continue;
|
|
116131
|
+
}
|
|
116132
|
+
|
|
116075
116133
|
for(let j = 0, jl = ic.chainsSeq[chainid].length; j < jl; ++j) {
|
|
116076
116134
|
// NCBI residue number starts from 1 and increases continuously
|
|
116077
116135
|
let residNCBI = chainid + '_' + (j+1).toString();
|
|
@@ -116421,6 +116479,7 @@ class LoadCIF {
|
|
|
116421
116479
|
chain1Array = resi1Array = resi2Array = [];
|
|
116422
116480
|
}
|
|
116423
116481
|
|
|
116482
|
+
// let vBonds = [];
|
|
116424
116483
|
if(block.getCategory("_struct_conn")) {
|
|
116425
116484
|
ic.bSsbondProvided = true;
|
|
116426
116485
|
|
|
@@ -116431,11 +116490,13 @@ class LoadCIF {
|
|
|
116431
116490
|
|
|
116432
116491
|
let chain1Array = struct_conn.getColumn("ptnr1_auth_asym_id");
|
|
116433
116492
|
let name1Array = struct_conn.getColumn("ptnr1_label_atom_id");
|
|
116434
|
-
let resi1Array = struct_conn.getColumn("
|
|
116493
|
+
let resi1Array = struct_conn.getColumn("ptnr1_auth_seq_id");
|
|
116494
|
+
// let resn1Array = struct_conn.getColumn("ptnr1_auth_comp_id");
|
|
116435
116495
|
|
|
116436
116496
|
let chain2Array = struct_conn.getColumn("ptnr2_auth_asym_id");
|
|
116437
116497
|
let name2Array = struct_conn.getColumn("ptnr2_label_atom_id");
|
|
116438
|
-
let resi2Array = struct_conn.getColumn("
|
|
116498
|
+
let resi2Array = struct_conn.getColumn("ptnr2_auth_seq_id");
|
|
116499
|
+
// let resn2Array = struct_conn.getColumn("ptnr2_auth_comp_id");
|
|
116439
116500
|
|
|
116440
116501
|
let connSize = struct_conn.rowCount;
|
|
116441
116502
|
for (let i = 0; i < connSize; ++i) {
|
|
@@ -116444,21 +116505,24 @@ class LoadCIF {
|
|
|
116444
116505
|
let chain1 = chain1Array.getString(i);
|
|
116445
116506
|
name1Array.getString(i);
|
|
116446
116507
|
let resi1 = resi1Array.getString(i);
|
|
116508
|
+
// let resn1 = resn1Array.getString(i);
|
|
116447
116509
|
let id1 = structure + '_' + chain1 + "_" + resi1;
|
|
116510
|
+
|
|
116511
|
+
// let chain1Tmp = (me.parasCls.residueAbbrev.hasOwnProperty(resn1)) ? chain1 : resn1;
|
|
116512
|
+
// let bondId1 = chain1Tmp + "_" + resi1 + "_" + name1;
|
|
116448
116513
|
|
|
116449
116514
|
let chain2 = chain2Array.getString(i);
|
|
116450
116515
|
name2Array.getString(i);
|
|
116451
116516
|
let resi2 = resi2Array.getString(i);
|
|
116517
|
+
// let resn2 = resn2Array.getString(i);
|
|
116452
116518
|
let id2 = structure + '_' + chain2 + "_" + resi2;
|
|
116453
|
-
|
|
116454
|
-
//
|
|
116455
|
-
|
|
116456
|
-
|
|
116457
|
-
//
|
|
116458
|
-
|
|
116459
|
-
|
|
116460
|
-
|
|
116461
|
-
if(conn_type_id == "disulf") {
|
|
116519
|
+
|
|
116520
|
+
// let chain2Tmp = (me.parasCls.residueAbbrev.hasOwnProperty(resn2)) ? chain2 : resn2;
|
|
116521
|
+
// let bondId2 = chain2Tmp + "_" + resi2 + "_" + name2;
|
|
116522
|
+
|
|
116523
|
+
// Verify that the linkage is covalent, as indicated by the conn_type_id attribute2
|
|
116524
|
+
if (conn_type_id == "covale") ;
|
|
116525
|
+
else if(conn_type_id == "disulf") {
|
|
116462
116526
|
if(ic.ssbondpnts[structure] === undefined) ic.ssbondpnts[structure] = [];
|
|
116463
116527
|
|
|
116464
116528
|
ic.ssbondpnts[structure].push(id1);
|
|
@@ -116591,6 +116655,7 @@ class LoadCIF {
|
|
|
116591
116655
|
let nameArray = atom_site.getColumn("label_atom_id");
|
|
116592
116656
|
let entiyidArray = atom_site.getColumn("label_entity_id");
|
|
116593
116657
|
|
|
116658
|
+
// check 3QUM
|
|
116594
116659
|
let chainArray = atom_site.getColumn("auth_asym_id");
|
|
116595
116660
|
|
|
116596
116661
|
let resiArray = atom_site.getColumn("label_seq_id");
|
|
@@ -116612,7 +116677,6 @@ class LoadCIF {
|
|
|
116612
116677
|
let sChain = {};
|
|
116613
116678
|
let prevModelNum = '';
|
|
116614
116679
|
if(!ic.molid2chain) ic.molid2chain = {};
|
|
116615
|
-
|
|
116616
116680
|
for (let i = 0; i < atomSize; ++i) {
|
|
116617
116681
|
let modelNum = modelNumArray.getString(i);
|
|
116618
116682
|
if(i > 0 && modelNum != prevModelNum) {
|
|
@@ -116640,7 +116704,6 @@ class LoadCIF {
|
|
|
116640
116704
|
|
|
116641
116705
|
let autochain = autochainArray.getString(i);
|
|
116642
116706
|
|
|
116643
|
-
|
|
116644
116707
|
resi = oriResi;
|
|
116645
116708
|
|
|
116646
116709
|
let molecueType;
|
|
@@ -116659,7 +116722,7 @@ class LoadCIF {
|
|
|
116659
116722
|
}
|
|
116660
116723
|
else {
|
|
116661
116724
|
molecueType = "ligand"; // ligands or ions
|
|
116662
|
-
chain = resn;
|
|
116725
|
+
if(chain == "?" || chain == ".") chain = resn; // check 3QUM
|
|
116663
116726
|
}
|
|
116664
116727
|
}
|
|
116665
116728
|
if(chain === '') chain = 'A';
|
|
@@ -116749,6 +116812,8 @@ class LoadCIF {
|
|
|
116749
116812
|
let z = zArray.getFloat(i);
|
|
116750
116813
|
let coord = new Vector3$1(x, y, z);
|
|
116751
116814
|
|
|
116815
|
+
let id = serial.toString();
|
|
116816
|
+
|
|
116752
116817
|
let atomDetails = {
|
|
116753
116818
|
het: (atom_hetatm == "HETATM"), // optional, used to determine chemicals, water, ions, etc
|
|
116754
116819
|
serial: serial, // required, unique atom id
|
|
@@ -116905,6 +116970,30 @@ class LoadCIF {
|
|
|
116905
116970
|
ic.residues[residueNum] = residuesTmp;
|
|
116906
116971
|
if(ic.chains[chainNum] === undefined) ic.chains[chainNum] = {};
|
|
116907
116972
|
ic.chains[chainNum] = me.hashUtilsCls.unionHash2Atoms(ic.chains[chainNum], chainsTmp, ic.atoms);
|
|
116973
|
+
/*
|
|
116974
|
+
/// add the defined bonds
|
|
116975
|
+
for(let i = 0; i < vBonds.length; i = i + 2) {
|
|
116976
|
+
let id1 = mName2Serial[vBonds[i]];
|
|
116977
|
+
let id2 = mName2Serial[vBonds[i+1]];
|
|
116978
|
+
|
|
116979
|
+
if(!mId2Set.hasOwnProperty(id1)) mId2Set[id1] = {};
|
|
116980
|
+
if(!mId2Set.hasOwnProperty(id2)) mId2Set[id2] = {};
|
|
116981
|
+
mId2Set[id1][id2] = 1;
|
|
116982
|
+
mId2Set[id2][id1] = 1;
|
|
116983
|
+
}
|
|
116984
|
+
|
|
116985
|
+
for(let id in mId2Set) {
|
|
116986
|
+
let sConnId = mId2Set[id];
|
|
116987
|
+
let vConnId = Object.keys(sConnId);
|
|
116988
|
+
let serial = parseInt(id);
|
|
116989
|
+
|
|
116990
|
+
for(let j = 0, jl = vConnId.length; j < jl; ++j) {
|
|
116991
|
+
if(vConnId[j] === 'undefined' || !ic.atoms[serial]) continue;
|
|
116992
|
+
if(!ic.atoms[serial].bonds) ic.atoms[serial].bonds = [];
|
|
116993
|
+
ic.atoms[serial].bonds.push(parseInt(vConnId[j]));
|
|
116994
|
+
}
|
|
116995
|
+
}
|
|
116996
|
+
*/
|
|
116908
116997
|
|
|
116909
116998
|
// clear memory
|
|
116910
116999
|
atom_hetatmArray = resnArray = elemArray = nameArray = chainArray = resiArray = resiOriArray
|
|
@@ -117076,6 +117165,41 @@ class LoadCIF {
|
|
|
117076
117165
|
}
|
|
117077
117166
|
}
|
|
117078
117167
|
|
|
117168
|
+
// check the bonds between chemicals and all other atoms
|
|
117169
|
+
let processedChemicals = {};
|
|
117170
|
+
for(let i in ic.chemicals) {
|
|
117171
|
+
console.log(" i = ", i, " processedChemicals = ", processedChemicals);
|
|
117172
|
+
if(processedChemicals.hasOwnProperty(i)) continue;
|
|
117173
|
+
|
|
117174
|
+
let atom = ic.atoms[i];
|
|
117175
|
+
let resid = atom.structure + '_' + atom.chain + '_' + atom.resi;
|
|
117176
|
+
|
|
117177
|
+
let radius = 4;
|
|
117178
|
+
let residueAtoms = ic.residues[resid];
|
|
117179
|
+
let otherAtoms = me.hashUtilsCls.exclHash(ic.atoms, residueAtoms);
|
|
117180
|
+
let neighborAtoms = ic.contactCls.getAtomsWithinAtom(otherAtoms, residueAtoms, radius);
|
|
117181
|
+
|
|
117182
|
+
for(let j in residueAtoms) {
|
|
117183
|
+
let startAtom = ic.atoms[j];
|
|
117184
|
+
for(let k in neighborAtoms) {
|
|
117185
|
+
let neighborAtom = ic.atoms[k];
|
|
117186
|
+
let neighborResid = neighborAtom.structure + '_' + neighborAtom.chain + '_' + neighborAtom.resi;
|
|
117187
|
+
if(resid === neighborResid) continue;
|
|
117188
|
+
|
|
117189
|
+
if(me.utilsCls.hasCovalentBond(startAtom, neighborAtom)) {
|
|
117190
|
+
// Handle covalent bond
|
|
117191
|
+
if(!startAtom.bonds) startAtom.bonds = [];
|
|
117192
|
+
if(!neighborAtom.bonds) neighborAtom.bonds = [];
|
|
117193
|
+
|
|
117194
|
+
startAtom.bonds.push(neighborAtom.serial);
|
|
117195
|
+
neighborAtom.bonds.push(startAtom.serial);
|
|
117196
|
+
}
|
|
117197
|
+
}
|
|
117198
|
+
}
|
|
117199
|
+
|
|
117200
|
+
processedChemicals = me.hashUtilsCls.unionHash(processedChemicals, ic.residues[resid]);
|
|
117201
|
+
}
|
|
117202
|
+
|
|
117079
117203
|
ic.pmin = pmin;
|
|
117080
117204
|
ic.pmax = pmax;
|
|
117081
117205
|
|