icn3d 3.29.0 → 3.29.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
@@ -6858,6 +6858,10 @@ class ClickMenu {
6858
6858
  me.myEventCls.onIds("#" + me.pre + "mn1_selection", "click", function(e) { me.icn3d; //e.preventDefault();
6859
6859
  me.htmlCls.dialogCls.openDlg('dl_selection', 'Please input the selection file');
6860
6860
  });
6861
+
6862
+ me.myEventCls.onIds("#" + me.pre + "mn1_collection", "click", function (e) { me.icn3d; //e.preventDefault();
6863
+ me.htmlCls.dialogCls.openDlg('dl_collection', 'Please input the collection file');
6864
+ });
6861
6865
 
6862
6866
  me.myEventCls.onIds("#" + me.pre + "mn1_dsn6", "click", function(e) { me.icn3d; //e.preventDefault();
6863
6867
  me.htmlCls.dialogCls.openDlg('dl_dsn6', 'Please input the map file to display electron density map');
@@ -9447,6 +9451,7 @@ class SetMenu {
9447
9451
  html += this.getLink('mn1_state', 'State/Script File', undefined, 2);
9448
9452
  html += this.getLink('mn1_fixedversion', 'Share Link in Archived Ver. ' + me.htmlCls.wifiStr, undefined, 2);
9449
9453
  html += this.getLink('mn1_selection', 'Selection File', undefined, 2);
9454
+ html += this.getLink("mn1_collection", "Collection File", undefined, 2);
9450
9455
 
9451
9456
  html += this.getMenuSep();
9452
9457
 
@@ -11872,6 +11877,19 @@ class SetDialog {
11872
11877
  html += me.htmlCls.buttonStr + "reload_selectionfile' style='margin-top: 6px;'>Load</button>";
11873
11878
  html += "</div>";
11874
11879
 
11880
+ html += me.htmlCls.divStr + "dl_collection' class='" + dialogClass + "'>";
11881
+ html += "Collection file: " + me.htmlCls.inputFileStr + "id='" + me.pre + "collectionfile'><br/>";
11882
+ html += me.htmlCls.buttonStr + "reload_collectionfile' style='margin-top: 6px;'>Load</button>";
11883
+ html += "</div>";
11884
+
11885
+ html += me.htmlCls.divStr + "dl_selectCollections' class='" + dialogClass + "'>";
11886
+ html += me.htmlCls.divStr + "dl_collectionsMenu'>";
11887
+ html += "<b>Structures:</b> <br/>";
11888
+ html += "<select id='" + me.pre + "collections_menu' multiple size='6' style='min-width:130px;'>";
11889
+ html += "</select>";
11890
+ html += "</div>";
11891
+ html += "</div>";
11892
+
11875
11893
  html += me.htmlCls.divStr + "dl_menuloadpref' class='" + dialogClass + "'>";
11876
11894
  html += this.addNotebookTitle('dl_menuloadpref', 'Load a preference file');
11877
11895
  html += "Preference file: " + me.htmlCls.inputFileStr + "id='" + me.pre + "menupreffile'><br/>";
@@ -14076,6 +14094,45 @@ class Events {
14076
14094
  }
14077
14095
  });
14078
14096
 
14097
+ me.myEventCls.onIds("#" + me.pre + "reload_collectionfile", "click", function (e) { let ic = me.icn3d;
14098
+ e.preventDefault();
14099
+ let file = $("#" + me.pre + "collectionfile")[0].files[0];
14100
+ if (!file) {
14101
+ alert("Please select a file before clicking 'Load'");
14102
+ } else {
14103
+ if (!me.cfg.notebook) dialog.dialog("close");
14104
+ if (!me.cfg.notebook) {
14105
+ $(".ui-dialog-content").dialog("close");
14106
+ } else {
14107
+ ic.resizeCanvasCls.closeDialogs();
14108
+ }
14109
+ me.htmlCls.setHtmlCls.fileSupport();
14110
+ let reader = new FileReader();
14111
+ reader.onload = async function (e) {
14112
+ let dataStr = JSON.parse(e.target.result);
14113
+ let collection = [dataStr["structures"].map(({ id }) => id), dataStr["structures"].map(({ title }) => title)];
14114
+ let collectionHtml = ic.selectCollectionsCls.setAtomMenu(collection[0], collection[1]);
14115
+ await ic.chainalignParserCls.downloadMmdbAf(collection[0][0]);
14116
+
14117
+ ic.opts["color"] = "structure";
14118
+ ic.setColorCls.setColorByOptions(ic.opts, ic.dAtoms);
14119
+
14120
+ $("#" + ic.pre + "collections_menu").html(collectionHtml);
14121
+ ic.selectCollectionsCls.clickStructure();
14122
+
14123
+ $("#" + ic.pre + "collections_menu").trigger("change");
14124
+
14125
+ me.htmlCls.clickMenuCls.setLogCmd(
14126
+ "load collection file " +
14127
+ $("#" + me.pre + "collectionfile").val(),
14128
+ false
14129
+ );
14130
+ };
14131
+ reader.readAsText(file);
14132
+ me.htmlCls.dialogCls.openDlg("dl_selectCollections", "Select Collections");
14133
+ }
14134
+ });
14135
+
14079
14136
  me.myEventCls.onIds("#" + me.pre + "reload_dsn6file2fofc", "click", function(e) { let ic = me.icn3d;
14080
14137
  e.preventDefault();
14081
14138
  //if(!me.cfg.notebook) dialog.dialog( "close" );
@@ -52644,7 +52701,6 @@ class MtzParser {
52644
52701
  else {
52645
52702
  sigma = await this.mtzParserBase(url, type, sigma, 'url');
52646
52703
 
52647
- console.log("### sigma " + sigma);
52648
52704
  //me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' file mtz | ' + encodeURIComponent(url), true);
52649
52705
  }
52650
52706
  }
@@ -57339,7 +57395,7 @@ class LoadAtomData {
57339
57395
  if(!bTitle) ic.molTitle = '';
57340
57396
  }
57341
57397
  else { // mmdbid or mmcifid
57342
- if(data.descr !== undefined) ic.molTitle += data.descr.name;
57398
+ if(data.descr !== undefined) ic.molTitle = data.descr.name;
57343
57399
  if(type === 'mmdbid') {
57344
57400
  let pdbidTmp = (isNaN(id)) ? id : data.pdbId;
57345
57401
  let chainHash = {};
@@ -62970,7 +63026,7 @@ class DefinedSets {
62970
63026
  }
62971
63027
 
62972
63028
  //Set the menu of defined sets with an array of defined names "commandnameArray".
62973
- setAtomMenu(commandnameArray) { let ic = this.icn3d; ic.icn3dui;
63029
+ setAtomMenu(commandnameArray) { let ic = this.icn3d, me = ic.icn3dui;
62974
63030
  let html = "";
62975
63031
 
62976
63032
  let nameArray1 =(ic.defNames2Residues !== undefined) ? Object.keys(ic.defNames2Residues) : [];
@@ -62979,12 +63035,22 @@ class DefinedSets {
62979
63035
  let nameArrayTmp = nameArray1.concat(nameArray2).sort();
62980
63036
 
62981
63037
  let nameArray = [];
62982
- // $.each(nameArrayTmp, function(i, el){
62983
- // if($.inArray(el, nameArray) === -1) nameArray.push(el);
62984
- // });
62985
- nameArrayTmp.forEach(elem => {
62986
- if($.inArray(elem, nameArray) === -1) nameArray.push(elem);
62987
- });
63038
+ // $.each(nameArrayTmp, function(i, el){
63039
+ // if($.inArray(el, nameArray) === -1) nameArray.push(el);
63040
+ // });
63041
+ // nameArrayTmp.forEach(elem => {
63042
+ // if($.inArray(elem, nameArray) === -1) nameArray.push(elem);
63043
+ // });
63044
+
63045
+ let structureArray = Object.keys(me.utilsCls.getStructures(ic.dAtoms));
63046
+
63047
+ nameArrayTmp.forEach((elem) => {
63048
+ structureArray.forEach((structure) => {
63049
+ if (ic.defNames2Residues[elem][0].split("_")[0].includes(structure.split("_")[0])){
63050
+ if ($.inArray(elem, nameArray) === -1) nameArray.push(elem);
63051
+ }
63052
+ });
63053
+ });
62988
63054
 
62989
63055
  //for(let i in ic.defNames2Atoms) {
62990
63056
  for(let i = 0, il = nameArray.length; i < il; ++i) {
@@ -63550,6 +63616,124 @@ class DefinedSets {
63550
63616
 
63551
63617
  }
63552
63618
 
63619
+ class SelectCollections {
63620
+ constructor(icn3d) {
63621
+ this.icn3d = icn3d;
63622
+ }
63623
+
63624
+ //Set the menu of defined sets with an array of defined names "commandnameArray".
63625
+ setAtomMenu(nameArray, titleArray) {
63626
+ let ic = this.icn3d;
63627
+ ic.icn3dui;
63628
+ let html = "";
63629
+ let commandnameArray = [nameArray[0]];
63630
+ //for(let i in ic.defNames2Atoms) {
63631
+ for (let i = 0, il = nameArray.length; i < il; ++i) {
63632
+ let name = nameArray[i];
63633
+ let title = titleArray[i];
63634
+
63635
+ let atomHash;
63636
+ if (
63637
+ ic.defNames2Atoms !== undefined &&
63638
+ ic.defNames2Atoms.hasOwnProperty(name)
63639
+ ) {
63640
+ let atomArray = ic.defNames2Atoms[name];
63641
+
63642
+ if (atomArray.length > 0) ic.atoms[atomArray[0]];
63643
+ } else if (
63644
+ ic.defNames2Residues !== undefined &&
63645
+ ic.defNames2Residues.hasOwnProperty(name)
63646
+ ) {
63647
+ let residueArray = ic.defNames2Residues[name];
63648
+ if (residueArray.length > 0) {
63649
+ atomHash = ic.residues[residueArray[0]];
63650
+ if (atomHash) {
63651
+ ic.atoms[Object.keys(atomHash)[0]];
63652
+ }
63653
+ }
63654
+ }
63655
+
63656
+ if (commandnameArray.indexOf(name) != -1) {
63657
+ html +=
63658
+ "<option value='" +
63659
+ name +
63660
+ "' selected='selected'>" +
63661
+ title +
63662
+ "</option>";
63663
+ } else {
63664
+ html += "<option value='" + name + "'>" + title + "</option>";
63665
+ }
63666
+ }
63667
+
63668
+ return html;
63669
+ }
63670
+
63671
+ clickStructure() {
63672
+ let ic = this.icn3d,
63673
+ me = ic.icn3dui;
63674
+ let thisClass = this;
63675
+
63676
+ //me.myEventCls.onIds("#" + ic.pre + "atomsCustom", "change", function(e) { let ic = thisClass.icn3d;
63677
+ $("#" + ic.pre + "collections_menu").change(async function (e) {
63678
+ let ic = thisClass.icn3d;
63679
+ // ic.init()
63680
+ let nameArray = $(this).val();
63681
+ let nameStructure = $(this).find("option:selected").text();
63682
+
63683
+ ic.nameArray = nameArray;
63684
+ if (nameArray !== null) {
63685
+ ic.bShowHighlight = false;
63686
+ await ic.chainalignParserCls.downloadMmdbAf(nameArray.toString());
63687
+
63688
+ ic.dAtoms = {};
63689
+ ic.hAtoms = {};
63690
+ // ic.ssbondpnts = {};
63691
+ let chainIdHash = {};
63692
+
63693
+ for (const name in nameArray) {
63694
+ for (const key in ic.chains) {
63695
+ if (key.includes(nameArray[name])) {
63696
+ chainIdHash[key] = 1;
63697
+ if (ic.chains.hasOwnProperty(key)) {
63698
+ const innerDict = ic.chains[key];
63699
+ for (const innerKey in innerDict) {
63700
+ if (innerDict.hasOwnProperty(innerKey)) {
63701
+ ic.dAtoms[innerKey] = innerDict[innerKey];
63702
+ ic.hAtoms[innerKey] = innerDict[innerKey];
63703
+ }
63704
+ }
63705
+ }
63706
+ }
63707
+ }
63708
+ }
63709
+
63710
+ ic.transformCls.zoominSelection();
63711
+ ic.definedSetsCls.showSets();
63712
+
63713
+
63714
+ await ic.drawCls.draw();
63715
+ ic.saveFileCls.showTitle();
63716
+
63717
+ me.htmlCls.clickMenuCls.setLogCmd(
63718
+ "select structure " + "[" + nameStructure + "]",
63719
+ true
63720
+ );
63721
+ ic.bSelectResidue = false;
63722
+ }
63723
+ });
63724
+
63725
+ me.myEventCls.onIds(
63726
+ "#" + ic.pre + "collections_menu",
63727
+ "focus",
63728
+ function (e) {
63729
+ let ic = thisClass.icn3d;
63730
+ if (me.utilsCls.isMobile())
63731
+ $("#" + ic.pre + "collections_menu").val("");
63732
+ }
63733
+ );
63734
+ }
63735
+ }
63736
+
63553
63737
  /**
63554
63738
  * @author Jiyao Wang <wangjiy@ncbi.nlm.nih.gov> / https://github.com/ncbi/icn3d
63555
63739
  */
@@ -74754,7 +74938,8 @@ class iCn3D {
74754
74938
  this.setSeqAlignCls = new SetSeqAlign(this);
74755
74939
 
74756
74940
  this.applyCommandCls = new ApplyCommand(this);
74757
- this.definedSetsCls = new DefinedSets(this);
74941
+ this.definedSetsCls = new DefinedSets(this);
74942
+ this.selectCollectionsCls = new SelectCollections(this);
74758
74943
  this.legendTableCls = new LegendTable(this);
74759
74944
  this.loadScriptCls = new LoadScript(this);
74760
74945
  this.selByCommCls = new SelectByCommand(this);
@@ -75001,7 +75186,7 @@ class iCn3DUI {
75001
75186
  //even when multiple iCn3D viewers are shown together.
75002
75187
  this.pre = this.cfg.divid + "_";
75003
75188
 
75004
- this.REVISION = '3.29.0';
75189
+ this.REVISION = '3.29.1';
75005
75190
 
75006
75191
  // In nodejs, iCn3D defines "window = {navigator: {}}"
75007
75192
  this.bNode = (Object.keys(window).length < 2) ? true : false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icn3d",
3
- "version": "3.29.0",
3
+ "version": "3.29.1",
4
4
  "main": "./icn3d.js",
5
5
  "exports": {
6
6
  ".": {