Skip to content

Commit

Permalink
Merge pull request #105 in STRUC/icn3d from release253 to master
Browse files Browse the repository at this point in the history
* commit '058d2327bc3a9d453a4059f9bc55bd7315980482':
  Added commands for up arraow and down arrow after picking a residue
  fix link in README
  • Loading branch information
jiywang3 committed Mar 12, 2019
2 parents 8dc6140 + 058d232 commit 4467547
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 245 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## Change Log
The production version [icn3d-2.5.3](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.5.3.zip) was release on March 12, 2019. Added commands for up arraow and down arrow after picking a residue.

The production version [icn3d-2.5.2](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.5.2.zip) was release on March 5, 2019. The style Lines was fixed by replacing THREE.Line with THREE.LineSegments.

The production version [icn3d-2.5.1](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.5.1.zip) was release on February 14, 2019. Change log was moved to the file CHANGELOG.md. Share Link was changed from https://d55qc.app.goo.gl/### to https://icn3d.page.link/###. All previous share links still work. iCn3D library file was renamed from full_ui_all_#.#.#.min.js to icn3d_full_ui_#.#.#.min.js. Both files are available to make it backward compatible.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ We provided two types of iCn3D widgets: [basic interface](https://www.ncbi.nlm.n

Either of these widgets could be easily added to your own web pages. Please see the [help page](https://www.ncbi.nlm.nih.gov/Structure/icn3d/docs/icn3d_help.html#HowToUse) for more details.

<b>Complete package</b> of iCn3D including Three.js and jQuery can be downloaded from [https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.5.2.zip](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.5.2.zip). The "Download ZIP" link in this page does not include third-party libraries.
<b>Complete package</b> of iCn3D including Three.js and jQuery can be downloaded from [https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.5.3.zip](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.5.3.zip). The "Download ZIP" link in this page does not include third-party libraries.

## Usage

Expand All @@ -44,7 +44,7 @@ iCn3D can be embedded in a web page by including the URL in HTML iframe, e.g. <i

To embed iCn3D with JavaScript libraries, the following libraries need to be included: jQuery, jQuery UI, Three.js, and iCn3D library. An html div tag to hold the 3D viewer is added. The iCn3D widget is initialized with the custom defined parameter "cfg": "var icn3dui = new iCn3DUI(cfg); icn3dui.show3DStructure();". Multiple iCn3D widgets can be embedded in a single page.

Users can choose to show the most recent version of iCn3D, or a locked version of iCn3D. To show the most recent version, use the library files without the version postfix as shown in the [iCn3D Web API page] (https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#HowToUse). To show a locked version, use the library files with the version postfix as shown in the source code of [iCn3D page] (https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?mmdbid=1tup). If the input is provided as an MMDB ID, both library files and backend cgis are versioned so that the 3D display will be stable.
Users can choose to show the most recent version of iCn3D, or a locked version of iCn3D. To show the most recent version, use the library files without the version postfix as shown in the [iCn3D Web API page](https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d.html#HowToUse). To show a locked version, use the library files with the version postfix as shown in the source code of [iCn3D page](https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?mmdbid=1tup). If the input is provided as an MMDB ID, both library files and backend cgis are versioned so that the 3D display will be stable.

## Third-party libraries used

Expand Down
20 changes: 17 additions & 3 deletions icn3d.html
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ <h1>iCn3D Web APIs</h1>
<a href="#outputSelection">outputSelection</a><br>
<a href="#selectAAlignChain">selectAAlignChain</a><br>
<a href="#selectAChain">selectAChain</a><br>
<a href="#switchHighlightLevelDown">switchHighlightLevelDown</a><br>
<a href="#switchHighlightLevelUp">switchHighlightLevelUp</a><br>
<a href="#toggleSelection">toggleSelection</a><br>
<br>
<span style="font-weight:bold; font-size:1em;">Highlight Methods</span><br>
Expand Down Expand Up @@ -668,9 +670,9 @@ <h2>Menus, Commands, and Methods of the advanced interface<img src="https://www.

<tr><td colspan="3">f) Save Files</td> </tr>
<tr><td valign='top'><span class="indent">iCn3D PNG Image:</span></td> <td valign='top'>export canvas (URL example: <a href="https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?mmdbid=1top&command=export%20canvas" target="_blank">https://www.ncbi.nlm.nih.gov/Structure/icn3d/full.html?mmdbid=1top&command=export%20canvas</a>)</td> <td valign='top'><a href="#saveFile">saveFile([filename], 'png')</a></td></tr>
<tr><td valign='top'><span class="indent">State File:</span></td> <td valign='top'>[no command available]</td> <td valign='top'>saveFile</td></tr>
<tr><td valign='top'><span class="indent">All Selections:</span></td> <td valign='top'>[no command available]</td> <td valign='top'>saveFile</td></tr>
<tr><td valign='top'><span class="indent">Residue Counts:</span></td> <td valign='top'>[no command available]</td> <td valign='top'>saveFile</td></tr>
<tr><td valign='top'><span class="indent">State File:</span></td> <td valign='top'>[no command available]</td> <td valign='top'><a href="#saveFile">saveFile</a></td></tr>
<tr><td valign='top'><span class="indent">All Selections:</span></td> <td valign='top'>[no command available]</td> <td valign='top'><a href="#saveFile">saveFile</a></td></tr>
<tr><td valign='top'><span class="indent">Residue Counts:</span></td> <td valign='top'>[no command available]</td> <td valign='top'><a href="#saveFile">saveFile</a></td></tr>
<tr><td valign='top'><span class="indent">Interaction List:</span></td> <td valign='top'>export interactions</td> <td valign='top'><a href="#exportInteractions">exportInteractions</a></td></tr>

<tr><td valign='top'>g) Share Link:</td> <td valign='top'>[no command available]</td> <td valign='top'><a href="#shareLink">shareLink</a></td></tr>
Expand Down Expand Up @@ -711,6 +713,10 @@ <h2>Menus, Commands, and Methods of the advanced interface<img src="https://www.
<tr><td valign='top'><span class="indent">Outline:</span></td> <td valign='top'>set highlight style outline</td> <td valign='top'>me.icn3d.bHighlight = 1;</td></tr>
<tr><td valign='top'><span class="indent">3D Objects:</span></td> <td valign='top'>set highlight style 3d</td> <td valign='top'>me.icn3d.bHighlight = 2;</td></tr>

<tr><td colspan="3"><br>l) Switch Highlight Level</td> </tr>
<tr><td valign='top'><span class="indent">&uarr;:</span></td> <td valign='top'>highlight level up</td> <td valign='top'><a href="#switchHighlightLevelUp">switchHighlightLevelUp<a></td></tr>
<tr><td valign='top'><span class="indent">&darr;:</span></td> <td valign='top'>highlight level down</td> <td valign='top'><a href="#switchHighlightLevelDown">switchHighlightLevelDown</a></td></tr>

</tbody></table>
<br>
<a name="selectb"></a><b>2b. Selection Definition</b> <a href="#Top"><span class="top">&nbsp;&nbsp;&nbsp;</span></a><br>
Expand Down Expand Up @@ -1771,6 +1777,11 @@ <h3>Methods <a href="#Top"><span class="top">&nbsp;&nbsp;&nbsp;</span></a></h3>
<br><br><a name="showTitle"></a><b>showTitle()</b> <a href="#Top"><span class="top">&nbsp;&nbsp;&nbsp;</span></a><br>
Show the title and PDB ID of the PDB structure at the beginning of the viewer.

<br><br><a name="switchHighlightLevelDown"></a><b>switchHighlightLevelDown()</b> <a href="#Top"><span class="top">&nbsp;&nbsp;&nbsp;</span></a><br>
When users pick an atom, a residue, a strand/helix, a chain, or a structure, they can use upper arrow to increase the highlight level by one, or use down arrow to decrease the highlight level by one. This function switchHighlightLevelDown() decreases the highlight level by one.

<br><br><a name="switchHighlightLevelUp"></a><b>switchHighlightLevelUp()</b> <a href="#Top"><span class="top">&nbsp;&nbsp;&nbsp;</span></a><br>
When users pick an atom, a residue, a strand/helix, a chain, or a structure, they can use upper arrow to increase the highlight level by one, or use down arrow to decrease the highlight level by one. This function switchHighlightLevelUp() increases the highlight level by one.

<br><br><a name="toggleSelection"></a><b>toggleSelection()</b> <a href="#Top"><span class="top">&nbsp;&nbsp;&nbsp;</span></a><br>
Toggle on and off the current selection.
Expand Down Expand Up @@ -1799,6 +1810,9 @@ <h3>Methods <a href="#Top"><span class="top">&nbsp;&nbsp;&nbsp;</span></a></h3>

<a name="log"></a>
<h2>Change Log:<img src="https://www.ncbi.nlm.nih.gov/Structure/IMG/spacer.gif" width="25" height="1" border="0"><a href="#Top"><img src="https://www.ncbi.nlm.nih.gov/Structure/IMG/arrowup_blue.gif" width="12" height="12" border="0" alt="back to top"></a></h2>
The production version <a href="https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.5.3.zip">icn3d-2.5.3</a> was release on March 12, 2019. Added commands for up arraow and down arrow after picking a residue.
<br><br>

The production version <a href="https://www.ncbi.nlm.nih.gov/Structure/icn3d/icn3d-2.5.2.zip">icn3d-2.5.2</a> was release on March 5, 2019. The style Lines was fixed by replacing THREE.Line with THREE.LineSegments.
<br><br>

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "icn3d",
"version": "2.5.2",
"version": "2.5.3",
"description": "iCn3D Structure Viewer",
"main": "index.html",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/icn3d/icn3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ var iCn3D = function (id) {
e.preventDefault();
});

