Skip to content

Commit

Permalink
Added test data and test stubs to address issue #41.
Browse files Browse the repository at this point in the history
  • Loading branch information
IgorRodchenkov committed Dec 13, 2018
1 parent 21897db commit 22a5956
Show file tree
Hide file tree
Showing 3 changed files with 122 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,21 @@
import org.sbgn.bindings.Sbgn;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
import java.io.*;
import java.util.*;

/**
* @author Ozgun Babur
*/
public class SBGNConverterTest
{
static final BioPAXIOHandler handler = new SimpleIOHandler();

private static final BioPAXIOHandler handler = new SimpleIOHandler();
private static UbiqueDetector blacklist;
private static Unmarshaller unmarshaller;
private static Marshaller marshaller;

@BeforeClass
public static void setUp() {
public static void setUp() throws JAXBException {
blacklist = new ListUbiqueDetector(new HashSet<String>(Arrays.asList(
"http://pid.nci.nih.gov/biopaxpid_685",
"http://pid.nci.nih.gov/biopaxpid_678",
Expand All @@ -42,6 +41,11 @@ public static void setUp() {
"http://pathwaycommons.org/pc2/SmallMolecule_3037a14ebec3a95b8dab68e6ea5c946f",
"http://pathwaycommons.org/pc2/SmallMolecule_4ca9a2cfb6a8a6b14cee5d7ed5945364"
)));

JAXBContext context = JAXBContext.newInstance("org.sbgn.bindings");
unmarshaller = context.createUnmarshaller();
marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
}

@Test
Expand All @@ -66,9 +70,6 @@ public void testSBGNConversion() throws Exception
else
System.out.println ("Validation failed");

JAXBContext context = JAXBContext.newInstance("org.sbgn.bindings");
Unmarshaller unmarshaller = context.createUnmarshaller();

// Now read from "f" and put the result in "sbgn"
Sbgn result = (Sbgn)unmarshaller.unmarshal (outFile);

Expand Down Expand Up @@ -109,7 +110,6 @@ public void testNestedComplexes() throws Exception

L3ToSBGNPDConverter conv = new L3ToSBGNPDConverter(null, null, true);
conv.setFlattenComplexContent(false);

conv.writeSBGN(level3, out);

File outFile = new File(out);
Expand All @@ -121,9 +121,6 @@ public void testNestedComplexes() throws Exception
else
System.out.println ("Validation failed");

JAXBContext context = JAXBContext.newInstance("org.sbgn.bindings");
Unmarshaller unmarshaller = context.createUnmarshaller();

// Now read from "f" and put the result in "sbgn"
Sbgn result = (Sbgn)unmarshaller.unmarshal (outFile);

Expand Down Expand Up @@ -168,9 +165,6 @@ public void testStoichiometry() throws Exception
else
System.out.println ("warning: " + out + " is invalid SBGN");

JAXBContext context = JAXBContext.newInstance("org.sbgn.bindings");
Unmarshaller unmarshaller = context.createUnmarshaller();

// Now read from "f" and put the result in "sbgn"
Sbgn result = (Sbgn)unmarshaller.unmarshal (outFile);

Expand Down Expand Up @@ -206,8 +200,7 @@ public void testConvertBmpPathway() throws Exception
System.out.println ("warning: " + out + " is invalid SBGN");

// Now read the SBGN model back
Sbgn result = (Sbgn) JAXBContext.newInstance("org.sbgn.bindings")
.createUnmarshaller().unmarshal (outFile);
Sbgn result = (Sbgn) unmarshaller.unmarshal (outFile);

// Assert that the sbgn result contains glyphs
assertTrue(!result.getMap().getGlyph().isEmpty());
Expand Down Expand Up @@ -270,9 +263,6 @@ public void testSbgnLayoutKegg51() throws Exception
if (!SbgnUtil.isValid(sbgnFile))
System.out.println ("invalid input SBGN");

JAXBContext context = JAXBContext.newInstance("org.sbgn.bindings");
Unmarshaller unmarshaller = context.createUnmarshaller();

// Now read from "f" and put the result in "sbgn"
Sbgn result = (Sbgn)unmarshaller.unmarshal (sbgnFile);
// Assert that the sbgn result contains glyphs
Expand All @@ -281,9 +271,6 @@ public void testSbgnLayoutKegg51() throws Exception
// infinite loop in LGraph.updateConnected when SbgnPDLayout is used
(new SBGNLayoutManager()).createLayout(result, true);
//TODO: run, add assertions

Marshaller marshaller = context.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
marshaller.marshal(result, new FileOutputStream("target/hsa00051.out.sbgn"));
}

Expand Down Expand Up @@ -361,12 +348,34 @@ public void testConvertTfap2Pathway() throws Exception
System.out.println ("warning: " + out + " is invalid SBGN");

// Now read the SBGN model back
Sbgn result = (Sbgn) JAXBContext.newInstance("org.sbgn.bindings").createUnmarshaller().unmarshal (outFile);
Sbgn result = (Sbgn) unmarshaller.unmarshal (outFile);

// Assert that the sbgn result contains glyphs
assertTrue(!result.getMap().getGlyph().isEmpty());

//TODO: test complexes are complete, no dangling, member complex contains a homodimer...
// it looks ok in SBGNViz editor/viewer though...
}

@Test
public void testConvertActivation()
{
String input = "/activation";
InputStream in = getClass().getResourceAsStream(input + ".owl");
Model level3 = handler.convertFromOWL(in);
String out = "target/" + input + ".sbgn";
L3ToSBGNPDConverter conv = new L3ToSBGNPDConverter(blacklist,null, true);
conv.writeSBGN(level3, out);
}

@Test
public void testConvertModulation()
{
String input = "/modulation";
InputStream in = getClass().getResourceAsStream(input + ".owl");
Model level3 = handler.convertFromOWL(in);
String out = "target/" + input + ".sbgn";
L3ToSBGNPDConverter conv = new L3ToSBGNPDConverter(blacklist,null, true);
conv.writeSBGN(level3, out);
}
}
44 changes: 44 additions & 0 deletions sbgn-converter/src/test/resources/activation.owl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:bp="http://www.biopax.org/release/biopax-level3.owl#">
<owl:Ontology rdf:about="">
<owl:imports rdf:resource="http://www.biopax.org/release/biopax-level3.owl#" />
</owl:Ontology>
<bp:Protein rdf:about="f98f403f-ab47-4d50-a9c1-dd0c62ddb929">
<bp:displayName rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">FSHB</bp:displayName>
<bp:entityReference rdf:resource="61a166af-cabc-4f37-82dc-205cd763a354" />
</bp:Protein>
<bp:ProteinReference rdf:about="61a166af-cabc-4f37-82dc-205cd763a354">
<bp:xref rdf:resource="6b54a312-f1ce-46c1-aa65-23a475d8a448" />
<bp:displayName rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">FSHB</bp:displayName>
</bp:ProteinReference>
<bp:RelationshipXref rdf:about="6b54a312-f1ce-46c1-aa65-23a475d8a448">
<bp:id rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">P01225</bp:id>
<bp:db rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">uniprot</bp:db>
</bp:RelationshipXref>
<bp:Protein rdf:about="2e8917ce-7b7c-42dd-ba0a-fee2b139dd3e">
<bp:displayName rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">IGF1</bp:displayName>
<bp:entityReference rdf:resource="7a1b2976-619c-439e-a3e8-d9064519d60b" />
</bp:Protein>
<bp:ProteinReference rdf:about="7a1b2976-619c-439e-a3e8-d9064519d60b">
<bp:xref rdf:resource="4090cd2e-f146-4c85-9478-5af0818f19cf" />
<bp:displayName rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">IGF1</bp:displayName>
</bp:ProteinReference>
<bp:RelationshipXref rdf:about="4090cd2e-f146-4c85-9478-5af0818f19cf">
<bp:id rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">P05019</bp:id>
<bp:db rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">uniprot</bp:db>
</bp:RelationshipXref>
<bp:Control rdf:about="9d9700c6-a390-4ebe-91a9-82c4a89ea5ee">
<bp:comment>FSHB activates IGF1</bp:comment>
<bp:controlled rdf:resource="93d7ff4e-2943-45bf-aca9-16ff4241a7c0" />
<bp:controller rdf:resource="f98f403f-ab47-4d50-a9c1-dd0c62ddb929" />
<bp:controlType rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">ACTIVATION</bp:controlType>
</bp:Control>
<bp:Control rdf:about="93d7ff4e-2943-45bf-aca9-16ff4241a7c0">
<bp:controller rdf:resource="2e8917ce-7b7c-42dd-ba0a-fee2b139dd3e" />
<bp:controlType rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">ACTIVATION</bp:controlType>
</bp:Control>
</rdf:RDF>
44 changes: 44 additions & 0 deletions sbgn-converter/src/test/resources/modulation.owl
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:bp="http://www.biopax.org/release/biopax-level3.owl#">
<owl:Ontology rdf:about="">
<owl:imports rdf:resource="http://www.biopax.org/release/biopax-level3.owl#" />
</owl:Ontology>
<bp:SmallMolecule rdf:about="28ee35e1-de08-4cec-91c9-cfbadae683ef">
<bp:displayName rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">Estradiol</bp:displayName>
<bp:entityReference rdf:resource="e9d5ce7b-71d9-442d-970e-b768dc7c7418" />
</bp:SmallMolecule>
<bp:SmallMoleculeReference rdf:about="e9d5ce7b-71d9-442d-970e-b768dc7c7418">
<bp:xref rdf:resource="150e9163-9811-4ab8-9442-54dbb16a39d5" />
<bp:displayName rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">Estradiol</bp:displayName>
</bp:SmallMoleculeReference>
<bp:RelationshipXref rdf:about="150e9163-9811-4ab8-9442-54dbb16a39d5">
<bp:id rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">5757</bp:id>
<bp:db rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">pubchem</bp:db>
</bp:RelationshipXref>
<bp:Protein rdf:about="1a6dedda-6fa6-436e-836a-1c1c58be526a">
<bp:displayName rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">LEP</bp:displayName>
<bp:entityReference rdf:resource="10e75ab2-b79d-4359-af37-e90e3a7473e7" />
</bp:Protein>
<bp:ProteinReference rdf:about="10e75ab2-b79d-4359-af37-e90e3a7473e7">
<bp:xref rdf:resource="88f99df9-6771-44aa-8514-95071e84476b" />
<bp:displayName rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">LEP</bp:displayName>
</bp:ProteinReference>
<bp:RelationshipXref rdf:about="88f99df9-6771-44aa-8514-95071e84476b">
<bp:id rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">P41159</bp:id>
<bp:db rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">uniprot</bp:db>
</bp:RelationshipXref>
<bp:Modulation rdf:about="f0ae2f3a-f88c-40ad-8d25-c653ae636aba">
<bp:comment>Estradiol activates LEP</bp:comment>
<bp:controlled rdf:resource="fb03be15-e844-4e5b-92d3-1d527efbabbe" />
<bp:controller rdf:resource="28ee35e1-de08-4cec-91c9-cfbadae683ef" />
<bp:controlType rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">ACTIVATION</bp:controlType>
</bp:Modulation>
<bp:Catalysis rdf:about="fb03be15-e844-4e5b-92d3-1d527efbabbe">
<bp:controller rdf:resource="1a6dedda-6fa6-436e-836a-1c1c58be526a" />
<bp:controlType rdf:datatype = "http://www.w3.org/2001/XMLSchema#string">ACTIVATION</bp:controlType>
</bp:Catalysis>
</rdf:RDF>

0 comments on commit 22a5956

Please sign in to comment.