-
Notifications
You must be signed in to change notification settings - Fork 967
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add drawrna, with existing code until npm dependency works
- Loading branch information
Showing
30 changed files
with
5,438 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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="RNA Structure Viewer"> | ||
<description>Renders RNA structures hosted at https://github.com/bene200/drawrnajs.</description> | ||
<data_sources> | ||
<data_source> | ||
<model_class>HistoryDatasetAssociation</model_class> | ||
<test test_attr="ext" result_type="datatype">dbn</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> | ||
<entry_point entry_point_type="chart" src="static/script.js" func="func"/> | ||
</visualization> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "visualization", | ||
"version": "0.1.0", | ||
"keywords": [ | ||
"galaxy", | ||
"visualization" | ||
], | ||
"license": "AFL-3.0", | ||
"dependencies": { | ||
"babel-preset-env": "^1.6.1", | ||
"backbone": "^1.3.3", | ||
"bootstrap": "^3.3.7", | ||
"drawrnajs": "^1.2.6", | ||
"jquery": "^3.1.1", | ||
"parcel-bundler": "^1.4.1" | ||
}, | ||
"scripts": { | ||
"build": "parcel build src/script.js -d static" | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
config/plugins/visualizations/drawrna/src/drawrnajs/drawrna.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
var Backbone = require("backbone"); | ||
var Structure = require("./models/structure"); | ||
var Vispanel = require("./views/vispanel"); | ||
|
||
var Drawrnajs = Backbone.View.extend({ | ||
initialize: function(opts){ | ||
this.struct = new Structure(opts.seq, opts.dotbr, 'naview'); | ||
this.vis = new Vispanel({ el: opts.el, struct: this.struct, resindex: opts.resindex }); | ||
}, | ||
render: function(){ | ||
this.vis.render(); | ||
} | ||
}); | ||
|
||
module.exports = Drawrnajs; |
24 changes: 24 additions & 0 deletions
24
config/plugins/visualizations/drawrna/src/drawrnajs/layouts/layout.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
var radiate = require("./radiate/getradiate"); | ||
var naview = require("./naview/getnaview"); | ||
|
||
var Layout = function(layout, nodes, links){ | ||
this.layout = layout; | ||
this.nodes = nodes; | ||
this.links = links; | ||
} | ||
|
||
Layout.prototype.getCoords = function(){ | ||
var coords = null; | ||
if(this.layout === "radiate"){ | ||
coords = radiate(this.nodes, this.links); | ||
} | ||
else if(this.layout === "naview"){ | ||
coords = naview(this.nodes, this.links); | ||
} | ||
else { | ||
throw new Error("Invalid layout"); | ||
} | ||
return coords; | ||
} | ||
|
||
module.exports = Layout; |
49 changes: 49 additions & 0 deletions
49
config/plugins/visualizations/drawrna/src/drawrnajs/layouts/naview/base.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
var Region = require("./region"); | ||
|
||
var Base = module.exports = function(){ | ||
this.mate = null; | ||
this.x = null; | ||
this.y = null; | ||
this.extracted = null; | ||
this.region = new Region(); | ||
} | ||
|
||
Base.prototype.getMate = function(){ | ||
return this.mate; | ||
} | ||
|
||
Base.prototype.setMate = function(mate){ | ||
this.mate = mate; | ||
} | ||
|
||
Base.prototype.getX = function(){ | ||
return this.x; | ||
} | ||
|
||
Base.prototype.setX = function(x){ | ||
this.x = x; | ||
} | ||
|
||
Base.prototype.getY = function(){ | ||
return this.y; | ||
} | ||
|
||
Base.prototype.setY = function(y){ | ||
this.y = y; | ||
} | ||
|
||
Base.prototype.isExtracted = function(){ | ||
return this.extracted; | ||
} | ||
|
||
Base.prototype.setExtracted = function(extracted){ | ||
this.extracted = extracted; | ||
} | ||
|
||
Base.prototype.getRegion = function(){ | ||
return this.region; | ||
} | ||
|
||
Base.prototype.setRegion = function(region){ | ||
this.region = region; | ||
} |
100 changes: 100 additions & 0 deletions
100
config/plugins/visualizations/drawrna/src/drawrnajs/layouts/naview/connection.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
var Loop = require("./loop"); | ||
var Region = require("./region"); | ||
|
||
var Connection = module.exports = function(){ | ||
this.loop = new Loop(); | ||
this.region = new Region(); | ||
// Start and end form the 1st base pair of the region. | ||
this.start = null; | ||
this.end = null; | ||
this.xrad = null; | ||
this.yrad = null; | ||
this.angle = null; | ||
// True if segment between this connection and the | ||
// next must be extruded out of the circle | ||
this.extruded = null; | ||
// True if the extruded segment must be drawn long. | ||
this.broken = null; | ||
|
||
this._isNull = false; | ||
} | ||
|
||
Connection.prototype.isNull = function(){ | ||
return this._isNull; | ||
} | ||
|
||
Connection.prototype.setNull = function(isNull){ | ||
this._isNull = isNull; | ||
} | ||
|
||
Connection.prototype.getLoop = function(){ | ||
return this.loop; | ||
} | ||
|
||
Connection.prototype.setLoop = function(loop) { | ||
this.loop = loop; | ||
} | ||
|
||
Connection.prototype.getRegion = function(){ | ||
return this.region; | ||
} | ||
|
||
Connection.prototype.setRegion = function(region){ | ||
this.region = region; | ||
} | ||
|
||
Connection.prototype.getStart = function(){ | ||
return this.start; | ||
} | ||
|
||
Connection.prototype.setStart = function(start) { | ||
this.start = start; | ||
} | ||
|
||
Connection.prototype.getEnd = function(){ | ||
return this.end; | ||
} | ||
|
||
Connection.prototype.setEnd = function(end){ | ||
this.end = end; | ||
} | ||
|
||
Connection.prototype.getXrad = function(){ | ||
return this.xrad; | ||
} | ||
|
||
Connection.prototype.setXrad = function(xrad){ | ||
this.xrad = xrad; | ||
} | ||
|
||
Connection.prototype.getYrad = function(){ | ||
return this.yrad; | ||
} | ||
|
||
Connection.prototype.setYrad = function(yrad) { | ||
this.yrad = yrad; | ||
} | ||
|
||
Connection.prototype.getAngle = function(){ | ||
return this.angle; | ||
} | ||
|
||
Connection.prototype.setAngle = function(angle){ | ||
this.angle = angle; | ||
} | ||
|
||
Connection.prototype.isExtruded = function(){ | ||
return this.extruded; | ||
} | ||
|
||
Connection.prototype.setExtruded = function(extruded){ | ||
this.extruded = extruded; | ||
} | ||
|
||
Connection.prototype.isBroken = function(){ | ||
return this.broken; | ||
} | ||
|
||
Connection.prototype.setBroken = function(broken){ | ||
this.broken = broken; | ||
} |
44 changes: 44 additions & 0 deletions
44
config/plugins/visualizations/drawrna/src/drawrnajs/layouts/naview/getnaview.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
var NAView = require("./naview"); | ||
|
||
getCoordsNAVIEW = module.exports = function(nodes, links){ | ||
//Calculates coordinates according to the NAView layout | ||
var pairTable = []; | ||
|
||
for(var i=0; i<nodes.length; i++){ | ||
pairTable.push(getPartner(i, links)); | ||
} | ||
var naView = new NAView(); | ||
var xy = naView.naview_xy_coordinates(pairTable); | ||
|
||
// Updating individual base positions | ||
var coords = [] | ||
for (var i = 0; i < nodes.length; i++) { | ||
coords.push({ | ||
x: Math.round(xy.x[i] * 2.5), | ||
y: Math.round(xy.y[i] * 2.5) | ||
}); | ||
} | ||
return coords; | ||
} | ||
|
||
function getPartner(srcIndex, links){ | ||
//Returns the partner of a nucleotide: | ||
//-1 means there is no partner | ||
var partner = -1; | ||
for(var i = 0; i < links.length; i++){ | ||
if(links[i].type !== "phosphodiester" && links[i].type !== "index"){ | ||
if(links[i].source === srcIndex){ | ||
partner = links[i].target; | ||
break; | ||
} | ||
else if(links[i].target === srcIndex){ | ||
partner = links[i].source; | ||
break; | ||
} | ||
else { | ||
continue; | ||
} | ||
} | ||
} | ||
return partner; | ||
} |
98 changes: 98 additions & 0 deletions
98
config/plugins/visualizations/drawrna/src/drawrnajs/layouts/naview/loop.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
var Loop = module.exports = function(){ | ||
this.nconnection = null; | ||
this.connections = []; | ||
this._connections = []; | ||
this.number = null; | ||
this.depth = null; | ||
this.mark = null; | ||
this.x = null; | ||
this.y = null; | ||
this.radius = null; | ||
} | ||
|
||
Loop.prototype.getNconnection = function() { | ||
return this.nconnection; | ||
} | ||
|
||
Loop.prototype.setNconnection = function(nconnection) { | ||
this.nconnection = nconnection; | ||
} | ||
|
||
Loop.prototype.setConnection = function(i, c){ | ||
var Connection = require("./connection"); | ||
if (c != null){ | ||
this._connections[i] = c; | ||
} | ||
else { | ||
if (!this._connections[i]){ | ||
this._connections[i] = new Connection(); | ||
} | ||
this._connections[i].setNull(true); | ||
} | ||
} | ||
|
||
Loop.prototype.getConnection = function(i){ | ||
var Connection = require("./connection"); | ||
if (!this._connections[i]){ | ||
this._connections[i] = new Connection(); | ||
} | ||
var c = this._connections[i]; | ||
if (c.isNull()){ | ||
return null; | ||
} | ||
else { | ||
return c; | ||
} | ||
} | ||
|
||
Loop.prototype.addConnection = function(i, c){ | ||
this._connections.push(c); | ||
} | ||
|
||
Loop.prototype.getNumber = function(){ | ||
return this.number; | ||
} | ||
|
||
Loop.prototype.setNumber = function(number){ | ||
this.number = number; | ||
} | ||
|
||
Loop.prototype.getDepth = function(){ | ||
return this.depth; | ||
} | ||
|
||
Loop.prototype.setDepth = function(depth){ | ||
this.depth = depth; | ||
} | ||
|
||
Loop.prototype.isMark = function(){ | ||
return this.mark; | ||
} | ||
|
||
Loop.prototype.setMark = function(mark){ | ||
this.mark = mark; | ||
} | ||
|
||
Loop.prototype.getX = function(){ | ||
return this.x; | ||
} | ||
|
||
Loop.prototype.setX = function(x){ | ||
this.x = x; | ||
} | ||
|
||
Loop.prototype.getY = function(){ | ||
return this.y; | ||
} | ||
|
||
Loop.prototype.setY = function(y){ | ||
this.y = y; | ||
} | ||
|
||
Loop.prototype.getRadius = function(){ | ||
return this.radius; | ||
} | ||
|
||
Loop.prototype.setRadius = function(radius){ | ||
this.radius = radius; | ||
} |
Oops, something went wrong.