me.switchHighlightLevel();
//me.switchHighlightLevel();

// key event has to use the document because it requires the focus
me.typetext = false;
Expand Down
156 changes: 18 additions & 138 deletions src/icn3d/other.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,129 +510,6 @@ iCn3D.prototype.addHlObjects = function (color, bRender, atomsHash) {
if(bRender === undefined || bRender) this.render();
};

iCn3D.prototype.switchHighlightLevelBase = function() { var me = this;
$(document).bind('keydown', function (e) {
if(e.keyCode === 38) { // arrow up, select upper level of atoms
e.preventDefault();

if(!me.bShift && !me.bCtrl) me.removeHlObjects();

if(me.highlightlevel === 1) { // atom -> residue
me.highlightlevel = 2;

var firstAtom = me.getFirstAtomObj(me.pickedAtomList);

if(!me.bShift && !me.bCtrl) {
me.hAtoms = me.cloneHash(me.residues[firstAtom.structure + '_' + firstAtom.chain + '_' + firstAtom.resi]);
}
else {
me.hAtoms = me.unionHash(me.hAtoms, me.residues[firstAtom.structure + '_' + firstAtom.chain + '_' + firstAtom.resi]);
}
}
else if(me.highlightlevel === 2) { // residue -> strand
me.highlightlevel = 3;

var firstAtom = me.getFirstAtomObj(me.pickedAtomList);
if(!me.bShift && !me.bCtrl) {
me.hAtoms = me.cloneHash(me.selectStrandHelixFromAtom(firstAtom));
}
else {
me.hAtoms = me.unionHash(me.hAtoms, me.selectStrandHelixFromAtom(firstAtom));
}
}
else if(me.highlightlevel === 3) { // strand -> chain
me.highlightlevel = 4;

var firstAtom = me.getFirstAtomObj(me.pickedAtomList);
if(!me.bShift && !me.bCtrl) {
me.hAtoms = me.cloneHash(me.chains[firstAtom.structure + '_' + firstAtom.chain]);
}
else {
me.hAtoms = me.unionHash(me.hAtoms, me.chains[firstAtom.structure + '_' + firstAtom.chain]);
}
}
else if(me.highlightlevel === 4 || me.highlightlevel === 5) { // chain -> structure
me.highlightlevel = 5;

var firstAtom = me.getFirstAtomObj(me.pickedAtomList);

if(!me.bShift && !me.bCtrl) me.hAtoms = {};
var chainArray = me.structures[firstAtom.structure];
for(var i = 0, il = chainArray.length; i < il; ++i) {
me.hAtoms = me.unionHash(me.hAtoms, me.chains[chainArray[i]]);
}
}

me.addHlObjects();
}
else if(e.keyCode === 40) { // arrow down, select down level of atoms
e.preventDefault();

me.removeHlObjects();

if( (me.highlightlevel === 2 || me.highlightlevel === 1) && Object.keys(me.pickedAtomList).length === 1) { // residue -> atom
me.highlightlevel = 1;

me.hAtoms = me.cloneHash(me.pickedAtomList);
if(!me.bShift && !me.bCtrl) {
me.hAtoms = me.cloneHash(me.pickedAtomList);
}
else {
me.hAtoms = me.unionHash(me.hAtoms, me.pickedAtomList);
}
}
else if(me.highlightlevel === 3) { // strand -> residue
var residueHash = {};

for(var i in me.pickedAtomList) {
residueid = me.atoms[i].structure + '_' + me.atoms[i].chain + '_' + me.atoms[i].resi;
residueHash[residueid] = 1;
}

if(Object.keys(residueHash).length === 1) {
me.highlightlevel = 2;

var firstAtom = me.getFirstAtomObj(me.pickedAtomList);
if(!me.bShift && !me.bCtrl) {
me.hAtoms = me.cloneHash(me.residues[firstAtom.structure + '_' + firstAtom.chain + '_' + firstAtom.resi]);
}
else {
me.hAtoms = me.unionHash(me.hAtoms, me.residues[firstAtom.structure + '_' + firstAtom.chain + '_' + firstAtom.resi]);
}
}
}
else if(me.highlightlevel === 4) { // chain -> strand
me.highlightlevel = 3;

var firstAtom = me.getFirstAtomObj(me.pickedAtomList);
if(!me.bShift && !me.bCtrl) {
me.hAtoms = me.cloneHash(me.selectStrandHelixFromAtom(firstAtom));
}
else {
me.hAtoms = me.unionHash(me.hAtoms, me.selectStrandHelixFromAtom(firstAtom));
}
}
else if(me.highlightlevel === 5) { // structure -> chain
me.highlightlevel = 4;

var firstAtom = me.getFirstAtomObj(me.pickedAtomList);
if(!me.bShift && !me.bCtrl) {
me.hAtoms = me.cloneHash(me.chains[firstAtom.structure + '_' + firstAtom.chain]);
}
else {
me.hAtoms = me.unionHash(me.hAtoms, me.chains[firstAtom.structure + '_' + firstAtom.chain]);
}
}

me.addHlObjects();
}
});
};

