Skip to content

Commit 85b1f69

Browse files
committed
Allowed to load multiple mmCIF text files, which could contain multiple structures separated by "ENDMDL\n".
1 parent 07ea49a commit 85b1f69

5 files changed

Lines changed: 1073 additions & 0 deletions

File tree

dist/full2_3.32.0.html

Lines changed: 342 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,342 @@
1+
<!DOCTYPE html><html lang="en"><head>
2+
<meta charset="utf-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
4+
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
5+
<meta name="description" content="iCn3D Structure Viewer">
6+
<meta name="keywords" content="NCBI, Structure, JavaScript, iCn3D, 3D, Viewer, WebGL, three.js, sequence, chemical">
7+
<meta name="robots" content="index,follow,noarchive">
8+
<meta name="ncbi_app" content="structure">
9+
<meta name="ncbi_pdid" content="icn3d">
10+
<meta name="ncbi_page" content="full2">
11+
<meta name="ncbi_pinger_xml_http_request_override" content="false"/>
12+
<meta name="ncbi_pinger_click_ping_selector" content="button, a, input[type=submit], span[data-pinger], div[data-pinger], label[data-pinger]"/>
13+
<title>iCn3D: Web-based 3D Structure Viewer</title>
14+
<script type="text/javascript">
15+
window.ncbi_startTime = new Date();
16+
</script>
17+
</head>
18+
<body>
19+
<div id="div0" style="float:left; padding-right:5px;"></div>
20+
<div id="div1" style="float:left;"></div>
21+
22+
<link rel="stylesheet" href="lib/jquery-ui-1.13.2.min.css">
23+
<link rel="stylesheet" href="icn3d_3.32.0.css">
24+
<script src="lib/jquery-3.5.0.min.js"></script>
25+
<script src="lib/jquery-ui-1.13.2.min.js"></script>
26+
<script src="lib/three_0.151.0.min.js"></script>
27+
<script src="icn3d_3.32.0.min.js"></script>
28+
29+
<script type="text/javascript">
30+
$( document ).ready(async function() {
31+
if (navigator.userAgent.indexOf("MSIE ") > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./)) { // If Internet Explorer
32+
// iCn3D version 2.24.7 doesn't work with three_0.128.0.min.js
33+
//$.getScript('icn3d_full_ui_2.24.7.min.js', function() {
34+
// var version = 2;
35+
// launchIcn3d(version);
36+
//});
37+
38+
var fixedUrl = document.URL.replace('full2.html', 'full2_2.24.7.html');
39+
window.open(fixedUrl, '_self');
40+
41+
alert("IE does NOT work with the current iCn3D version 3. The old iCn3D version 2 is used instead.");
42+
}
43+
else {
44+
//$.getScript('icn3d_3.32.0.min.js', function() {
45+
var version = 3;
46+
await launchIcn3d(version);
47+
//});
48+
}
49+
50+
async function launchIcn3d(version) {
51+
// use the FIXED name "icn3duiHash" for side-by-side view
52+
window.icn3duiHash = {};
53+
54+
var cfg = getConfig();
55+
cfg.version = version;
56+
57+
if(cfg.bcifid !== undefined) {
58+
await setupViewer('bcifid', cfg.bcifid, cfg);
59+
}
60+
else if(cfg.mmtfid !== undefined) {
61+
await setupViewer('mmtfid', cfg.mmtfid, cfg);
62+
}
63+
else if(cfg.pdbid !== undefined) {
64+
await setupViewer('pdbid', cfg.pdbid, cfg);
65+
}
66+
else if(cfg.afid !== undefined) {
67+
await setupViewer('afid', cfg.afid, cfg);
68+
}
69+
else if(cfg.opmid !== undefined) {
70+
await setupViewer('opmid', cfg.opmid, cfg);
71+
}
72+
else if(cfg.cid !== undefined) {
73+
await setupViewer('cid', cfg.cid, cfg);
74+
}
75+
else if(cfg.mmcifid !== undefined) {
76+
await setupViewer('mmcifid', cfg.mmcifid, cfg);
77+
}
78+
else if(cfg.mmdbid !== undefined) {
79+
await setupViewer('mmdbid', cfg.mmdbid, cfg);
80+
}
81+
else if(cfg.gi !== undefined) {
82+
await setupViewer('gi', cfg.gi, cfg);
83+
}
84+
else if(cfg.blast_rep_id !== undefined) {
85+
if( (from === 'blast' || from === 'icn3d') && command == '') {
86+
command = 'view+annotations;+set+annotation+cdd;+set+annotation+site;+set+view+detailed+view;+select+chain+'
87+
+ cfg.blast_rep_id + ';+show+selection';
88+
}
89+
90+
await setupViewer('blast_rep_id', cfg.blast_rep_id, cfg);
91+
}
92+
else if(cfg.urlname !== undefined) {
93+
var urlname = decodeURIComponent(cfg.urlname);
94+
await setupViewer('url', cfg.urltype + '|' + urlname, cfg);
95+
}
96+
// e.g., align=103701,1,4,68563,1,167 [mmdbid1,biounit,molecule,mmdbid2,biounit,molecule]
97+
else if(cfg.align !== undefined) {
98+
cfg.width = '49%'; //width,
99+
cfg.mobilemenu = true; //mobilemenu,
100+
cfg.closepopup = true; //closepopup,
101+
cfg.controlGl = true;
102+
cfg.bSidebyside = true;
103+
104+
cfg.divid = 'div0';
105+
cfg.align = cfg.align;
106+
cfg.showalignseq = cfg.showalignseq;
107+
108+
// VAST+ uses biological units
109+
cfg.bu = 1;
110+
111+
cfg.idname = 'align';
112+
cfg.idvalue = cfg.align;
113+
114+
var icn3dui = new icn3d.iCn3DUI(cfg);
115+
window.icn3duiHash['div0'] = icn3dui;
116+
await icn3dui.show3DStructure();
117+
118+
var cfg2 = cfg;
119+
cfg2.divid = 'div1';
120+
var icn3dui2 = new icn3d.iCn3DUI(cfg2);
121+
window.icn3duiHash['div1'] = icn3dui2;
122+
await icn3dui2.show3DStructure();
123+
}
124+
else if(cfg.chainalign !== undefined || cfg.mmdbafid !== undefined) {
125+
cfg.width = '49%'; //width,
126+
cfg.mobilemenu = true; //mobilemenu,
127+
cfg.closepopup = true; //closepopup,
128+
cfg.controlGl = true;
129+
cfg.bSidebyside = true;
130+
131+
cfg.divid = 'div0';
132+
//cfg.chainalign = cfg.chainalign;
133+
//cfg.resnum = cfg.resnum;
134+
//cfg.showalignseq = cfg.showalignseq;
135+
136+
if(cfg.chainalign !== undefined) {
137+
cfg.idname = 'chainalign';
138+
cfg.idvalue = cfg.chainalign;
139+
}
140+
else {
141+
cfg.idname = 'mmdbafid';
142+
cfg.idvalue = cfg.mmdbafid;
143+
}
144+
145+
var icn3dui = new icn3d.iCn3DUI(cfg);
146+
window.icn3duiHash['div0'] = icn3dui;
147+
await icn3dui.show3DStructure();
148+
149+
var cfg2 = cfg;
150+
cfg2.divid = 'div1';
151+
var icn3dui2 = new icn3d.iCn3DUI(cfg2);
152+
window.icn3duiHash['div1'] = icn3dui2;
153+
await icn3dui2.show3DStructure();
154+
}
155+
else {
156+
await setupViewer('', '', cfg);
157+
}
158+
}
159+
160+
async function setupViewer(idName, idValue, cfg) {
161+
cfg.idname = idName;
162+
cfg.idvalue = idValue;
163+
164+
var maxStructure = 5; // show max 5 structures
165+
166+
var idArray = idValue.replace(/\s/g, '').split(',');
167+
168+
//if(idArray.length > 1) {
169+
cfg.resize = false;
170+
171+
if(cfg.width && cfg.width.indexOf('%') != -1) {
172+
cfg.width = 400;
173+
cfg.height = 400;
174+
}
175+
//}
176+
177+
//for(var i = 0, il = idArray.length; i < il && i < maxStructure; ++i) {
178+
var i = 0;
179+
cfg.divid = 'div' + i;
180+
cfg.width = '49%'; //width,
181+
cfg.mobilemenu = true; //mobilemenu,
182+
cfg.closepopup = true; //closepopup,
183+
cfg.controlGl = true;
184+
cfg.bSidebyside = true;
185+
186+
if(idName !== '') cfg[idName] = idArray[i];
187+
188+
var icn3dui = new icn3d.iCn3DUI(cfg);
189+
window.icn3duiHash['div0'] = icn3dui;
190+
await icn3dui.show3DStructure();
191+
if(idName === '') $("#div" + i + "_wait").hide();
192+
193+
i = 1;
194+
var cfg2 = cfg;
195+
cfg2.divid = 'div' + i;
196+
var icn3dui2 = new icn3d.iCn3DUI(cfg2);
197+
window.icn3duiHash['div1'] = icn3dui2;
198+
await icn3dui2.show3DStructure();
199+
if(idName === '') $("#div" + i + "_wait").hide();
200+
//}
201+
}
202+
203+
function getConfig() {
204+
// separating the GET parameters from the current URL
205+
// repalce "color #" with "color " in the url
206+
var url = document.URL.replace(/\#/g, '');
207+
208+
var bNopara = false;
209+
var ampPos = url.indexOf("?");
210+
if(ampPos === -1) {
211+
// alert("Please include '?pdbid=1GPK,2POR,...' in your url");
212+
bNopara = true;
213+
}
214+
215+
var params = url.split("?");
216+
// transforming the GET parameters into a dictionary
217+
var search = params[params.length - 1];
218+
219+
var cfg = {};
220+
221+
if(!bNopara) {
222+
var decodeSearch = decodeURIComponent(search).replace(/\+/g, ' ');
223+
224+
// command could contains '&', for example when loading statefile 'load mmdb 1kq2 | parameters &atype=1'
225+
var commandPos = decodeSearch.indexOf('&command=');
226+
if(commandPos != -1) {
227+
cfg.command = decodeSearch.substr(commandPos + 9); // ";" separated commands
228+
decodeSearch = decodeSearch.substr(0, commandPos);
229+
230+
var paraPos = decodeSearch.indexOf(' | parameters ');
231+
232+
if(paraPos != -1) { //When loading statefile (e.g., 'load mmdb 1kq2 | parameters &atype=1'), the commands ends with '}}'.
233+
var tmpPos = cfg.command.indexOf('}}&');
234+
if(tmpPos != -1) { // more parameters after the command
235+
decodeSearch += cfg.command.substr(tmpPos + 2);
236+
cfg.command = cfg.command.substr(0, tmpPos + 2);
237+
}
238+
}
239+
else {
240+
var paraPos = cfg.command.indexOf(' | parameters ');
241+
242+
if(paraPos != -1) { //"&command=load mmdb 7DDD | parameters &mmdbid=7DDD; select..." the commands ends with '}}'.
243+
var tmpPos = cfg.command.indexOf('}}&');
244+
if(tmpPos != -1) { // more parameters after the command
245+
decodeSearch += cfg.command.substr(tmpPos + 2);
246+
cfg.command = cfg.command.substr(0, tmpPos + 2);
247+
}
248+
}
249+
else {
250+
var tmpPos = cfg.command.indexOf('&');
251+
if(tmpPos != -1) {
252+
decodeSearch += cfg.command.substr(tmpPos);
253+
cfg.command = cfg.command.substr(0, tmpPos);
254+
}
255+
}
256+
}
257+
}
258+
else {
259+
cfg.command = '';
260+
}
261+
262+
var hashes = decodeSearch.split('&');
263+
for (var i = 0; i < hashes.length; i++) {
264+
var hash = hashes[i].split('=');
265+
cfg[hash[0].trim()] = (hash[1] !== undefined) ? hash[1].trim() : undefined;
266+
}
267+
268+
// for mmdb structures, pass the parameters after the first "&" sign
269+
cfg.inpara = "&" + url.substr(ampPos + 1);
270+
}
271+
272+
// changed some parameter names
273+
cfg.rid = cfg.RID;
274+
275+
cfg.urlname = cfg.url;
276+
if(cfg.urlname && cfg.urlname.indexOf('%3A%2F%2F') === -1) { // decoded URL
277+
// should encode it
278+
cfg.urlname = encodeURIComponent(cfg.urlname);
279+
}
280+
cfg.urltype = (cfg.type === undefined) ? 'pdb' : cfg.type;
281+
282+
cfg.version = getValue(cfg.v);
283+
284+
if(cfg.version !== undefined && window.localStorage && localStorage.getItem('fixedversion')) {
285+
var fixedUrl = url.replace('full.html', 'full_' + cfg.version + '.html');
286+
window.open(fixedUrl, '_self');
287+
288+
localStorage.removeItem('fixedversion');
289+
}
290+
291+
// standardize the input values
292+
for(var i in cfg) {
293+
if(i == 'bu') {
294+
cfg[i] = getInt(cfg[i]);
295+
}
296+
else {
297+
cfg[i] = getValue(cfg[i]);
298+
}
299+
}
300+
301+
// backward compatible with showseq
302+
cfg.showanno = cfg.showanno || cfg.showseq;
303+
304+
cfg.shownote = 1; //cfg.shownote;
305+
cfg.options = (cfg.options !== undefined) ? JSON.parse(cfg.options) : undefined;
306+
307+
// default to show biological unit
308+
if(cfg.bu === undefined) cfg.bu = 1; //0;
309+
if(cfg.buidx !== undefined) cfg.bu = cfg.buidx;
310+
311+
return cfg;
312+
}
313+
314+
function getValue(input) {
315+
if(input == 'true') { // || input == '1') {
316+
input = true;
317+
}
318+
else if(input == 'false') { // || input == '0') {
319+
input = false;
320+
}
321+
322+
return input;
323+
}
324+
325+
function getInt(input) {
326+
if(input == 'true' || input == '1') {
327+
input = 1;
328+
}
329+
else if(input == 'false' || input == '0') {
330+
input = 0;
331+
}
332+
333+
return input;
334+
}
335+
}); // document ready
336+
337+
</script>
338+
339+
<!-- log & Google Analytics -->
340+
<script type="text/javascript" src="https://www.ncbi.nlm.nih.gov/core/pinger/pinger.js"></script>
341+
</body></html>
342+

0 commit comments

Comments
 (0)