Skip to content

Commit 91ae63c

Browse files
committed
Merge branch 'master' into version_control
2 parents 25e4029 + df359df commit 91ae63c

File tree

10 files changed

+160
-95
lines changed

10 files changed

+160
-95
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<dependency>
8080
<groupId>org.sbolstandard</groupId>
8181
<artifactId>libSBOLj</artifactId>
82-
<version>2.3.1</version>
82+
<version>2.4.0</version>
8383
</dependency>
8484

8585
</dependencies>

src/main/java/knox/spring/data/neo4j/controller/KnoxController.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
import java.util.*;
66

77
import knox.spring.data.neo4j.domain.DesignSpace;
8+
import knox.spring.data.neo4j.exception.*;
89
import knox.spring.data.neo4j.sample.DesignSampler.EnumerateType;
9-
import knox.spring.data.neo4j.exception.DesignSpaceBranchesConflictException;
10-
import knox.spring.data.neo4j.exception.DesignSpaceConflictException;
11-
import knox.spring.data.neo4j.exception.DesignSpaceNotFoundException;
12-
import knox.spring.data.neo4j.exception.ParameterEmptyException;
1310
import knox.spring.data.neo4j.sbol.SBOLConversion;
1411
import knox.spring.data.neo4j.services.DesignSpaceService;
1512

