Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .settings/org.eclipse.wst.common.project.facet.core.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v8.0"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.utility" version="1.0"/>
</faceted-project>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<groupId>de.uni-rostock.sbi</groupId>
<artifactId>BiVeS-Core</artifactId>
<packaging>jar</packaging>
<version>1.9.5</version>
<version>1.9.8</version>
<name>BiVeS-Core</name>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public String translate (ReactionNetwork rn)
//add compartments
for (ReactionNetworkCompartment c : rn.getCompartments ()){
String path = getPath(c.getA(), c.getB(), c.getModification());
addCompartment(c.getId(), "null", c.getLabel(), c.getModification(), "SBO:0000290", path);
addCompartment(c.getId(), c.getOutsideCompartment(), c.getLabel(), c.getModification(), "SBO:0000290", path);
}

//add species
Expand Down Expand Up @@ -238,6 +238,35 @@ public String translate (ReactionNetwork rn)

String rPath = getPath(r.getA(), r.getB(), r.getModification());

//handle phenotypes
// no process node
// one or more modulation arcs
if (outputs.size() == 1) {
Collection<ReactionNetworkSubstanceRef> outs = outputs;
ReactionNetworkSubstanceRef o = outs.iterator().next();

String sbo = "";
if(o.getSubstance().getB() != null) {
if(o.getSubstance().getB().getAttributeValue("sboTerm") != null)
sbo = o.getSubstance().getB().getAttributeValue("sboTerm");
} else if (o.getSubstance().getA() != null) {
if(o.getSubstance().getA().getAttributeValue("sboTerm") != null)
sbo = o.getSubstance().getA().getAttributeValue("sboTerm");
}


if(sbo.equals("SBO:0000358")) {
for(ReactionNetworkSubstanceRef i : inputs) {
//allways nec. stim.
addEdge(i.getSubstance().getId(), o.getSubstance().getId(), "SBO:0000171", i.getModification(), i.getXPath());
}
continue;

}


}

