Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jmol visualiser #18540

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions client/gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const STATIC_PLUGIN_BUILD_IDS = [
"h5web",
"heatmap/heatmap_default",
"hyphyvision",
"jmol",
"jqplot/jqplot_bar",
"media_player",
"mvpapp",
Expand Down
14 changes: 14 additions & 0 deletions config/plugins/visualizations/jmol/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Jmol Visualizer Plugin for Galaxy

This plugin allows you to visualize molecular structures within the Galaxy platform using [JSmol](http://wiki.jmol.org/index.php/JSmol), a powerful JavaScript library for molecular visualization.

**Usage:**

1. In your Galaxy workflow, select a dataset containing a supported molecular format (e.g., cif file).
2. Choose the "jmol Visualization" tool from the available tools.
3. The molecule will be rendered within the visualization panel. You can interact with the molecule using the controls provided by JSmol.

**Additional Notes:**

* For detailed information on JSmol and supported features, refer to the JSmol documentation: [https://sourceforge.net/projects/jmol/](https://sourceforge.net/projects/jmol/)

16 changes: 16 additions & 0 deletions config/plugins/visualizations/jmol/config/jmol.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE visualization SYSTEM "../../visualization.dtd">
<visualization name="jmol">
<description>This is a visualiser for molecular structures using Jmol</description>
<data_sources>
<data_source>
<model_class>HistoryDatasetAssociation</model_class>
<test type="isinstance" test_attr="datatype" result_type="datatype">data.Data</test>
<to_param param_attr="id">dataset_id</to_param>
</data_source>
</data_sources>
<params>
<param type="dataset" var_name_in_template="hda" required="true">dataset_id</param>
</params>
<template>jmol.mako</template>
</visualization>
265 changes: 265 additions & 0 deletions config/plugins/visualizations/jmol/static/JSmol.min.js

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
Clazz.declarePackage("J.adapter.readers.cif");
Clazz.load(["JU.CifDataParser"], "J.adapter.readers.cif.BCIFDataParser", ["java.io.BufferedInputStream", "$.FileInputStream", "JU.BinaryDocument", "$.MessagePackReader", "J.adapter.readers.cif.BCIFDecoder"], function(){
var c$ = Clazz.decorateAsClass(function(){
this.rdr = null;
this.categoryName = null;
this.rowCount = 0;
this.columnMaps = null;
this.columnDecoders = null;
this.rowPt = 0;
this.ifield = 0;
this.dfield = 0;
this.fieldStr = null;
this.fieldIsValid = false;
this.cifMap = null;
this.header = null;
Clazz.instantialize(this, arguments);}, J.adapter.readers.cif, "BCIFDataParser", JU.CifDataParser);
Clazz.makeConstructor(c$,
function(bcifReader, debugging){
Clazz.superConstructor (this, J.adapter.readers.cif.BCIFDataParser, []);
this.rdr = bcifReader;
this.debugging = debugging;
}, "J.adapter.readers.cif.BCIFReader,~B");
Clazz.defineMethod(c$, "getDecoder",
function(key, col, rowCount, catName){
var sb = null;
var d = new J.adapter.readers.cif.BCIFDecoder(sb, key, col).setRowCount(rowCount, catName).finalizeDecoding(null);
return (d == null || d.dataType == 0 ? null : d);
}, "~S,java.util.Map,~N,~S");
Clazz.defineMethod(c$, "initializeCategory",
function(catName, rowCount, columns){
this.columnMaps = columns;
this.rowCount = rowCount;
this.categoryName = catName;
var n = this.columnCount = columns.length;
if (this.columnNames == null || this.columnNames.length < n) this.columnNames = new Array(n);
for (var i = 0; i < n; i++) {
this.columnNames[i] = (catName + "_" + (columns[i]).get("name")).toLowerCase();
}
}, "~S,~N,~A");
Clazz.overrideMethod(c$, "parseDataBlockParameters",
function(fieldNames, key, data, key2col, col2key){
this.haveData = false;
this.rowPt = -1;
for (var i = 100; --i >= 0; ) {
col2key[i] = key2col[i] = -1;
}
if (!JU.CifDataParser.htFields.containsKey(fieldNames[0])) {
for (var i = fieldNames.length; --i >= 0; ) JU.CifDataParser.htFields.put(fieldNames[i], Integer.$valueOf(i));

}this.columnDecoders = new Array(this.columnCount);
for (var pt = 0; pt < this.columnCount; pt++) {
var s = this.columnNames[pt];
var iField = JU.CifDataParser.htFields.get(s);
var keyIndex = col2key[pt] = (iField == null ? -1 : iField.intValue());
var d = (keyIndex == -1 ? null : this.getDecoder(s, this.getDataColumn(pt), this.rowCount, this.categoryName));
if (d == null) {
if (keyIndex >= 0) key2col[keyIndex] = -2;
} else {
this.columnDecoders[pt] = d;
key2col[keyIndex] = pt;
this.haveData = true;
}}
}, "~A,~S,~S,~A,~A");
Clazz.defineMethod(c$, "decodeAndGetData",
function(icol){
this.columnDecoders = Clazz.newArray(-1, [this.getDecoder(null, this.getDataColumn(icol), this.rowCount, this.categoryName)]);
this.getColumnData(0);
this.columnDecoders = null;
}, "~N");
Clazz.overrideMethod(c$, "getData",
function(){
this.rowPt++;
var done = this.rowPt >= this.rowCount;
if (done) {
for (var i = this.columnDecoders.length; --i >= 0; ) this.columnDecoders[i] = null;

}return !done;
});
Clazz.overrideMethod(c$, "getColumnData",
function(colPt){
this.rdr.key = this.getColumnName(colPt);
this.ifield = -2147483648;
this.dfield = NaN;
if (colPt >= this.columnDecoders.length) System.out.println("???");
if (this.columnDecoders[colPt] == null) {
this.fieldIsValid = false;
return this.fieldStr = this.nullString;
}switch (this.columnDecoders[colPt].dataType) {
case 1:
this.ifield = this.columnDecoders[colPt].getIntValue(this.rowPt);
this.fieldStr = (this.ifield == -2147483648 ? this.nullString : "_");
break;
case 2:
this.dfield = this.columnDecoders[colPt].getFixedPtValue(this.rowPt);
this.fieldStr = (Double.isNaN(this.dfield) ? this.nullString : "_");
break;
case 3:
this.fieldStr = this.columnDecoders[colPt].getStringValue(this.rowPt);
break;
}
this.fieldIsValid = (this.fieldStr !== this.nullString);
return this.fieldStr;
}, "~N");
Clazz.defineMethod(c$, "isFieldValid",
function(){
return this.fieldIsValid;
});
Clazz.defineMethod(c$, "getDataColumn",
function(icol){
return (icol >= 0 && icol < this.columnCount ? this.columnMaps[icol] : null);
}, "~N");
Clazz.overrideMethod(c$, "getAllCifData",
function(){
return null;
});
c$.main = Clazz.defineMethod(c$, "main",
function(args){
try {
var testFile = (args.length == 0 ? "c:/temp/1cbs.bcif" : args[0]);
var binaryDoc = new JU.BinaryDocument();
var bis = new java.io.BufferedInputStream( new java.io.FileInputStream(testFile));
binaryDoc.setStream(bis, true);
var msgMap;
msgMap = ( new JU.MessagePackReader(binaryDoc, false)).readMap();
var parser = new J.adapter.readers.cif.BCIFDataParser(null, true);
parser.debugConstructCifMap(msgMap);
binaryDoc.close();
System.out.println("OK - DONE");
} catch (e) {
if (Clazz.exceptionOf(e, Exception)){
e.printStackTrace();
} else {
throw e;
}
}
}, "~A");
});
;//5.0.1-v2 Fri Jun 07 15:32:46 BST 2024
Loading