Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:FelixAkk/synthbio

  • Loading branch information...
commit c0858a397a1e1e3dd0aaf85ee75c584797607c58 2 parents 9dd38a9 + 33fdcb6
@nielsAD nielsAD authored
View
6 README.md
@@ -1,3 +1,5 @@
-Synthetic Biology project (group 5/E, TU Delft, 2012)
+# Zelula - Synthetic Biology project (group E, TU Delft, 2012)
-The aim of `synthbio` is develop a modeling and simulation package for BioBricks. Developers IRC channel: <a href="irc://#synthbio@irc.freenode.net">#synthbio@irc.freenode.net</a>.
+The aim of `synthbio` is develop a modeling and simulation package for BioBricks.
+
+Developers IRC channel: <a href="irc://#synthbio@irc.freenode.net">#synthbio@irc.freenode.net</a>.
View
BIN  deliverables/scrumplan-1/scrumplan-1.pdf
Binary file not shown
View
2  deliverables/scrumplan-1/scrumplan-1.tex
@@ -3,7 +3,7 @@
\input{../scrumplan-common}
-\title{Project title Zelula - SCRUM plan \#1}
+\title{Project Zelula - SCRUM plan \#1}
\author{Group 5/E:\\
Felix Akkermans \\
View
BIN  deliverables/scrumplan-2/scrumplan-2.pdf
Binary file not shown
View
2  deliverables/scrumplan-2/scrumplan-2.tex
@@ -2,7 +2,7 @@
\input{../scrumplan-common}
-\title{Programming Life - SCRUM plan \#2}
+\title{Project Zelula - SCRUM plan \#2}
\author{Group 5/E:\\
Felix Akkermans \\
View
0  ...INF/src/synthbio/simulator/test/SBMLsimulator.jar → program/WEB-INF/lib/SBMLsimulator.jar
File renamed without changes
View
24 program/WEB-INF/src/synthbio/models/Circuit.java
@@ -7,6 +7,8 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
@@ -201,10 +203,8 @@ public static Circuit fromJSON(JSONObject json) throws Exception {
int from;
int to;
- //todo: this is a simplified and incorrect way to do it, since
- //it coveres only the in-order cases.
- //a Map<int, String> should be used as tmp variable.
- String tmpTF="";
+ //remember the first transcription factor for a And-gate.
+ Map<Integer, String> tmpTF=new HashMap<Integer, String>();
for(int i=0; i<JSONSignals.length(); i++){
signal=JSONSignals.getJSONObject(i);
@@ -225,10 +225,10 @@ public static Circuit fromJSON(JSONObject json) throws Exception {
//this is not the first connection from gate 'from'
//check if this signal protein is the same as
//already present, if not, throw an exception.
-
- //todo: implement the check.
+ if(!ret.gateAt(from).getCDS().getName().equals(signal.getString("protein"))){
+ throw new Exception("CDS for gate "+from+" is ambigious");
+ }
}
-
}else{
//input signal, nothing to do at the input side.
}
@@ -247,22 +247,24 @@ public static Circuit fromJSON(JSONObject json) throws Exception {
);
}else{
//and gate, requires two inputs, so wait till whe have two.
- if(tmpTF==""){
- tmpTF=signal.getString("protein");
+ if(!tmpTF.containsKey(to)){
+ tmpTF.put(to, signal.getString("protein"));
}else{
ret.gateAt(to).setPromotor(
- bbr.getAndPromotor(signal.getString("protein"), tmpTF)
+ bbr.getAndPromotor(signal.getString("protein"), tmpTF.get(to))
);
- tmpTF="";
+ tmpTF.remove(to);
}
}
}else{
//output signal, nothing to do at the output.
}
}
+/*
if(tmpTF!=""){
throw new Exception("And gate with one input");
}
+*/
return ret;
}
View
4 program/WEB-INF/src/synthbio/models/test/TestCircuit.java
@@ -53,6 +53,10 @@ public void testFromJSON() throws Exception{
assertEquals(2, c.getGates().size());
//assertEquals(4, c.collectSignals().size());
+
+ assertEquals("[and(A,B)->C @(2.0,2.0)]", c.gateAt(0).toString());
+ assertEquals("[not(C)->D @(2.0,4.0)]", c.gateAt(1).toString());
+
}
}
View
68 program/WEB-INF/src/synthbio/servlets/CircuitServlet.java
@@ -0,0 +1,68 @@
+/**
+ * Synthetic Biology project (Biobrick Modeller/Simulator)
+ * https://github.com/FelixAkk/synthbio
+ */
+
+package synthbio.servlets;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+import synthbio.json.JSONResponse;
+import synthbio.files.BioBrickReader;
+import synthbio.models.CDS;
+
+
+/**
+ * Servlet ListServlets returns a default JSON-reply with a list of
+ * proteins available.
+ *
+ * @author jieter
+ */
+public class CircuitServlet extends SynthbioServlet {
+
+ @Override
+ public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
+
+ response.setContentType("text/plain");
+ PrintWriter out = response.getWriter();
+
+ JSONResponse json=new JSONResponse();
+
+ /* Try to load the BioBrick Repository
+ */
+ BioBrickReader bbr;
+ try{
+ bbr=this.getBioBrickReaderRepository();
+ }catch(Exception e){
+ json.success=false;
+ json.message="Could not load BioBricks: "+e.getMessage();
+ out.println(json.toJSONString());
+ return;
+ }
+
+ /* Dispatch actions.
+ */
+ String action=request.getParameter("action");
+ if(action.equals("load")){
+
+ }else if(action.equals("save")){
+
+ }else if(action.equals("validate")){
+
+ }else{
+ json.success=false;
+ json.message="Invalid Action";
+ }
+
+ /* Send response to browser.
+ */
+ out.println(json.toJSONString());
+ }
+}
View
6 ...m/WEB-INF/src/synthbio/servlets/ListProteins.java → ...NF/src/synthbio/servlets/ListProteinsServlet.java
@@ -25,7 +25,7 @@
*
* @author jieter
*/
-public class ListProteins extends HttpServlet {
+public class ListProteinsServlet extends SynthbioServlet {
@Override
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException {
@@ -33,11 +33,9 @@ public void doGet(HttpServletRequest request, HttpServletResponse response) thro
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
- String path=this.getServletContext().getRealPath("/")+"WEB-INF/biobricks/";
-
JSONResponse json=new JSONResponse();
try{
- json.data=new BioBrickReader(path).getCDSs();
+ json.data=this.getBioBrickReaderRepository().getCDSs();
json.success=true;
}catch(Exception e){
View
39 program/WEB-INF/src/synthbio/servlets/SynthbioServlet.java
@@ -0,0 +1,39 @@
+/**
+ * Synthetic Biology project (Biobrick Modeller/Simulator)
+ * https://github.com/FelixAkk/synthbio
+ */
+
+package synthbio.servlets;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+import synthbio.json.JSONResponse;
+import synthbio.files.BioBrickReader;
+import synthbio.models.CDS;
+
+
+/**
+ * Synthbio abstract servlet containing shared functionality.
+ *
+ * @author jieter
+ */
+public abstract class SynthbioServlet extends HttpServlet {
+
+
+ /**
+ * Return the BioBrick repository.
+ *
+ * @return A BioBrickReader object.
+ */
+ public BioBrickReader getBioBrickReaderRepository() throws Exception{
+ String path=this.getServletContext().getRealPath("/")+"WEB-INF/biobricks/";
+ return new BioBrickReader(path);
+ }
+}
View
30 program/WEB-INF/src/synthbio/simulator/SolverInterface.java
@@ -13,32 +13,38 @@
* The SBML solver used is SBMLsimulator: http://sourceforge.net/projects/sbml-simulator/
*/
public class SolverInterface {
- private final String SBMLSIMULATOR_PATH = "/SBMLsimulator.jar";
- private String result;
+ private final String SBMLSIMULATOR_PATH = "lib/SBMLsimulator.jar";
- public SolverInterface solve(String file) {
+ /**
+ * Takes a sbml file, a time series file (csv), a sbml file (for output of optimized sbml) and a result file (csv) and solves it.
+ * Returns commandline output
+ */
+ public String solve(String sbmlIn, String timeIn, String sbmlOut, String results) {
+ String res = "ERROR";
try {
Runtime rt = Runtime.getRuntime();
- Process pr = rt.exec("java -jar \""+SBLMSIMULATOR_PATH+"\" --sbml-input-file \""+file+"\"");
+ Process pr = rt.exec(
+ "java -jar \""+SBMLSIMULATOR_PATH+
+ "\" --sbml-input-file \""+sbmlIn+
+ "\" --time-series-file \""+timeIn+
+ "\" --sbml-output-file \""+sbmlOut+
+ "\" --simulation-output-file \""+results+"\""
+ );
+
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
- String res = "";
+ res = "";
String line = null;
while((line = input.readLine()) != null) {
res += line + "\n";
}
-
+
int exitVal = pr.waitFor();
-
- result = res;
} catch(Exception e) {
System.out.println(e.toString());
e.printStackTrace();
}
- }
-
- public String getStringResult() {
- return result;
+ return res;
}
}
View
BIN  program/WEB-INF/src/synthbio/simulator/test/Hello.jar
Binary file not shown
View
14 program/WEB-INF/src/synthbio/simulator/test/TestCommandLineCatchOutput.java
@@ -18,15 +18,23 @@
* Runs a command line program and catches the output.
*
*/
- @Test @Ignore
+ @Test
public void testCommandline() {
try {
Runtime rt = Runtime.getRuntime();
- Process pr = rt.exec("helloworld.exe");
+ Process pr = rt.exec("java -jar \"src/synthbio/simulator/test/Hello.jar\"");
BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
- assertEquals("Hello world!", input.readLine());
+ String res = "";
+ String line = null;
+ while((line = input.readLine()) != null) {
+ res += line + "\n";
+ }
+
+ int exitVal = pr.waitFor();
+
+ assertEquals("Hello\n", res);
} catch(Exception e) {
System.out.println(e.toString());
e.printStackTrace();
View
8 program/WEB-INF/src/synthbio/simulator/test/TestSolverInterface.java
@@ -16,14 +16,14 @@
* Testing the execution of the solver and catching the results.
*/
public class TestSolverInterface {
-
+ private final String TEST_PATH = "src/synthbio/simulator/test/";
/**
* Runs the solver and catches the output.
*/
- @Test
+ @Test @Ignore
public void testSolver() {
SolverInterface si = new SolverInterface();
- String result = si.solve("test.sbml").getStringResult;
- assertEquals("", result);
+ String res = si.solve(TEST_PATH+"test2.sbml", TEST_PATH+"test2-time.csv", TEST_PATH+"test2-opt.sbml", TEST_PATH+"test2-output.csv");
+ System.out.println(res);
}
}
View
BIN  program/WEB-INF/src/synthbio/simulator/test/helloworld.exe
Binary file not shown
View
2  program/css/style.less
@@ -204,6 +204,7 @@ body {
.gate:hover {
background-color: rgba(255,255,255, 0.15);
+ cursor: pointer;
}
.gate img {
@@ -220,6 +221,7 @@ body {
bottom: @statusHeight;
background-color: lighten(@baseColor, 20%);
background-image: url('../img/grid.png');
+ overflow: auto;
box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.25);
/*.borderDown(@baseColor, @contrast, 10%); */
View
11 program/js/requests.js
@@ -32,7 +32,9 @@ synthbio.requests.baseURL = "";
*/
synthbio.requests.baseXHR = function(provided){
var options={
- dataType: "json"
+ dataType: "json",
+ error: function(){},
+ always: function(){}
}
//merge provided options with the default options.
$.extend(options, provided);
@@ -64,8 +66,7 @@ synthbio.requests.getCDSs = function(callback){
});
return callback(list);
},
- error:
- always:
+
});
};
@@ -85,10 +86,10 @@ synthbio.requests.listFiles = function(callback){
return callback(response.message);
}
return callback(list);
- }
+ },
error: function(){
return callback("Error has occured. Cannot get list of files from server")
- }
+ },
always: callback()
});
Please sign in to comment.
Something went wrong with that request. Please try again.