iCn3D.prototype.switchHighlightLevel = function() { var me = this;
this.switchHighlightLevelBase();
};

iCn3D.prototype.resetOrientation = function() {
var bSet = false;
if(this.commands.length > 0) {
Expand Down Expand Up @@ -757,24 +634,27 @@ iCn3D.prototype.selectStrandHelixFromAtom = function(atom) {

// fill the beginning
var beginResi = firstAtom.resi;
for(var i = firstAtom.resi - 1; i > 0; --i) {
var residueid = firstAtom.structure + '_' + firstAtom.chain + '_' + i;
if(!this.residues.hasOwnProperty(residueid)) break;

var atom = this.getFirstCalphaAtomObj(this.residues[residueid]);
beginResi = atom.resi;

if( (firstAtom.ss !== 'coil' && atom.ss === firstAtom.ss && atom.ssbegin) || (firstAtom.ss === 'coil' && atom.ss !== firstAtom.ss) ) {
if(firstAtom.ss === 'coil' && atom.ss !== firstAtom.ss) {
beginResi = atom.resi + 1;
if(!firstAtom.ssbegin) {
for(var i = firstAtom.resi - 1; i > 0; --i) {
var residueid = firstAtom.structure + '_' + firstAtom.chain + '_' + i;
if(!this.residues.hasOwnProperty(residueid)) break;

var atom = this.getFirstCalphaAtomObj(this.residues[residueid]);
beginResi = atom.resi;

if( (firstAtom.ss !== 'coil' && atom.ss === firstAtom.ss && atom.ssbegin)
|| (firstAtom.ss === 'coil' && atom.ss !== firstAtom.ss) ) {
if(firstAtom.ss === 'coil' && atom.ss !== firstAtom.ss) {
beginResi = atom.resi + 1;
}
break;
}
break;
}
}

for(var i = beginResi; i <= firstAtom.resi; ++i) {
var residueid = firstAtom.structure + '_' + firstAtom.chain + '_' + i;
atomsHash = this.unionHash(atomsHash, this.hash2Atoms(this.residues[residueid]));
for(var i = beginResi; i <= firstAtom.resi; ++i) {
var residueid = firstAtom.structure + '_' + firstAtom.chain + '_' + i;
atomsHash = this.unionHash(atomsHash, this.hash2Atoms(this.residues[residueid]));
}
}

// fill the end
Expand Down
13 changes: 9 additions & 4 deletions src/icn3dui/annotations/addtrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,14 @@ iCn3DUI.prototype.clickAddTrackButton = function() { var me = this;
var title = (isNaN(gi)) ? 'Acc ' + gi : 'gi ' + gi;

//var text = $("#" + me.pre + "track_text").val();
var url = 'https://www.ncbi.nlm.nih.gov/Structure/pwaln/pwaln.fcgi?fmt';
var url = 'https://www.ncbi.nlm.nih.gov/Structure/pwaln/pwaln.fcgi?';

$.ajax({
url: url,
type: 'POST',
data : {'targets': chainid, 'queries': gi},
dataType: 'jsonp',
//dataType: 'jsonp',
dataType: 'json',
tryCount : 0,
retryLimit : 1,
success: function(data) {
Expand All @@ -237,6 +239,7 @@ iCn3DUI.prototype.clickAddTrackButton = function() { var me = this;
if(data.data !== undefined) {
query = data.data[0].query;
target = data.data[0].targets[chainid];
if(target === undefined) target = data.data[0].targets[chainid.replace(/_/g, '')];
}

var text = '';
Expand Down Expand Up @@ -309,12 +312,13 @@ iCn3DUI.prototype.clickAddTrackButton = function() { var me = this;
var title = 'fasta ' + fasta.substr(0, 5);

//var text = $("#" + me.pre + "track_text").val();
var url = 'https://www.ncbi.nlm.nih.gov/Structure/pwaln/pwaln.fcgi?fmt';
var url = 'https://www.ncbi.nlm.nih.gov/Structure/pwaln/pwaln.fcgi?';
$.ajax({
url: url,
type: 'POST',
data : {'targets': chainid, 'queries': fasta},
dataType: 'jsonp',
//dataType: 'jsonp',
dataType: 'json',
tryCount : 0,
retryLimit : 1,
success: function(data) {
Expand All @@ -323,6 +327,7 @@ iCn3DUI.prototype.clickAddTrackButton = function() { var me = this;
if(data.data !== undefined) {
query = data.data[0].query;
target = data.data[0].targets[chainid];
if(target === undefined) target = data.data[0].targets[chainid.replace(/_/g, '')];
}

var text = '';
Expand Down
Loading

0 comments on commit 4467547

Please sign in to comment.