JAL-3692 parse DE for description, and other refactoring...
[jalview.git] / test / jalview / io / EmblFlatFileTest.java
index 6d9874e..b1023d1 100644 (file)
@@ -2,7 +2,6 @@ package jalview.io;
 
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.assertNull;
 
 import java.io.File;
 import java.io.IOException;
@@ -13,6 +12,7 @@ import java.util.Set;
 import org.testng.annotations.Test;
 
 import jalview.datamodel.DBRefEntry;
+import jalview.datamodel.Mapping;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.datamodel.features.SequenceFeatures;
@@ -39,6 +39,7 @@ public class EmblFlatFileTest
     SequenceI seq = seqs.get(0);
     assertEquals(seq.getName(), "EmblTest|J03321");
     assertEquals(seq.getLength(), 7502);
+    assertEquals(seq.getDescription(), "Chlamydia trachomatis plasmid pCHL1, complete sequence");
 
     /*
      * should be 9 CDS features (one is a 'join' of two exons)
@@ -48,7 +49,7 @@ public class EmblFlatFileTest
     assertTrue(featureTypes.contains("CDS"));
     
     /*
-     * inspect some features (sort them for convenience of test assertions)
+     * inspect some features (sorted just for convenience of test assertions)
      */
     List<SequenceFeature> features = seq.getFeatures()
             .getAllFeatures("CDS");
@@ -65,7 +66,7 @@ public class EmblFlatFileTest
     assertEquals(sf.getPhase(), "0");
     assertEquals(sf.getStrand(), 1);
     assertEquals(sf.getValue("note"), "pGP7-D");
-    // second exon of circular DNA!
+    // this is the second exon of circular CDS!
     assertEquals(sf.getValue("exon number"), 2);
     assertEquals(sf.getValue("product"), "hypothetical protein");
     assertEquals(sf.getValue("transl_table"), "11");
@@ -97,7 +98,7 @@ public class EmblFlatFileTest
     assertEquals(sf.getValue("product"), "hypothetical protein");
     
     /*
-     * CDS at 7022-7502 is the first exon of the circular DNA CDS
+     * CDS at 7022-7502 is the first exon of the circular CDS
      */
     sf = features.get(8);
     assertEquals(sf.getBegin(), 7022);
@@ -113,18 +114,25 @@ public class EmblFlatFileTest
     assertEquals(sf.getValue("product"), "hypothetical protein");
 
     /*
-     * there are 4 'direct' (DR) dbrefs, and numerous CDS /db_xref entries,
-     * some of them (e.g. INTERPRO) duplicates; sample a few here
+     * Jalview adds a dbref to 'self', and  there are 4 'direct' (DR) dbrefs, 
+     * and numerous CDS /db_xref entries (some e.g. INTERPRO are duplicates)
+     * sample a few here
      * Note DBRefEntry constructor capitalises source
      */
     List<DBRefEntry> dbrefs = seq.getDBRefs();
-    assertEquals(dbrefs.size(), 31);
+    assertEquals(dbrefs.size(), 32);
+    // xref to 'self':
+    DBRefEntry selfRef = new DBRefEntry("EMBLTEST", "1", "J03321");
+    int[] range = new int[] {1, seq.getLength()};
+    selfRef.setMap(new Mapping(null, range, range, 1, 1));
+    assertTrue(dbrefs.contains(selfRef));
+    
     // 1st DR line; note trailing period is removed
     assertTrue(dbrefs.contains(new DBRefEntry("MD5", "0",
             "d4c4942a634e3df4995fd5ac75c26a61")));
     // the 4th DR line:
     assertTrue(
-            dbrefs.contains(new DBRefEntry("EuropePMC", "0", "PMC87941")));
+            dbrefs.contains(new DBRefEntry("EUROPEPMC", "0", "PMC87941")));
     // from the first CDS feature; note canonicalisation to "UNIPROT"
     assertTrue(dbrefs.contains(new DBRefEntry("GOA", "0", "P0CE19")));
     assertTrue(dbrefs.contains(new DBRefEntry("UNIPROT", "0", "P0CE19")));