//add process Node
String processId = r.getId();
String compartmentId = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public class ReactionNetworkCompartment
* @param labelB the label of that compartment in the modified document
* @param docA the original document
* @param docB the modified document
* @param outisdeA the compartment id of the containing compartment in the original document
* @param outisdeB the compartment id of the containing compartment in the modified document
*/
public ReactionNetworkCompartment (ReactionNetwork rn, String labelA, String labelB, DocumentNode docA, DocumentNode docB)
public ReactionNetworkCompartment (ReactionNetwork rn, String labelA, String labelB, DocumentNode docA, DocumentNode docB, ReactionNetworkCompartment outsideA, ReactionNetworkCompartment outsideB)
{
super ("c" + rn.getNextCompartmentID (), labelA, labelB, docA, docB);
super ("c" + rn.getNextCompartmentID (), labelA, labelB, docA, docB, outsideA, outsideB);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ public abstract class ReactionNetworkEntity
/** The single doc flag if in single-doc-operation-mode. */
protected boolean singleDoc;

/** Id of the containing compartment in original document **/
protected ReactionNetworkCompartment outsideA;

/** Id of the containing compartment in original document **/
protected ReactionNetworkCompartment outsideB;

/**
* Instantiates a new entity.
*
Expand All @@ -40,15 +46,19 @@ public abstract class ReactionNetworkEntity
* @param labelB the label of that entity in the modified document
* @param docA the original document
* @param docB the modified document
* @param compartmentB
* @param compartmentA
*/
public ReactionNetworkEntity (String entityId, String labelA, String labelB, DocumentNode docA, DocumentNode docB)
public ReactionNetworkEntity (String entityId, String labelA, String labelB, DocumentNode docA, DocumentNode docB, ReactionNetworkCompartment compartmentA, ReactionNetworkCompartment compartmentB)
{
this.id = entityId;
this.labelA = labelA;
this.labelB = labelB;
this.docA = docA;
this.docB = docB;
singleDoc = false;
this.outsideA = compartmentA;
this.outsideB = compartmentB;
}

/**
Expand Down Expand Up @@ -91,6 +101,16 @@ public void setLabelB (String labelB)
this.labelB = labelB;
}

public void setOutsideA(ReactionNetworkCompartment compartmentA) {
this.outsideA = compartmentA;

}

public void setOutsideB(ReactionNetworkCompartment compartmentB) {
this.outsideB = compartmentB;
}


/**
* Gets the original document node.
*
Expand Down Expand Up @@ -157,6 +177,20 @@ public int getModification ()
return MODIFIED;
return UNMODIFIED;
}

public String getOutsideCompartment() {
if(outsideA == outsideB) {
if(outsideA == null) return null;
return outsideB.getId();
}
if(outsideA != null && outsideB != null)
return outsideB.getId();
if(outsideA == null && outsideB != null)
return outsideB.getId();
if(outsideA != null)
return outsideA.getId();
return null;
}

/**
* Sets the single document flag.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class ReactionNetworkReaction
*/
public ReactionNetworkReaction (ReactionNetwork rn, String labelA, String labelB, DocumentNode docA, DocumentNode docB, ReactionNetworkCompartment compartmentA, ReactionNetworkCompartment compartmentB, boolean reversible)
{
super ("r" + rn.getNextReactionID (), labelA, labelB, docA, docB);
super ("r" + rn.getNextReactionID (), labelA, labelB, docA, docB, compartmentA, compartmentB);
in = new HashMap<ReactionNetworkSubstance, ReactionNetworkSubstanceRef> ();
out = new HashMap<ReactionNetworkSubstance, ReactionNetworkSubstanceRef> ();
mod = new Vector<ReactionNetworkSubstanceRef> ();
Expand Down Expand Up @@ -213,17 +213,19 @@ public void addModA (ReactionNetworkSubstance subst, SBOTerm sbo, String xPath)
*
* @param subst the substance
* @param sbo the SBOTerm describing the interaction
* @throws BivesUnsupportedException when SBO terms don't match
*/
public void addInputB (ReactionNetworkSubstance subst, SBOTerm sbo, String xPath)
public void addInputB (ReactionNetworkSubstance subst, SBOTerm sbo, String xPath) throws BivesUnsupportedException
{
ReactionNetworkSubstanceRef r = in.get (subst);
if (r == null)
try{
in.put (subst, new ReactionNetworkSubstanceRef (subst, false, true, null, sbo, xPath)); //checken
in.put (subst, new ReactionNetworkSubstanceRef (subst, false, true, null, sbo, xPath));
}catch (BivesUnsupportedException e){}
else
{
r.setFlagB (true);
r.setSboB(sbo);
}
}

Expand All @@ -232,8 +234,9 @@ public void addInputB (ReactionNetworkSubstance subst, SBOTerm sbo, String xPath
*
* @param subst the substance
* @param sbo the SBOTerm describing the interaction
* @throws BivesUnsupportedException when sbo terms don't match
*/
public void addOutputB (ReactionNetworkSubstance subst, SBOTerm sbo, String xPath)
public void addOutputB (ReactionNetworkSubstance subst, SBOTerm sbo, String xPath) throws BivesUnsupportedException
{
ReactionNetworkSubstanceRef r = out.get (subst);
if (r == null)
Expand All @@ -243,6 +246,7 @@ public void addOutputB (ReactionNetworkSubstance subst, SBOTerm sbo, String xPat
else
{
r.setFlagB (true);
r.setSboB(sbo);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ReactionNetworkSubstance
*/
public ReactionNetworkSubstance (ReactionNetwork rn, String labelA, String labelB, DocumentNode docA, DocumentNode docB, ReactionNetworkCompartment compartmentA, ReactionNetworkCompartment compartmentB)
{
super ("s" + rn.getNextSubstanceID (), labelA, labelB, docA, docB);
super ("s" + rn.getNextSubstanceID (), labelA, labelB, docA, docB, compartmentA, compartmentB);
this.compartmentA = compartmentA;
this.compartmentB = compartmentB;
singleDoc = false;
Expand Down
66 changes: 55 additions & 11 deletions src/test/java/de/unirostock/sems/bives/TestGraphs.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ public ReactionNetworkCompartment addCompartment (DocumentNode node, String labe
{
ReactionNetworkCompartment compartment = null;
if (a)
compartment = new ReactionNetworkCompartment (crn, label, null, node, null);
compartment = new ReactionNetworkCompartment (crn, label, null, node, null, null, null);
else
compartment = new ReactionNetworkCompartment (crn, null, label, null, node);
compartment = new ReactionNetworkCompartment (crn, null, label, null, node, null, null);

crn.setCompartment (node, compartment);
return compartment;
Expand Down Expand Up @@ -183,8 +183,16 @@ public void testCrn ()
reaction1.setCompartmentB (compartment1);
reaction1.setLabelB ("reaction in A");
reaction1.setDocB (dummy);
reaction1.addInputB (substrate1, null, null);
reaction1.addOutputB (substrate1, null, null);
try {
reaction1.addInputB (substrate1, null, null);
reaction1.addOutputB (substrate1, null, null);
}
catch (BivesUnsupportedException e)
{
LOGGER.error (e, "this error wasn't expected!?");
fail ("this error wasn't expected!?");
}


assertEquals ("unexpected label in compartment", "compartment in A", compartment1.getLabel ());
assertEquals ("expected no modification", GraphEntity.UNMODIFIED, compartment1.getModification ());
Expand All @@ -209,8 +217,17 @@ public void testCrn ()
reaction1.setCompartmentB (compartment1);
reaction1.setLabelB ("reaction in N");
reaction1.setDocB (dummy);
reaction1.addInputB (substrate1, null, null);
reaction1.addOutputB (substrate1, null, null);

try
{
reaction1.addInputB (substrate1, null, null);
reaction1.addOutputB (substrate1, null, null);
}
catch (BivesUnsupportedException e)
{
LOGGER.error (e, "this error wasn't expected!?");
fail ("this error wasn't expected!?");
}


assertFalse ("unexpected label in compartment", "compartment in A".equals (compartment1.getLabel ()));
Expand All @@ -233,8 +250,17 @@ public void testCrn ()
reaction1.setCompartmentB (compartment2);
reaction1.setLabelB ("reaction in N");
reaction1.setDocB (dummy);
reaction1.addInputB (substrate1, null, null);
reaction1.addOutputB (substrate1, null, null);

try
{
reaction1.addInputB (substrate1, null, null);
reaction1.addOutputB (substrate1, null, null);
}
catch (BivesUnsupportedException e)
{
LOGGER.error (e, "this error wasn't expected!?");
fail ("this error wasn't expected!?");
}


assertFalse ("unexpected label in substrate", "substrate in A".equals (substrate1.getLabel ()));
Expand Down Expand Up @@ -263,8 +289,17 @@ public void testCrn ()
reaction1.setCompartmentB (compartment1);
reaction1.setLabelB ("reaction in A");
reaction1.setDocB (dummy);
reaction1.addInputB (substrate1, null, null);
reaction1.addOutputB (substrate1, null, null);

try
{
reaction1.addInputB (substrate1, null, null);
reaction1.addOutputB (substrate1, null, null);
}
catch (BivesUnsupportedException e)
{
LOGGER.error (e, "this error wasn't expected!?");
fail ("this error wasn't expected!?");
}

assertEquals ("unexpected label in compartment", "compartment in A", compartment1.getLabel ());
assertEquals ("expected no modification", GraphEntity.UNMODIFIED, compartment1.getModification ());
Expand All @@ -280,7 +315,16 @@ public void testCrn ()


// different i/o?
reaction1.addInputB (substrate2, null, null);
try
{
reaction1.addInputB (substrate2, null, null);
}
catch (BivesUnsupportedException e)
{
LOGGER.error (e, "this error wasn't expected!?");
fail ("this error wasn't expected!?");
}

reaction1.addOutputA (substrate2, null, null);
assertEquals ("unexpected label in compartment", "compartment in A", compartment1.getLabel ());
assertEquals ("expected no modification", GraphEntity.UNMODIFIED, compartment1.getModification ());
Expand Down