Permalink
Browse files

Two additional tests, fixed the jsonModels for them; remove unused Si…

…gnal class
  • Loading branch information...
1 parent 065cc68 commit f7029f3e9f7237f53874405857713abc3780b83b @jieter jieter committed Apr 27, 2012
@@ -275,5 +275,11 @@ public static Circuit fromJSON(JSONObject json) throws Exception {
return ret;
}
-
+ public String toString(){
+ String ret="Circuit: "+this.getName()+" | "+this.getDescription()+"\n";
+ for(Gate g: this.getGates()){
+ ret+=g.toString()+"\n";
+ }
+ return ret;
+ }
}
@@ -1,79 +0,0 @@
-/**
- * Project Zelula
- *
- * Contextproject TI2800
- * TU Delft - University of Technology
- *
- * Authors:
- * Felix Akkermans, Niels Doekemeijer, Thomas van Helden
- * Albert ten Napel, Jan Pieter Waagmeester
- *
- * https://github.com/FelixAkk/synthbio
- */
-
-package synthbio.models;
-
-
-
-
-/**
- * Signal representation
- * @author jieter
- */
-public class Signal{
-
- /**
- * References to Gates from and to this Signal flows.
- *
- * If from is null, the signal is an input of the circuit.
- * If to is null, the signal is an output of the circuit.
- */
- private Gate from;
- private Gate to;
-
- /**
- * Protein representing this Signal.
- *
- * CDS could be used here aswell, but biologically it does not make
- * sense since the signal is not the Coding Sequence, but just the
- * protein which is producing it.
- * It could also be derived from the CDS of this.from, but since
- * the Signal object acts mainly as a bridge between the JSON
- * representation and the Circuit model, we'll use an explicit field
- * anyway.
- */
- private String protein;
-
- public Signal(Gate from, Gate to, String protein){
- this.setFrom(from);
- this.setTo(to);
-
- this.setProtein(protein);
- }
-
- /*
- * Getters
- */
- public Gate getFrom(){
- return this.from;
- }
- public Gate getTo(){
- return this.to;
- }
- public String protein(){
- return this.protein;
- }
-
- /*
- * Setters
- */
- public void setFrom(Gate from){
- this.from=from;
- }
- public void setTo(Gate to){
- this.to=to;
- }
- public void setProtein(String protein){
- this.protein=protein;
- }
-}
@@ -46,8 +46,11 @@ public void testConstructor2(){
assertEquals(new ArrayList<Gate>(), c.getGates());
}
+ /**
+ * Test some example circuits
+ */
@Test
- public void testFromJSON() throws Exception{
+ public void testFromJSON1() throws Exception{
String json=Util.fileToString("src/synthbio/models/test/exampleCircuit.json");
Circuit c=Circuit.fromJSON(json);
@@ -60,7 +63,36 @@ public void testFromJSON() throws Exception{
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());
+ }
+
+ @Test
+ public void testFromJSON2() throws Exception{
+ String json=Util.fileToString("src/synthbio/models/test/exampleCircuit2.json");
+ Circuit c=Circuit.fromJSON(json);
+
+ assertEquals("example2.syn", c.getName());
+ assertEquals("Another example G=(A^B^C^D)", c.getDescription());
+
+ assertEquals(3, c.getGates().size());
+
+ assertEquals("[and(A,B)->E @(2.0,2.0)]", c.gateAt(0).toString());
+ assertEquals("[and(C,D)->F @(2.0,4.0)]", c.gateAt(1).toString());
+ assertEquals("[and(E,F)->G @(4.0,3.0)]", c.gateAt(2).toString());
+ }
+ @Test
+ public void testFromJSON3() throws Exception{
+ String json=Util.fileToString("src/synthbio/models/test/exampleCircuit3.json");
+ Circuit c=Circuit.fromJSON(json);
+
+ assertEquals("example3.syn", c.getName());
+ assertEquals("Another example H=(~(A^B))^(C^D)", c.getDescription());
+
+ assertEquals(4, c.getGates().size());
+ assertEquals("[and(A,B)->E @(2.0,2.0)]", c.gateAt(0).toString());
+ assertEquals("[and(C,D)->F @(2.0,4.0)]", c.gateAt(1).toString());
+ assertEquals("[and(F,G)->H @(4.0,3.0)]", c.gateAt(2).toString());
+ assertEquals("[not(E)->G @(5.0,5.0)]", c.gateAt(3).toString());
}
}
@@ -10,12 +10,12 @@
{ "from": "input", "to": 0, "protein": "A"},
{ "from": "input", "to": 0, "protein": "B"},
{ "from": "input", "to": 1, "protein": "C"},
- { "from": "input", "to": 2, "protein": "D"},
+ { "from": "input", "to": 1, "protein": "D"},
{ "from": 0, "to": 2, "protein": "E"},
{ "from": 1, "to": 2, "protein": "F"},
{ "from": 2, "to": 'output', "protein": "G"}
],
"grouping": [
]
-}
+}
@@ -8,16 +8,19 @@
{ "kind": "not", "position": {"x": 5,"y": 5}}
],
"signals": [
- { "from": "input", "to": 0, "protein": "A"},
- { "from": "input", "to": 0, "protein": "B"},
- { "from": 0, "to": 3, "protein" "E"}
- { "from": "input", "to": 1, "protein": "C"},
- { "from": "input", "to": 2, "protein": "D"},
- { "from": 1, "to": 2, "protein": "F"},
- { "from": 2, "to": 3, "protein": "G"},
- { "from": 3, "to": 'output', "protein": "H"}
+ { "from": "input", "to": 0, "protein": "A"},
+ { "from": "input", "to": 0, "protein": "B"},
+ { "from": "input", "to": 1, "protein": "C"},
+ { "from": "input", "to": 1, "protein": "D"},
+
+ { "from": 0, "to": 3, "protein": "E"},
+
+ { "from": 1, "to": 2, "protein": "F"},
+ { "from": 3, "to": 2, "protein": "G"},
+
+ { "from": 2, "to": "output", "protein": "H"}
],
"grouping": [
]
-}
+}

2 comments on commit f7029f3

Collaborator

nielsAD replied Apr 27, 2012

Building Circuit.java fails now, because it requires the Signal class (line 135: collectSignals).

Collaborator

jieter replied Apr 27, 2012

Quick fix applied.

Please sign in to comment.