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.js CHANGED
@@ -5957,6 +5957,10 @@ class ClickMenu {
5957
5957
  me.myEventCls.onIds("#" + me.pre + "mn1_selection", "click", function(e) { me.icn3d; //e.preventDefault();
5958
5958
  me.htmlCls.dialogCls.openDlg('dl_selection', 'Please input the selection file');
5959
5959
  });
5960
+
5961
+ me.myEventCls.onIds("#" + me.pre + "mn1_collection", "click", function (e) { me.icn3d; //e.preventDefault();
5962
+ me.htmlCls.dialogCls.openDlg('dl_collection', 'Please input the collection file');
5963
+ });
5960
5964
 
5961
5965
  me.myEventCls.onIds("#" + me.pre + "mn1_dsn6", "click", function(e) { me.icn3d; //e.preventDefault();
5962
5966
  me.htmlCls.dialogCls.openDlg('dl_dsn6', 'Please input the map file to display electron density map');
@@ -8546,6 +8550,7 @@ class SetMenu {
8546
8550
  html += this.getLink('mn1_state', 'State/Script File', undefined, 2);
8547
8551
  html += this.getLink('mn1_fixedversion', 'Share Link in Archived Ver. ' + me.htmlCls.wifiStr, undefined, 2);
8548
8552
  html += this.getLink('mn1_selection', 'Selection File', undefined, 2);
8553
+ html += this.getLink("mn1_collection", "Collection File", undefined, 2);
8549
8554
 
8550
8555
  html += this.getMenuSep();
8551
8556
 
@@ -10971,6 +10976,19 @@ class SetDialog {
10971
10976
  html += me.htmlCls.buttonStr + "reload_selectionfile' style='margin-top: 6px;'>Load</button>";
10972
10977
  html += "</div>";
10973
10978
 
10979
+ html += me.htmlCls.divStr + "dl_collection' class='" + dialogClass + "'>";
10980
+ html += "Collection file: " + me.htmlCls.inputFileStr + "id='" + me.pre + "collectionfile'><br/>";
10981
+ html += me.htmlCls.buttonStr + "reload_collectionfile' style='margin-top: 6px;'>Load</button>";
10982
+ html += "</div>";
10983
+
10984
+ html += me.htmlCls.divStr + "dl_selectCollections' class='" + dialogClass + "'>";
10985
+ html += me.htmlCls.divStr + "dl_collectionsMenu'>";
10986
+ html += "<b>Structures:</b> <br/>";
10987
+ html += "<select id='" + me.pre + "collections_menu' multiple size='6' style='min-width:130px;'>";
10988
+ html += "</select>";
10989
+ html += "</div>";
10990
+ html += "</div>";
10991
+
10974
10992
  html += me.htmlCls.divStr + "dl_menuloadpref' class='" + dialogClass + "'>";
10975
10993
  html += this.addNotebookTitle('dl_menuloadpref', 'Load a preference file');
10976
10994
  html += "Preference file: " + me.htmlCls.inputFileStr + "id='" + me.pre + "menupreffile'><br/>";
@@ -13175,6 +13193,45 @@ class Events {
13175
13193
  }
13176
13194
  });
13177
13195
 
13196
+ me.myEventCls.onIds("#" + me.pre + "reload_collectionfile", "click", function (e) { let ic = me.icn3d;
13197
+ e.preventDefault();
13198
+ let file = $("#" + me.pre + "collectionfile")[0].files[0];
13199
+ if (!file) {
13200
+ var aaa = 1; //alert("Please select a file before clicking 'Load'");
13201
+ } else {
13202
+ if (!me.cfg.notebook) dialog.dialog("close");
13203
+ if (!me.cfg.notebook) {
13204
+ $(".ui-dialog-content").dialog("close");
13205
+ } else {
13206
+ ic.resizeCanvasCls.closeDialogs();
13207
+ }
13208
+ me.htmlCls.setHtmlCls.fileSupport();
13209
+ let reader = new FileReader();
13210
+ reader.onload = async function (e) {
13211
+ let dataStr = JSON.parse(e.target.result);
13212
+ let collection = [dataStr["structures"].map(({ id }) => id), dataStr["structures"].map(({ title }) => title)];
13213
+ let collectionHtml = ic.selectCollectionsCls.setAtomMenu(collection[0], collection[1]);
13214
+ await ic.chainalignParserCls.downloadMmdbAf(collection[0][0]);
13215
+
13216
+ ic.opts["color"] = "structure";
13217
+ ic.setColorCls.setColorByOptions(ic.opts, ic.dAtoms);
13218
+
13219
+ $("#" + ic.pre + "collections_menu").html(collectionHtml);
13220
+ ic.selectCollectionsCls.clickStructure();
13221
+
13222
+ $("#" + ic.pre + "collections_menu").trigger("change");
13223
+
13224
+ me.htmlCls.clickMenuCls.setLogCmd(
13225
+ "load collection file " +
13226
+ $("#" + me.pre + "collectionfile").val(),
13227
+ false
13228
+ );
13229
+ };
13230
+ reader.readAsText(file);
13231
+ me.htmlCls.dialogCls.openDlg("dl_selectCollections", "Select Collections");
13232
+ }
13233
+ });
13234
+
13178
13235
  me.myEventCls.onIds("#" + me.pre + "reload_dsn6file2fofc", "click", function(e) { let ic = me.icn3d;
13179
13236
  e.preventDefault();
13180
13237
  //if(!me.cfg.notebook) dialog.dialog( "close" );
@@ -51743,7 +51800,6 @@ class MtzParser {
51743
51800
  else {
51744
51801
  sigma = await this.mtzParserBase(url, type, sigma, 'url');
51745
51802
 
51746
- console.log("### sigma " + sigma);
51747
51803
  //me.htmlCls.clickMenuCls.setLogCmd('set map ' + type + ' sigma ' + sigma + ' file mtz | ' + encodeURIComponent(url), true);
51748
51804
  }
51749
51805
  }
@@ -56438,7 +56494,7 @@ class LoadAtomData {
56438
56494
  if(!bTitle) ic.molTitle = '';
56439
56495
  }
56440
56496
  else { // mmdbid or mmcifid
56441
- if(data.descr !== undefined) ic.molTitle += data.descr.name;
56497
+ if(data.descr !== undefined) ic.molTitle = data.descr.name;
56442
56498
  if(type === 'mmdbid') {
56443
56499
  let pdbidTmp = (isNaN(id)) ? id : data.pdbId;
56444
56500
  let chainHash = {};
@@ -62069,7 +62125,7 @@ class DefinedSets {
62069
62125
  }
62070
62126
 
62071
62127
  //Set the menu of defined sets with an array of defined names "commandnameArray".
62072
- setAtomMenu(commandnameArray) { let ic = this.icn3d; ic.icn3dui;
62128
+ setAtomMenu(commandnameArray) { let ic = this.icn3d, me = ic.icn3dui;
62073
62129
  let html = "";
62074
62130
 
62075
62131
  let nameArray1 =(ic.defNames2Residues !== undefined) ? Object.keys(ic.defNames2Residues) : [];
@@ -62078,12 +62134,22 @@ class DefinedSets {
62078
62134
  let nameArrayTmp = nameArray1.concat(nameArray2).sort();
62079
62135
 
62080
62136
  let nameArray = [];
62081
- // $.each(nameArrayTmp, function(i, el){
62082
- // if($.inArray(el, nameArray) === -1) nameArray.push(el);
62083
- // });
62084
- nameArrayTmp.forEach(elem => {
62085
- if($.inArray(elem, nameArray) === -1) nameArray.push(elem);
62086
- });
62137
+ // $.each(nameArrayTmp, function(i, el){
62138
+ // if($.inArray(el, nameArray) === -1) nameArray.push(el);
62139
+ // });
62140
+ // nameArrayTmp.forEach(elem => {
62141
+ // if($.inArray(elem, nameArray) === -1) nameArray.push(elem);
62142
+ // });
62143
+
62144
+ let structureArray = Object.keys(me.utilsCls.getStructures(ic.dAtoms));
62145
+
62146
+ nameArrayTmp.forEach((elem) => {
62147
+ structureArray.forEach((structure) => {
62148
+ if (ic.defNames2Residues[elem][0].split("_")[0].includes(structure.split("_")[0])){
62149
+ if ($.inArray(elem, nameArray) === -1) nameArray.push(elem);
62150
+ }
62151
+ });
62152
+ });
62087
62153
 
62088
62154
  //for(let i in ic.defNames2Atoms) {
62089
62155
  for(let i = 0, il = nameArray.length; i < il; ++i) {
@@ -62649,6 +62715,124 @@ class DefinedSets {
62649
62715
 
62650
62716
  }
62651
62717
 
62718
+ class SelectCollections {
62719
+ constructor(icn3d) {
62720
+ this.icn3d = icn3d;
62721
+ }
62722
+
62723
+ //Set the menu of defined sets with an array of defined names "commandnameArray".
62724
+ setAtomMenu(nameArray, titleArray) {
62725
+ let ic = this.icn3d;
62726
+ ic.icn3dui;
62727
+ let html = "";
62728
+ let commandnameArray = [nameArray[0]];
62729
+ //for(let i in ic.defNames2Atoms) {
62730
+ for (let i = 0, il = nameArray.length; i < il; ++i) {
62731
+ let name = nameArray[i];
62732
+ let title = titleArray[i];
62733
+
62734
+ let atomHash;
62735
+ if (
62736
+ ic.defNames2Atoms !== undefined &&
62737
+ ic.defNames2Atoms.hasOwnProperty(name)
62738
+ ) {
62739
+ let atomArray = ic.defNames2Atoms[name];
62740
+
62741
+ if (atomArray.length > 0) ic.atoms[atomArray[0]];
62742
+ } else if (
62743
+ ic.defNames2Residues !== undefined &&
62744
+ ic.defNames2Residues.hasOwnProperty(name)
62745
+ ) {
62746
+ let residueArray = ic.defNames2Residues[name];
62747
+ if (residueArray.length > 0) {
62748
+ atomHash = ic.residues[residueArray[0]];
62749
+ if (atomHash) {
62750
+ ic.atoms[Object.keys(atomHash)[0]];
62751
+ }
62752
+ }
62753
+ }
62754
+
62755
+ if (commandnameArray.indexOf(name) != -1) {
62756
+ html +=
62757
+ "<option value='" +
62758
+ name +
62759
+ "' selected='selected'>" +
62760
+ title +
62761
+ "</option>";
62762
+ } else {
62763
+ html += "<option value='" + name + "'>" + title + "</option>";
62764
+ }
62765
+ }
62766
+
62767
+ return html;
62768
+ }
62769
+
62770
+ clickStructure() {
62771
+ let ic = this.icn3d,
62772
+ me = ic.icn3dui;
62773
+ let thisClass = this;
62774
+
62775
+ //me.myEventCls.onIds("#" + ic.pre + "atomsCustom", "change", function(e) { let ic = thisClass.icn3d;
62776
+ $("#" + ic.pre + "collections_menu").change(async function (e) {
62777
+ let ic = thisClass.icn3d;
62778
+ // ic.init()
62779
+ let nameArray = $(this).val();
62780
+ let nameStructure = $(this).find("option:selected").text();
62781
+
62782
+ ic.nameArray = nameArray;
62783
+ if (nameArray !== null) {
62784
+ ic.bShowHighlight = false;
62785
+ await ic.chainalignParserCls.downloadMmdbAf(nameArray.toString());
62786
+
62787
+ ic.dAtoms = {};
62788
+ ic.hAtoms = {};
62789
+ // ic.ssbondpnts = {};
62790
+ let chainIdHash = {};
62791
+
62792
+ for (const name in nameArray) {
62793
+ for (const key in ic.chains) {
62794
+ if (key.includes(nameArray[name])) {
62795
+ chainIdHash[key] = 1;
62796
+ if (ic.chains.hasOwnProperty(key)) {
62797
+ const innerDict = ic.chains[key];
62798
+ for (const innerKey in innerDict) {
62799
+ if (innerDict.hasOwnProperty(innerKey)) {
62800
+ ic.dAtoms[innerKey] = innerDict[innerKey];
62801
+ ic.hAtoms[innerKey] = innerDict[innerKey];
62802
+ }
62803
+ }
62804
+ }
62805
+ }
62806
+ }
62807
+ }
62808
+
62809
+ ic.transformCls.zoominSelection();
62810
+ ic.definedSetsCls.showSets();
62811
+
62812
+
62813
+ await ic.drawCls.draw();
62814
+ ic.saveFileCls.showTitle();
62815
+
62816
+ me.htmlCls.clickMenuCls.setLogCmd(
62817
+ "select structure " + "[" + nameStructure + "]",
62818
+ true
62819
+ );
62820
+ ic.bSelectResidue = false;
62821
+ }
62822
+ });
62823
+
62824
+ me.myEventCls.onIds(
62825
+ "#" + ic.pre + "collections_menu",
62826
+ "focus",
62827
+ function (e) {
62828
+ let ic = thisClass.icn3d;
62829
+ if (me.utilsCls.isMobile())
62830
+ $("#" + ic.pre + "collections_menu").val("");
62831
+ }
62832
+ );
62833
+ }
62834
+ }
62835
+
62652
62836
  /**
62653
62837
  * @author Jiyao Wang <wangjiy@ncbi.nlm.nih.gov> / https://github.com/ncbi/icn3d
62654
62838
  */
@@ -73853,7 +74037,8 @@ class iCn3D {
73853
74037
  this.setSeqAlignCls = new SetSeqAlign(this);
73854
74038
 
73855
74039
  this.applyCommandCls = new ApplyCommand(this);
73856
- this.definedSetsCls = new DefinedSets(this);
74040
+ this.definedSetsCls = new DefinedSets(this);
74041
+ this.selectCollectionsCls = new SelectCollections(this);
73857
74042
  this.legendTableCls = new LegendTable(this);
73858
74043
  this.loadScriptCls = new LoadScript(this);
73859
74044
  this.selByCommCls = new SelectByCommand(this);
@@ -74100,7 +74285,7 @@ class iCn3DUI {
74100
74285
  //even when multiple iCn3D viewers are shown together.
74101
74286
  this.pre = this.cfg.divid + "_";
74102
74287
 
74103
- this.REVISION = '3.29.0';
74288
+ this.REVISION = '3.29.1';
74104
74289
 
74105
74290
  // In nodejs, iCn3D defines "window = {navigator: {}}"
74106
74291
  this.bNode = (Object.keys(window).length < 2) ? true : false;