Skip to content

Commit

Permalink
Merge pull request #68 from hicsail/generate_sbol
Browse files Browse the repository at this point in the history
Generate SBOL 2.2
  • Loading branch information
lucyq committed Jan 18, 2019
2 parents 82e6b21 + 4aca290 commit b240ce3
Show file tree
Hide file tree
Showing 69 changed files with 3,559 additions and 666 deletions.
29 changes: 29 additions & 0 deletions demos/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ let express = require('express');
let app = express();
let path = require('path');
let bodyParser = require('body-parser');
let FormData = require('form-data');
const Readable = require('stream').Readable;
let constellation = require('../lib/constellation');

app.use(bodyParser.json());
Expand Down Expand Up @@ -50,3 +52,30 @@ app.post('/postSpecs', function(req,res) {
res.status(405).send(String(error));
}
});

app.post('/sendToKnox', function(req,res) {

let form = new FormData();
let sbolDocs = JSON.parse(req.body['sbolDocs[]']);

for(let sbol of sbolDocs){
let stream = new Readable();
stream.push(sbol);
stream.push(null);
form.append('inputSBOLFiles[]', stream, {
filename : 'test.xml',
contentType: 'application/xml',
knownLength: sbol.length
}); //extra fields necessary
}
form.append('outputSpaceID', req.body.designName);

form.submit('http://localhost:8080/sbol/importCombinatorial', function(error, result) {
if (error) {
console.log('Error!');
res.status(405).send(String(error));
} else{
res.status(200).send(String(result));
}
});
});
9 changes: 7 additions & 2 deletions demos/static/client.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<link rel="stylesheet" href="css/theme/solarized.css">
<link rel="stylesheet" href="css/theme/ambiance.css">


<link rel="icon" href="favicon.png" type="image/x-icon" />



<link href="https://fonts.googleapis.com/css?family=Montserrat:200,300" rel="stylesheet">
Expand Down Expand Up @@ -46,7 +47,7 @@ <h3>Constellation</h3>
<br/>
</div>
</div>

<div class="row">
<div class="col-sm">
<col-sm-8>
Expand Down Expand Up @@ -94,6 +95,10 @@ <h3>Constellation</h3>
<br/><br/><br/>
<input id="submitBtn" class="btn" type="button" value="Submit">
</div>
<div class="row">
<br/><br/><br/>
<input id="knoxBtn" class="btn" type="button" value="Store in Knox">
</div>
<br/>
</div>
</body>
Expand Down
9 changes: 8 additions & 1 deletion demos/static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ textarea {
font-size: 20px;
}

#knoxBtn {
margin: auto;
background-color: white;
display: block;
font-size: 20px;
}

h5 {
color: rgb(120, 120, 120);
font-family: 'Montserrat', 'monospace';
Expand Down Expand Up @@ -122,4 +129,4 @@ input[type="button"]{
/* .dropdown:hover .dropdown-content {display: block;} */

/* Change the background color of the dropdown button when the dropdown content is shown */
/* .dropdown:hover .dropbtn {background-color: #30729f;} */
/* .dropdown:hover .dropbtn {background-color: #30729f;} */
Binary file added demos/static/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 25 additions & 7 deletions demos/static/js/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const IMAGESIZE = 30;
const RADIUS = 7;
const INTERMEDIATE = 'intermediate';

let nodePointer, linkPointer, simulationPointer, svgPointer, circlePointer, imagePointer, textPointer, width, height;
let nodePointer, linkPointer, simulationPointer, svgPointer, circlePointer, imagePointer, textPointer, width, height, sbolDocs;
let designName = 'Constellation';

/* * * * * * */
/* DESIGNS */
Expand Down Expand Up @@ -176,9 +177,10 @@ function drawNodes(nodes) {
.append('svg:image')
.attr('xlink:href', function(d) {
switch (d.text) {
case 'ribosomeBindingSite':
case 'promoter':
case 'terminator':
case 'CDS':
case 'cds':
case 'restriction_enzyme_assembly_scar':
case 'restriction_enzyme_recognition_site':
case 'protein_stability_element':
Expand Down Expand Up @@ -367,24 +369,34 @@ $(document).ready(function() {

editors.specEditor.setOption("theme", THEME);
editors.catEditor.setOption("theme", THEME);
editors.catEditor.setValue('{"promoter": ["BBa_R0040", "BBa_J23100"],\n "ribosomeBindingSite": ["BBa_B0032", "BBa_B0034"], \n"cds": ["BBa_E0040", "BBa_E1010"],\n"spacer": ["BBa_F0010"],\n"terminator": ["BBa_B0010"]}');
editors.catEditor.setValue('{"promoter": ["BBa_R0040", "BBa_J23100"],\n "ribosomeBindingSite": ["BBa_B0032", "BBa_B0034"], \n"cds": ["BBa_E0040", "BBa_E1010"],\n"nonCodingRna": ["BBa_F0010"],\n"terminator": ["BBa_B0010"]}');
editors.designsEditor.setOption("theme", THEME);

$('#demo-option').on('click', function() {
editors.specEditor.setValue('one-or-more(one-or-more(promoter then spacer)then cds then \n (zero-or-more \n (spacer or (one-or-more \n (spacer then promoter then spacer) then cds)) then \n (terminator or (terminator then spacer) or (spacer then terminator)))))')
editors.specEditor.setValue('one-or-more(one-or-more(promoter then nonCodingRna)then cds then \n (zero-or-more \n (nonCodingRna or (one-or-more \n (nonCodingRna then promoter then nonCodingRna) then cds)) then \n (terminator or (terminator then nonCodingRna) or (nonCodingRna then terminator)))))')
});


$('#debug-option').on('click', function() {
editors.specEditor.setValue('one-or-more (promoter or ribosomeBindingSite) then (zero-or-more cds) then terminator');
});


$("#knoxBtn").prop("disabled",true);

$('#knoxBtn').on('click', function() {
$.post('http://localhost:8082/sendToKnox', {
'designName': designName,
'sbolDocs[]': JSON.stringify(sbolDocs)})
.fail((response) => {
alert(response.responseText);
});
});


$("#submitBtn").click(function(){
// Reset UI
resetDiagram();
displayDesigns(editors, '');
let designName = 'Constellation';
let maxCycles = 0;
let numDesigns = 10;

Expand Down Expand Up @@ -412,8 +424,14 @@ $(document).ready(function() {
} else {
displayDesigns(editors, JSON.stringify(data.designs, null, "\t"));
}
sbolDocs = data.sbols;
$("#knoxBtn").prop("disabled",false);
}).fail((response) => {
alert(response.responseText);
});
});


});


1 change: 0 additions & 1 deletion demos/static/sbol/CDS.svg

This file was deleted.

1 change: 0 additions & 1 deletion demos/static/sbol/RNA_stability_element.svg

This file was deleted.

18 changes: 18 additions & 0 deletions demos/static/sbol/aptamer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions demos/static/sbol/assemblyScar.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions demos/static/sbol/bluntRestrictionSite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

16 changes: 16 additions & 0 deletions demos/static/sbol/cds.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions demos/static/sbol/dnaStabilityElement.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions demos/static/sbol/engineeredRegion.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions demos/static/sbol/fivePrimeStickyRestrictionSite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

16 changes: 16 additions & 0 deletions demos/static/sbol/halfroundRectangle.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 17 additions & 1 deletion demos/static/sbol/insulator.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions demos/static/sbol/locationDna.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit b240ce3

Please sign in to comment.