[MOBY-guts] biomoby commit

Martin Senger senger at dev.open-bio.org
Mon Mar 3 03:11:28 UTC 2008


senger
Sun Mar  2 22:11:27 EST 2008
Update of /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser
In directory dev.open-bio.org:/tmp/cvs-serv2132/src/test/java/org/biomoby/shared/parser

Modified Files:
	MobyParserTest.java 
Log Message:
More junit tests for XML parser

moby-live/Java/src/test/java/org/biomoby/shared/parser MobyParserTest.java,1.2,1.3
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser/MobyParserTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser/MobyParserTest.java	2008/03/02 12:45:27	1.2
+++ /home/repository/moby/moby-live/Java/src/test/java/org/biomoby/shared/parser/MobyParserTest.java	2008/03/03 03:11:27	1.3
@@ -20,6 +20,7 @@
 package org.biomoby.shared.parser;
 
 import org.biomoby.shared.MobyException;
+import org.biomoby.shared.data.MobyProvisionInfo;
 import org.biomoby.shared.datatypes.*;
 
 import org.junit.Before;
@@ -39,10 +40,12 @@
 
 public class MobyParserTest {
 
-    private static final String INPUT_1 = "parser-test-input-1.xml";
-    private static final String INPUT_2 = "parser-test-input-2.xml";
-    private static final String INPUT_3 = "parser-test-input-3.xml";
-    private static final String INPUT_4 = "parser-test-input-4.xml";
+    private static final String INPUT_1     = "parser-test-input-1.xml";
+    private static final String INPUT_2     = "parser-test-input-2.xml";
+    private static final String INPUT_3     = "parser-test-input-3.xml";
+    private static final String INPUT_4     = "parser-test-input-4.xml";
+    private static final String INPUT_XREFS = "parser-test-input-xrefs.xml";
+    private static final String INPUT_SET   = "parser-test-input-set.xml";
  
     /**************************************************************************
      *
@@ -72,26 +75,101 @@
 	assertEquals (typedData.getMoby_Length().getIntValue(), 10);
     }
 
-//     @Test
-//     public void testUnknownTopLevel()
-// 	throws IOException, MobyException {
-// 	parse (INPUT_2, "DNASequence", null);
-//     }
-
-//     @Test
-//     public void testUnknownTopLevelAndMember()
-// 	throws IOException, MobyException {
-// 	parse (INPUT_3, "BasicGFF3MultiFeature", null);
-//     }
-
-//     @Test
-//     public void testMoreUnknownTopLevels()
-// 	throws IOException, MobyException {
-// 	Map<String,String> backups = new HashMap<String,String>();
-// 	backups.put ("mySeq",   "DNASequence");
-// 	backups.put ("myPairs", "BasicGFF3MultiFeature");
-// 	parse (INPUT_4, null, backups);
-//     }
+     @Test
+     public void testUnknownTopLevel()
+ 	throws IOException, MobyException {
+	MobyPackage moby = parse (INPUT_2, "DNASequence", null);
+	DNASequence typedData = (DNASequence)moby.getJob(0).getData ("myDNA");
+	assertEquals (typedData.get_SequenceString(), "abcd");
+	assertEquals (typedData.getMoby_Length().getIntValue(), 12);
+     }
+
+    @Test
+    public void testUnknownTopLevelAndMember()
+	throws IOException, MobyException {
+	MobyPackage moby = parse (INPUT_3, "BasicGFF3MultiFeature", null);
+	BasicGFF3MultiFeature typedData = (BasicGFF3MultiFeature)moby.getJob(0).getData ("myPairs");
+	BasicGFF3SequenceFeature[] data = typedData.getMoby_BasicGFF3SequenceFeature();
+	assertEquals (data.length, 1);
+	assertEquals (data[0].getMoby_start().getIntValue(), 1);
+	assertEquals (data[0].getMoby_score().getFloatValue(), 12.34, 0);
+	assertEquals (data[0].get_phase(), "b");
+	multi_key_value_pair[] pairs = data[0].getMoby_column9_tag_value();
+	assertEquals (pairs.length, 2);
+	assertEquals (pairs[0].get_key(), "key1");
+	assertEquals (pairs[0].get_the_value().length, 3);
+	assertEquals (pairs[0].get_the_value()[0], "value1");
+	assertEquals (pairs[1].get_key(), "key2");
+	assertEquals (pairs[1].get_the_value().length, 1);
+	assertEquals (pairs[1].get_the_value()[0], "valueA");
+    }
+
+    @Test
+    public void testMoreUnknownTopLevels()
+	throws IOException, MobyException {
+	Map<String,String> backups = new HashMap<String,String>();
+	backups.put ("mySeq",   "DNASequence");
+	backups.put ("myPairs", "BasicGFF3MultiFeature");
+	MobyPackage moby = parse (INPUT_4, null, backups);
+	BasicGFF3MultiFeature typedData = (BasicGFF3MultiFeature)moby.getJob(0).getData ("myPairs");
+	BasicGFF3SequenceFeature[] data = typedData.getMoby_BasicGFF3SequenceFeature();
+	assertEquals (data.length, 1);
+	assertEquals (data[0].getMoby_start().getIntValue(), 1);
+	assertEquals (data[0].getMoby_score().getFloatValue(), 12.34, 0);
+	assertEquals (data[0].get_phase(), "b");
+	multi_key_value_pair[] pairs = data[0].getMoby_column9_tag_value();
+	assertEquals (pairs.length, 1);
+	assertEquals (pairs[0].get_key(), "key1");
+	assertEquals (pairs[0].get_the_value().length, 1);
+	assertEquals (pairs[0].get_the_value()[0], "value1");
+	DNASequence seqData = (DNASequence)moby.getJob(0).getData ("mySeq");
+	assertEquals (seqData.get_SequenceString(), "xyz");
+	assertEquals (seqData.getMoby_Length().getIntValue(), 123);
+    }
+
+    @Test
+    public void testSetWithSubstitution()
+	throws IOException, MobyException {
+ 	Map<String,String> backups = new HashMap<String,String>();
+ 	backups.put ("mySequenceCollection", "GenericSequence");
+	MobyPackage moby = parse (INPUT_SET, null, backups);
+	MobyObject[] data = moby.getJob(0).getDataSet ("mySequenceCollection");
+	assertEquals (data[0].getMobyTypeName(), "DNASequence");
+	assertEquals (data[1].getMobyTypeName(), "GenericSequence");
+	GenericSequence typedData = (GenericSequence)data[0];
+	assertEquals (typedData.get_SequenceString(), "tatatatata");
+	assertEquals (typedData.getMoby_Length().getIntValue(), 10);
+	typedData = (GenericSequence)data[1];
+	assertEquals (typedData.get_SequenceString(), "");
+	assertEquals (typedData.getMoby_Length().getIntValue(), 5);
+    }
+
+    @Test
+    public void testXref()
+	throws IOException, MobyException {
+	MobyPackage moby = parse (INPUT_XREFS, null, null);
+	assertEquals (moby.getJob(0).getData().getValue().trim(),
+		      "This is a value");
+	MobyXref[] xrefs = moby.getJob(0).getData().getXrefs();
+	assertEquals (xrefs.length, 3);
+	assertTrue  (xrefs[0].isSimpleXref());
+	assertTrue  (xrefs[1].isSimpleXref());
+	assertFalse (xrefs[2].isSimpleXref());
+	assertEquals (xrefs[0].getId(), "At263644");
+	assertEquals (xrefs[0].getNamespace(), "TIGR");
+	assertEquals (xrefs[2].getId(), "yes");
+	assertEquals (xrefs[2].getNamespace(), "LION");
+	assertEquals (xrefs[2].getEvidenceCode(), "IEA");
+
+	MobyProvisionInfo pi = moby.getJob(0).getData().getProvision();
+	assertEquals (pi.getSoftwareName(),    "InterPro");
+	assertEquals (pi.getSoftwareVersion(), "1.2");
+	assertEquals (pi.getSoftwareComment(), "HMMER's not run");
+	assertEquals (pi.getDBName(),    "Genbank/nt");
+	assertEquals (pi.getDBVersion(), "April 8, 2003");
+	assertEquals (pi.getDBComment(), "DBver");
+	assertEquals (pi.getComment(), "this <&>\"<&>\" is a software comment");
+    }
 
 
     /**************************************************************************




More information about the MOBY-guts mailing list