@@ -654,7 +651,7 @@ public ResponseEntity<String> importSBOL(@RequestParam("inputSBOLFiles[]") List<
654651

655652
try {
656653
designSpaceService.importSBOL(sbolDocs, outputSpaceID);
657-
} catch (IOException | SBOLValidationException | SBOLConversionException e) {
654+
} catch (IOException | SBOLValidationException | SBOLConversionException | SBOLException e) {
658655
// TODO Auto-generated catch block
659656
e.printStackTrace();
660657
}

src/main/java/knox/spring/data/neo4j/domain/Edge.java

Lines changed: 57 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,14 @@ public class Edge {
3131
ArrayList<String> componentIDs;
3232

3333
ArrayList<String> componentRoles;
34-
35-
String orientation;
34+
35+
Orientation orientation;
3636

3737
double weight;
3838

3939
private static final Logger LOG = LoggerFactory.getLogger(Edge.class);
4040

41-
public Edge() {
42-
43-
}
41+
public Edge() {}
4442

4543
public Edge(Node tail, Node head) {
4644
this.tail = tail;
@@ -51,13 +49,13 @@ public Edge(Node tail, Node head) {
5149

5250
componentRoles = new ArrayList<String>();
5351

54-
orientation = Orientation.NONE.getValue();
52+
orientation = Orientation.NONE;
5553

5654
weight = 1.0;
5755
}
5856

5957
public Edge(Node tail, Node head, ArrayList<String> componentIDs,
60-
ArrayList<String> componentRoles) {
58+
ArrayList<String> componentRoles) {
6159
this.tail = tail;
6260

6361
this.head = head;
@@ -67,16 +65,16 @@ public Edge(Node tail, Node head, ArrayList<String> componentIDs,
6765
this.componentRoles = componentRoles;
6866

6967
if (!this.componentIDs.isEmpty() || !this.componentRoles.isEmpty()) {
70-
orientation = Orientation.INLINE.getValue();
68+
orientation = Orientation.INLINE;
7169
} else {
72-
orientation = Orientation.NONE.getValue();
70+
orientation = Orientation.NONE;
7371
}
7472

7573
weight = 1.0;
7674
}
7775

7876
public Edge(Node tail, Node head, ArrayList<String> componentIDs,
79-
ArrayList<String> componentRoles, String orientation) {
77+
ArrayList<String> componentRoles, Orientation orientation) {
8078
this.tail = tail;
8179

8280
this.head = head;
@@ -88,14 +86,14 @@ public Edge(Node tail, Node head, ArrayList<String> componentIDs,
8886
if (!this.componentIDs.isEmpty() || !this.componentRoles.isEmpty()) {
8987
this.orientation = orientation;
9088
} else {
91-
this.orientation = Orientation.NONE.getValue();
89+
this.orientation = Orientation.NONE;
9290
}
9391

9492
weight = 1.0;
9593
}
9694

9795
public Edge(Node tail, Node head, ArrayList<String> componentIDs,
98-
ArrayList<String> componentRoles, String orientation, double weight) {
96+
ArrayList<String> componentRoles, Orientation orientation, double weight) {
9997
this.tail = tail;
10098

10199
this.head = head;
@@ -107,40 +105,40 @@ public Edge(Node tail, Node head, ArrayList<String> componentIDs,
107105
if (!this.componentIDs.isEmpty() || !this.componentRoles.isEmpty()) {
108106
this.orientation = orientation;
109107
} else {
110-
this.orientation = Orientation.NONE.getValue();
108+
this.orientation = Orientation.NONE;
111109
}
112110

113111
this.weight = weight;
114112
}
115113

116-
public Edge(ArrayList<String> componentIDs, ArrayList<String> componentRoles, String orientation,
117-
double weight) {
114+
public Edge(ArrayList<String> componentIDs, ArrayList<String> componentRoles,
115+
Orientation orientation, double weight) {
118116
this.componentIDs = componentIDs;
119117

120118
this.componentRoles = componentRoles;
121119

122120
if (!this.componentIDs.isEmpty() || !this.componentRoles.isEmpty()) {
123121
this.orientation = orientation;
124122
} else {
125-
this.orientation = Orientation.NONE.getValue();
123+
this.orientation = Orientation.NONE;
126124
}
127125

128126
this.weight = weight;
129127
}
130128

131129
public Edge copy() {
132130
return new Edge(new ArrayList<String>(componentIDs),
133-
new ArrayList<String>(componentRoles), orientation, weight);
131+
new ArrayList<>(componentRoles), orientation, weight);
134132
}
135133

136134
public Edge copy(Node head) {
137135
return new Edge(tail, head, new ArrayList<String>(componentIDs),
138-
new ArrayList<String>(componentRoles), orientation, weight);
136+
new ArrayList<>(componentRoles), orientation, weight);
139137
}
140138

141139
public Edge copy(Node tail, Node head) {
142140
return new Edge(tail, head, new ArrayList<String>(componentIDs),
143-
new ArrayList<String>(componentRoles), orientation, weight);
141+
new ArrayList<>(componentRoles), orientation, weight);
144142
}
145143

146144
public void delete() {
@@ -335,14 +333,6 @@ public boolean hasComponentRoles() {
335333
return componentRoles != null && !componentRoles.isEmpty();
336334
}
337335

338-
public boolean hasOrientation() {
339-
return isInline() || isReverseComplement();
340-
}
341-
342-
public boolean hasOrientation(String orientation) {
343-
return hasOrientation() && this.orientation.equals(orientation);
344-
}
345-
346336
public void intersectWithEdge(Edge edge, int tolerance) {
347337
// Map other component IDs to roles and other component roles to IDs
348338

@@ -503,14 +493,6 @@ public boolean hasSharedComponentRoles(Edge edge, Set<String> roles) {
503493
}
504494
}
505495

506-
public boolean isInline() {
507-
return orientation.equals(Orientation.INLINE.getValue());
508-
}
509-
510-
public boolean isReverseComplement() {
511-
return orientation.equals(Orientation.REVERSE_COMPLEMENT.getValue());
512-
}
513-
514496
public boolean isBlank() {
515497
return !hasComponentIDs() && !hasComponentRoles() && !hasOrientation();
516498
}
@@ -526,10 +508,6 @@ public void setHead(Node head) {
526508
public void setTail(Node tail) {
527509
this.tail = tail;
528510
}
529-
530-
public String getOrientation() {
531-
return orientation;
532-
}
533511

534512
public void setWeight(double weight) {
535513
this.weight = weight;
@@ -547,20 +525,56 @@ public String toString() {
547525
}
548526

549527
}
550-
528+
551529
public enum Orientation {
552530
INLINE("inline"),
553531
REVERSE_COMPLEMENT("reverseComplement"),
532+
UNDECLARED("undeclared"), //means it can be inline or reverse
554533
NONE("none");
555534

556535
private final String value;
557-
558-
Orientation(String value) {
536+
537+
Orientation(String value) {
559538
this.value = value;
560539
}
561540

562541
public String getValue() {
563-
return value;
542+
return value;
543+
}
544+
}
545+
546+
public Orientation getOrientation() {
547+
return orientation;
548+
}
549+
550+
public void setOrientation(Orientation orientation){
551+
this.orientation = orientation;
552+
}
553+
554+
public boolean hasOrientation() {
555+
return isInline() || isReverseComplement();
556+
}
557+
558+
559+
public boolean hasOrientation(Orientation orientation) {
560+
return hasOrientation() && this.orientation.equals(orientation);
561+
}
562+
563+
public boolean isInline() {
564+
return orientation.equals(Orientation.INLINE);
565+
}
566+
567+
public boolean isReverseComplement() {
568+
return orientation.equals(Orientation.REVERSE_COMPLEMENT);
569+
}
570+
571+
public void reverseOrientation(){
572+
if(isInline()){
573+
setOrientation(Orientation.REVERSE_COMPLEMENT);
574+
}
575+
576+
else if(isReverseComplement()){
577+
setOrientation(Orientation.INLINE);
564578
}
565579
}
566580
}

src/main/java/knox/spring/data/neo4j/domain/Node.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public Edge copyEdge(Edge edge) {
8080

8181
public Edge copyEdge(Edge edge, Node head) {
8282
return createEdge(head, new ArrayList<String>(edge.getComponentIDs()),
83-
new ArrayList<String>(edge.getComponentRoles()), edge.getOrientation());
83+
new ArrayList<>(edge.getComponentRoles()), edge.getOrientation());
8484
}
8585

8686
public Edge createEdge(Node head) {
@@ -100,7 +100,7 @@ public Edge createEdge(Node head, ArrayList<String> compIDs, ArrayList<String> c
100100
}
101101

102102
public Edge createEdge(Node head, ArrayList<String> compIDs, ArrayList<String> compRoles,
103-
String orientation) {
103+
Edge.Orientation orientation) {
104104
Edge edge = new Edge(this, head, compIDs, compRoles, orientation);
105105

106106
addEdge(edge);
@@ -278,7 +278,7 @@ public Set<Edge> getEdges(Node head) {
278278
return edgesWithHead;
279279
}
280280

281-
public Set<Edge> getEdges(String orientation) {
281+
public Set<Edge> getEdges(Edge.Orientation orientation) {
282282
Set<Edge> edgesWithHead = new HashSet<Edge>();
283283

284284
if (hasEdges()) {
@@ -377,7 +377,7 @@ public void mergeEdges() {
377377

378378
for (Edge edge : edges) {
379379
if (!edge.isBlank()) {
380-
String code = edge.getHeadID() + edge.getOrientation();
380+
String code = edge.getHeadID() + edge.getOrientation().getValue();
381381

382382
if (!codeToIncomingEdges.containsKey(code)) {
383383
codeToIncomingEdges.put(code, new HashSet<Edge>());
@@ -388,7 +388,7 @@ public void mergeEdges() {
388388
List<List<Edge>> blankPaths = edge.getOrthogonalBlankPaths();
389389

390390
for (List<Edge> blankPath : blankPaths) {
391-
String code = blankPath.get(blankPath.size() - 1).getHead().getNodeID() + edge.getOrientation();
391+
String code = blankPath.get(blankPath.size() - 1).getHead().getNodeID() + edge.getOrientation().getValue();
392392

393393
if (!codeToIncomingPaths.containsKey(code)) {
394394
codeToIncomingPaths.put(code, new HashSet<List<Edge>>());

src/main/java/knox/spring/data/neo4j/domain/NodeSpace.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@ public NodeSpace(ArrayList<String> componentIDs, ArrayList<String> componentRole
5353

5454
startNode.createEdge(acceptNode, componentIDs, componentRoles);
5555
}
56+
57+
public NodeSpace(ArrayList<String> componentIDs, ArrayList<String> componentRoles, Edge.Orientation orientation) {
58+
this(0);
59+
60+
Node startNode = createStartNode();
61+
62+
Node acceptNode = createAcceptNode();
63+
64+
startNode.createEdge(acceptNode, componentIDs, componentRoles, orientation);
65+
}
5666

5767
public void addNode(Node node) {
5868
if (nodes == null) {
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package knox.spring.data.neo4j.exception;
2+
3+
public class SBOLException extends RuntimeException{
4+
private static final long serialVersionUID = 462532991641214656L;
5+
6+
private String message;
7+
8+
public SBOLException(String message) {
9+
this.message = message;
10+
}
11+
}

src/main/java/knox/spring/data/neo4j/repositories/DesignSpaceRepository.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ Set<Branch> findBranch(@Param("targetSpaceID") String targetSpaceID,
115115
+ "WHERE target.spaceID = {targetSpaceID} "
116116
+
117117
"RETURN target.spaceID as spaceID, m.nodeID as tailID, m.nodeTypes as tailTypes, e.componentRoles as componentRoles, "
118-
+ "e.componentIDs as componentIDs, n.nodeID as headID, n.nodeTypes as headTypes")
118+
+ "e.componentIDs as componentIDs, e.orientation as orientation, n.nodeID as headID, n.nodeTypes as headTypes")
119119
List<Map<String, Object>> mapDesignSpace(@Param("targetSpaceID") String targetSpaceID);
120120

121121
@Query("MATCH (n:DesignSpace) RETURN n.spaceID;")

src/main/java/knox/spring/data/neo4j/sample/DesignSampler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ private List<List<Map<String, Object>>> multiplyDesigns(List<List<Map<String, Ob
238238

239239
comp.put("roles", edge.getComponentRoles());
240240

241-
comp.put("orientation", edge.getOrientation());
241+
// comp.put("orientation", edge.getOrientation());
242+
comp.put("orientation", edge.getOrientation().getValue()); //does this need to be string?
242243

243244
if (!designs.isEmpty()) {
244245
for (List<Map<String, Object>> design : designs) {

0 commit comments

Comments
 (0)