JAL-3446 JAL-3253 JAL-3445 BSML bbb XML format reader (preliminary) test Jalview-JS/develop.JAL-3445-BSML-reader
authorBobHanson <hansonr@stolaf.edu>
Tue, 2 Jun 2020 18:14:54 +0000 (13:14 -0500)
committerBobHanson <hansonr@stolaf.edu>
Tue, 2 Jun 2020 18:14:54 +0000 (13:14 -0500)
test/jalview/io/BSMLFileTest.java [new file with mode: 0644]

diff --git a/test/jalview/io/BSMLFileTest.java b/test/jalview/io/BSMLFileTest.java
new file mode 100644 (file)
index 0000000..3052658
--- /dev/null
@@ -0,0 +1,68 @@
+package jalview.io;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
+import jalview.datamodel.features.SequenceFeaturesI;
+
+import java.io.IOException;
+import java.util.List;
+
+import org.testng.annotations.Test;
+
+public class BSMLFileTest
+{
+  @Test(groups="Functional")
+  public void testParse_BSML() throws IOException
+  {
+    //@formatter:off
+    String data = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + 
+            "<Bsml>\r\n" + 
+            "  <Definitions>\r\n" + 
+            "    <Sequences>\r\n" + 
+            "      <Sequence\r\n" + 
+            "        comment=\"Sequence Data Contained in 'Multiple-alignment' section\"\r\n" + 
+            "        id=\"SEQ-ID:181170\" length=\"30\" molecule=\"dna\" title=\"EP1\">\r\n" + 
+            "        <Feature-tables>\r\n" + 
+            "          <Feature-table title=\"GENE\">\r\n" + 
+            "            <Feature class=\"GENE\" title=\"TEST-001\">\r\n" + 
+            "              <Interval-loc complement=\"0\" endpos=\"20\" startpos=\"10\"/>\r\n" + 
+            "              <Resource id=\"GENE-ID:181171\"/>\r\n" + 
+            "            </Feature>\r\n" + 
+            "          </Feature-table>\r\n" + 
+            "        </Feature-tables>\r\n" + 
+            "      </Sequence>\r\n" + 
+            "    </Sequences>\r\n" + 
+            "    <Tables>\r\n" + 
+            "      <Multiple-alignment-table molecule-type=\"nucleotide\">\r\n" + 
+            "        <Sequence-alignment sequences=\"1\">\r\n" + 
+            "          <Sequence-data seq-name=\"EP1\">--AATTTT-ATTTAGTGTCT-----------</Sequence-data>\r\n" + 
+            "          <Alignment-consensus/>\r\n" + 
+            "        </Sequence-alignment>\r\n" + 
+            "      </Multiple-alignment-table>\r\n" + 
+            "    </Tables>\r\n" + 
+            "    <Notebook notebook=\"\"/>\r\n" + 
+            "  </Definitions>\r\n" + 
+            "</Bsml>\r\n" + 
+            "";
+    BSMLFile cf = new BSMLFile(data, DataSourceType.PASTE);
+// why twice?    cf.parse();
+    SequenceI[] seqs = cf.getSeqsAsArray();
+    assertEquals(seqs.length, 1);
+    SequenceI seq = seqs[0];
+    assertEquals(seq.getName(), "EP1");
+    assertEquals(seq.getStart(), 1);
+    assertEquals(seq.getEnd(), 31);
+    assertTrue(seq.getSequenceAsString().equals("--AATTTT-ATTTAGTGTCT-----------"));
+    SequenceFeaturesI features = seq.getFeatures();
+    List<SequenceFeature> genes = features.getAllFeatures("GENE");
+    assertEquals(genes.size(), 1);
+    SequenceFeature sf = genes.get(0);
+    assertEquals(sf.getDescription(), "TEST-001");
+    assertEquals(sf.begin + "," + sf.end, "10,20");
+    
+  }
+
+}