icn3d 3.16.0 → 3.16.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/README.md +75 -4
- package/icn3d.js +76 -56
- package/icn3d.min.js +2 -2
- package/icn3d.module.js +76 -56
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,77 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
icn3d
|
|
2
|
+
=====
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
"I see in 3D" (iCn3D) Structure Viewer is not only a web-based 3D viewer, but also a structure analysis tool interactively or in the batch mode using NodeJS scripts based on the npm package icn3d. iCn3D synchronizes the display of 3D structure, 2D interaction, and 1D sequences and annotations. Users' custom display can be saved in a short URL or a PNG image. More features are listed at [iCn3D Doc](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#about).
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
iCn3D can be installed with the following command:
|
|
10
|
+
|
|
11
|
+
npm install icn3d
|
|
12
|
+
|
|
13
|
+
The following packages are required as shown in dependency:
|
|
14
|
+
|
|
15
|
+
npm install jquery
|
|
16
|
+
npm install jsdom
|
|
17
|
+
npm install three
|
|
18
|
+
|
|
19
|
+
Usage
|
|
20
|
+
--------
|
|
21
|
+
|
|
22
|
+
* <b>Use icn3d to generate Node.js scripts</b>
|
|
23
|
+
|
|
24
|
+
To use icn3d to generate Node.js scripts, the source code is from this icn3d npm package. As shown in [one example of Node.js script](https://github.com/ncbi/icn3d/blob/master/icn3dnode/interaction2.js), part of the script can be like the following. All classes and functions can be accessed with the variable "icn3dui". The class structure is listed at [iCn3D Doc](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#classstructure).
|
|
25
|
+
|
|
26
|
+
global.THREE = require('three');
|
|
27
|
+
let jsdom = require('jsdom');
|
|
28
|
+
global.$ = require('jquery')(new jsdom.JSDOM().window);
|
|
29
|
+
|
|
30
|
+
let icn3d = require('icn3d');
|
|
31
|
+
let icn3dui = new icn3d.iCn3DUI({});
|
|
32
|
+
|
|
33
|
+
* <b>Use icn3d as a 3D Viewer with React</b>
|
|
34
|
+
|
|
35
|
+
You can first specify the "dependencies.js" file as follows:
|
|
36
|
+
|
|
37
|
+
import * as THREE from 'icn3d/three'
|
|
38
|
+
import $ from 'jquery'
|
|
39
|
+
import 'jquery-ui-bundle';
|
|
40
|
+
|
|
41
|
+
import 'jquery-ui-bundle/jquery-ui.min.css';
|
|
42
|
+
|
|
43
|
+
global.THREE = THREE
|
|
44
|
+
global.$ = $
|
|
45
|
+
global.jQuery = $
|
|
46
|
+
|
|
47
|
+
Then specify the "icn3d-viewer.js" file as follows:
|
|
48
|
+
|
|
49
|
+
import React, { useEffect } from "react";
|
|
50
|
+
import './dependencies';
|
|
51
|
+
|
|
52
|
+
import * as icn3d from 'icn3d/module'
|
|
53
|
+
import "../node_modules/icn3d/css/icn3d.css"
|
|
54
|
+
|
|
55
|
+
function Icn3dViewer() {
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const cfg = {
|
|
58
|
+
divid: 'viewer',
|
|
59
|
+
mobilemenu: true
|
|
60
|
+
};
|
|
61
|
+
cfg['mmdbid'] = '1tup';
|
|
62
|
+
const icn3dui = new icn3d.iCn3DUI(cfg);
|
|
63
|
+
icn3dui.show3DStructure();
|
|
64
|
+
}, []);
|
|
65
|
+
return <div id="viewer"></div>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export default Icn3dViewer;
|
|
69
|
+
|
|
70
|
+
* <b>Use icn3d as a 3D Viewer with jQuery</b>
|
|
71
|
+
|
|
72
|
+
The source code is available in the [iCn3D GitHub page](https://github.com/ncbi/icn3d). You can following the instruction at [iCn3D Doc](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#HowToUse). The JavaScript code could be as simple as the following:
|
|
73
|
+
|
|
74
|
+
var cfg = {'mmdbid': '1tup'};
|
|
75
|
+
var icn3dui = new icn3d.iCn3DUI(cfg);
|
|
76
|
+
icn3dui.show3DStructure();
|
|
5
77
|
|
|
6
|
-
You can write Python scripts either based on iCn3D URLs as shown in the directory "icn3d_url", or by following the interactive steps in the directory "web_scraping", which enables you to extract any output from the UI.
|
package/icn3d.js
CHANGED
|
@@ -24585,7 +24585,8 @@ class RealignParser {
|
|
|
24585
24585
|
chainidArray.push(struct2chain[fromStruct]);
|
|
24586
24586
|
}
|
|
24587
24587
|
|
|
24588
|
-
|
|
24588
|
+
// align seq
|
|
24589
|
+
//ic.hAtoms = ic.chainalignParserCls.setMsa(chainidArray, undefined, true);
|
|
24589
24590
|
ic.hAtoms = ic.chainalignParserCls.setMsa(chainidArray);
|
|
24590
24591
|
|
|
24591
24592
|
name = 'protein_aligned';
|
|
@@ -24647,6 +24648,7 @@ class RealignParser {
|
|
|
24647
24648
|
}
|
|
24648
24649
|
|
|
24649
24650
|
// align seq
|
|
24651
|
+
//ic.hAtoms = ic.chainalignParserCls.setMsa(chainidArray, undefined, true);
|
|
24650
24652
|
ic.hAtoms = ic.chainalignParserCls.setMsa(chainidArray);
|
|
24651
24653
|
|
|
24652
24654
|
ic.transformCls.zoominSelection();
|
|
@@ -27892,7 +27894,7 @@ class LoadScript {
|
|
|
27892
27894
|
|
|
27893
27895
|
me.cfg.aligntool = 'tmalign';
|
|
27894
27896
|
|
|
27895
|
-
$.when(thisClass.applyCommandRealignByStruct(
|
|
27897
|
+
$.when(thisClass.applyCommandRealignByStruct(ic.commands[i])).then(function() {
|
|
27896
27898
|
thisClass.execCommandsBase(i + 1, end, steps);
|
|
27897
27899
|
});
|
|
27898
27900
|
|
|
@@ -35826,17 +35828,14 @@ class SetSeqAlign {
|
|
|
35826
35828
|
|
|
35827
35829
|
for(let i = 0, il = ic.qt_start_end[chainIndex].length; i < il; ++i) {
|
|
35828
35830
|
let start1, end1;
|
|
35829
|
-
if(bRealign) { // real residue numbers are stored
|
|
35830
|
-
|
|
35831
|
-
|
|
35832
|
-
|
|
35833
|
-
|
|
35834
|
-
// end1 = this.getPosFromResi(chainid1, ic.qt_start_end[chainIndex][i].t_end);
|
|
35835
|
-
}
|
|
35836
|
-
else {
|
|
35831
|
+
// if(bRealign) { // real residue numbers are stored
|
|
35832
|
+
// start1 = ic.qt_start_end[chainIndex][i].t_start;
|
|
35833
|
+
// end1 = ic.qt_start_end[chainIndex][i].t_end;
|
|
35834
|
+
// }
|
|
35835
|
+
// else {
|
|
35837
35836
|
start1 = ic.qt_start_end[chainIndex][i].t_start - 1;
|
|
35838
35837
|
end1 = ic.qt_start_end[chainIndex][i].t_end - 1;
|
|
35839
|
-
}
|
|
35838
|
+
//}
|
|
35840
35839
|
for(let j = start1; j <= end1; ++j) {
|
|
35841
35840
|
let resiPos = j - baseResi;
|
|
35842
35841
|
let resi = this.getResi(chainidArray[0], resiPos, bRealign);
|
|
@@ -53944,7 +53943,7 @@ class ClickMenu {
|
|
|
53944
53943
|
// }
|
|
53945
53944
|
for(let menu in me.htmlCls.allMenus) {
|
|
53946
53945
|
if(idArray.indexOf(menu) == -1) {
|
|
53947
|
-
me.htmlCls.shownMenus[
|
|
53946
|
+
me.htmlCls.shownMenus[menu] = 1;
|
|
53948
53947
|
}
|
|
53949
53948
|
}
|
|
53950
53949
|
}
|
|
@@ -59984,7 +59983,7 @@ class Events {
|
|
|
59984
59983
|
|
|
59985
59984
|
setPredefinedMenu(id) { let me = this.icn3dui, ic = me.icn3d;
|
|
59986
59985
|
if(Object.keys(ic.structures).length < 2) {
|
|
59987
|
-
var aaa = 1; //alert("At least two
|
|
59986
|
+
var aaa = 1; //alert("At least two structures are required for alignment...");
|
|
59988
59987
|
return;
|
|
59989
59988
|
}
|
|
59990
59989
|
if(ic.bSetChainsAdvancedMenu === undefined || !ic.bSetChainsAdvancedMenu) {
|
|
@@ -60147,7 +60146,7 @@ class Events {
|
|
|
60147
60146
|
// clickRealign: function() {
|
|
60148
60147
|
me.myEventCls.onIds("#" + me.pre + "mn2_realignresbyres", "click", function(e) { let ic = me.icn3d;
|
|
60149
60148
|
if(Object.keys(ic.structures).length < 2) {
|
|
60150
|
-
var aaa = 1; //alert("At least two
|
|
60149
|
+
var aaa = 1; //alert("At least two structures are required for alignment...");
|
|
60151
60150
|
return;
|
|
60152
60151
|
}
|
|
60153
60152
|
|
|
@@ -65491,13 +65490,26 @@ class Vastplus {
|
|
|
65491
65490
|
|
|
65492
65491
|
let struct1 = structArray[0], struct2 = structArray[1];
|
|
65493
65492
|
|
|
65494
|
-
//
|
|
65493
|
+
// get non-chemical chains
|
|
65494
|
+
let chainidArray1 = [], chainidArray2 = [];
|
|
65495
65495
|
for(let i = 0, il = ic.structures[struct1].length; i < il; ++i) {
|
|
65496
65496
|
let chainid1 = ic.structures[struct1][i];
|
|
65497
65497
|
if(ic.firstAtomObjCls.getFirstAtomObj(ic.chains[chainid1]).het) continue;
|
|
65498
|
+
chainidArray1.push(chainid1);
|
|
65499
|
+
}
|
|
65500
|
+
for(let i = 0, il = ic.structures[struct2].length; i < il; ++i) {
|
|
65501
|
+
let chainid2 = ic.structures[struct2][i];
|
|
65502
|
+
if(ic.firstAtomObjCls.getFirstAtomObj(ic.chains[chainid2]).het) continue;
|
|
65503
|
+
chainidArray2.push(chainid2);
|
|
65504
|
+
}
|
|
65505
|
+
|
|
65506
|
+
// align A to A, B to B first
|
|
65507
|
+
for(let i = 0, il = chainidArray1.length; i < il; ++i) {
|
|
65508
|
+
let chainid1 = chainidArray1[i];
|
|
65509
|
+
if(ic.firstAtomObjCls.getFirstAtomObj(ic.chains[chainid1]).het) continue;
|
|
65498
65510
|
|
|
65499
|
-
for(let j = 0, jl =
|
|
65500
|
-
let chainid2 =
|
|
65511
|
+
for(let j = 0, jl = chainidArray2.length; j < jl; ++j) {
|
|
65512
|
+
let chainid2 = chainidArray2[j];
|
|
65501
65513
|
if(ic.firstAtomObjCls.getFirstAtomObj(ic.chains[chainid2]).het) continue;
|
|
65502
65514
|
|
|
65503
65515
|
if(i == j) {
|
|
@@ -65509,12 +65521,12 @@ class Vastplus {
|
|
|
65509
65521
|
}
|
|
65510
65522
|
}
|
|
65511
65523
|
|
|
65512
|
-
for(let i = 0, il =
|
|
65513
|
-
let chainid1 =
|
|
65524
|
+
for(let i = 0, il = chainidArray1.length; i < il; ++i) {
|
|
65525
|
+
let chainid1 = chainidArray1[i];
|
|
65514
65526
|
if(ic.firstAtomObjCls.getFirstAtomObj(ic.chains[chainid1]).het) continue;
|
|
65515
65527
|
|
|
65516
|
-
for(let j = 0, jl =
|
|
65517
|
-
let chainid2 =
|
|
65528
|
+
for(let j = 0, jl = chainidArray2.length; j < jl; ++j) {
|
|
65529
|
+
let chainid2 = chainidArray2[j];
|
|
65518
65530
|
if(ic.firstAtomObjCls.getFirstAtomObj(ic.chains[chainid2]).het) continue;
|
|
65519
65531
|
|
|
65520
65532
|
if(i != j) {
|
|
@@ -65707,19 +65719,19 @@ class Vastplus {
|
|
|
65707
65719
|
let resiArray_t = resiArrays.resiArray_t;
|
|
65708
65720
|
let resiArray_q = resiArrays.resiArray_q;
|
|
65709
65721
|
|
|
65710
|
-
let base = 0;
|
|
65722
|
+
let base = parseInt(ic.chainsSeq[chainid_t][0].resi);
|
|
65711
65723
|
let result_t = ic.realignParserCls.getSeqCoorResid(resiArray_t, chainid_t, base);
|
|
65712
65724
|
coor_t = coor_t.concat(result_t.coor);
|
|
65713
65725
|
|
|
65714
|
-
base = parseInt(ic.chainsSeq[
|
|
65726
|
+
base = parseInt(ic.chainsSeq[chainid_q][0].resi);
|
|
65715
65727
|
let result_q = ic.realignParserCls.getSeqCoorResid(resiArray_q, chainid_q, base);
|
|
65716
65728
|
coor_q = coor_q.concat(result_q.coor);
|
|
65717
65729
|
|
|
65718
65730
|
// align seq
|
|
65719
65731
|
ic.qt_start_end = [];
|
|
65720
65732
|
ic.qt_start_end.push(segs);
|
|
65721
|
-
let bVastplus = true;
|
|
65722
|
-
let hAtomsTmp = ic.chainalignParserCls.setMsa(chainidArray, bVastplus);
|
|
65733
|
+
let bVastplus = true, bRealign = true;
|
|
65734
|
+
let hAtomsTmp = ic.chainalignParserCls.setMsa(chainidArray, bVastplus, bRealign);
|
|
65723
65735
|
hAtomsAll = me.hashUtilsCls.unionHash(hAtomsAll, hAtomsTmp);
|
|
65724
65736
|
}
|
|
65725
65737
|
|
|
@@ -66012,6 +66024,11 @@ class Vastplus {
|
|
|
66012
66024
|
childDist[count] = 0.0;
|
|
66013
66025
|
}
|
|
66014
66026
|
|
|
66027
|
+
let structArray = Object.keys(ic.structures);
|
|
66028
|
+
let nChain1 = ic.structures[structArray[0]].length;
|
|
66029
|
+
let nChain2 = ic.structures[structArray[1]].length;
|
|
66030
|
+
let nChain = (nChain1 < nChain2) ? nChain1 : nChain2;
|
|
66031
|
+
|
|
66015
66032
|
for(count = n; count < 2*n-1; ++count) {
|
|
66016
66033
|
// find the min dist
|
|
66017
66034
|
distTmp = maxDist;
|
|
@@ -66053,41 +66070,44 @@ class Vastplus {
|
|
|
66053
66070
|
else vvDist[j][selJ] = maxDist;
|
|
66054
66071
|
}
|
|
66055
66072
|
|
|
66056
|
-
|
|
66057
|
-
|
|
66058
|
-
|
|
66059
|
-
|
|
66060
|
-
|
|
66061
|
-
cumul[selJ].leaves
|
|
66062
|
-
|
|
66063
|
-
|
|
66064
|
-
|
|
66065
|
-
|
|
66066
|
-
|
|
66067
|
-
|
|
66068
|
-
|
|
66069
|
-
|
|
66070
|
-
|
|
66071
|
-
// if(this.compareFloat(cumul, nodeI, nodeJ) == 0) {
|
|
66072
|
-
// cumul[count].leaves.push(cumul[selI].leaves[i].concat(cumul[selJ].leaves[j]));
|
|
66073
|
-
// cumul[count].leaves.push(cumul[selJ].leaves[j].concat(cumul[selI].leaves[i]));
|
|
66074
|
-
// }
|
|
66075
|
-
// else if(this.compareFloat(cumul, nodeI, nodeJ) == -1) {
|
|
66076
|
-
// cumul[count].leaves.push(cumul[selI].leaves[i].concat(cumul[selJ].leaves[j]));
|
|
66077
|
-
// }
|
|
66078
|
-
// else if(this.compareFloat(cumul, nodeI, nodeJ) == 1) {
|
|
66079
|
-
// cumul[count].leaves.push(cumul[selJ].leaves[j].concat(cumul[selI].leaves[i]));
|
|
66073
|
+
let factor = 4; // 2-4 fold more chains/alignments
|
|
66074
|
+
if(cumul[selI].leaves.length < factor * nChain || cumul[selJ].leaves.length < factor * nChain) {
|
|
66075
|
+
cumul[count].leaves = [];
|
|
66076
|
+
|
|
66077
|
+
for(let i = 0, il = cumul[selI].leaves.length; i < il; ++i) {
|
|
66078
|
+
for(let j = 0, jl = cumul[selJ].leaves.length; j < jl; ++j) {
|
|
66079
|
+
// let nodeI = cumul[selI].leaves[i][0];
|
|
66080
|
+
// let nodeJ = cumul[selJ].leaves[j][0];
|
|
66081
|
+
|
|
66082
|
+
// skip non-similar alignments
|
|
66083
|
+
// if(cumul[selI].dist > threshold) {
|
|
66084
|
+
// cumul[count].leaves.push(cumul[selJ].leaves[j]);
|
|
66085
|
+
// } else if(cumul[selJ].dist > threshold) {
|
|
66086
|
+
// cumul[count].leaves = [];
|
|
66080
66087
|
// }
|
|
66088
|
+
// else {
|
|
66089
|
+
|
|
66090
|
+
// if(this.compareFloat(cumul, nodeI, nodeJ) == 0) {
|
|
66091
|
+
// cumul[count].leaves.push(cumul[selI].leaves[i].concat(cumul[selJ].leaves[j]));
|
|
66092
|
+
// cumul[count].leaves.push(cumul[selJ].leaves[j].concat(cumul[selI].leaves[i]));
|
|
66093
|
+
// }
|
|
66094
|
+
// else if(this.compareFloat(cumul, nodeI, nodeJ) == -1) {
|
|
66095
|
+
// cumul[count].leaves.push(cumul[selI].leaves[i].concat(cumul[selJ].leaves[j]));
|
|
66096
|
+
// }
|
|
66097
|
+
// else if(this.compareFloat(cumul, nodeI, nodeJ) == 1) {
|
|
66098
|
+
// cumul[count].leaves.push(cumul[selJ].leaves[j].concat(cumul[selI].leaves[i]));
|
|
66099
|
+
// }
|
|
66100
|
+
|
|
66101
|
+
cumul[count].leaves.push(cumul[selI].leaves[i].concat(cumul[selJ].leaves[j]));
|
|
66102
|
+
cumul[count].leaves.push(cumul[selJ].leaves[j].concat(cumul[selI].leaves[i]));
|
|
66081
66103
|
|
|
66082
|
-
|
|
66083
|
-
|
|
66084
|
-
|
|
66085
|
-
// }
|
|
66104
|
+
// }
|
|
66105
|
+
}
|
|
66086
66106
|
}
|
|
66087
|
-
}
|
|
66088
66107
|
|
|
66089
|
-
|
|
66090
|
-
|
|
66108
|
+
cumul[selI].leaves = [];
|
|
66109
|
+
cumul[selJ].leaves = [];
|
|
66110
|
+
}
|
|
66091
66111
|
|
|
66092
66112
|
// update mNearestNB and mNearestNBDist
|
|
66093
66113
|
delete mNearestNB[selI];
|