JAL-3692 parse multiline feature qualifiers and escaped quotes
[jalview.git] / test / jalview / io / EmblFlatFileTest.java
index 35b378b..2898a06 100644 (file)
@@ -242,11 +242,14 @@ public class EmblFlatFileTest
   public void testParse_noUniprotXref() throws IOException
   {
     // MN908947 cut down to 40BP, one CDS, length 5 peptide for test purposes
+    // plus an additional (invented) test case:
+    // - multi-line /product qualifier including escaped quotes
     String data = "ID   MN908947; SV 3; linear; genomic RNA; STD; VRL; 20 BP.\n"
             + "DE   Severe acute respiratory syndrome coronavirus 2 isolate Wuhan-Hu-1,\n"
             + "FT   CDS             3..17\n"
             + "FT                   /protein_id=\"QHD43415.1\"\n"
-            + "FT                   /product=\"orf1ab polyprotein\"\n"
+            + "FT                   /product=\"orf1ab polyprotein\n"
+            + "FT                   \"\"foobar\"\" \"\n"
             + "FT                   /translation=\"MRKLD\n"
             + "SQ   Sequence 7496 BP; 2450 A; 1290 C; 1434 G; 2322 T; 0 other;\n"
             + "     ggatGcgtaa gttagacgaa attttgtctt tgcgcacaga        40\n";
@@ -284,7 +287,8 @@ public class EmblFlatFileTest
     mapping = dbref.getMap();
     SequenceI mapTo = mapping.getTo();
     assertEquals(mapTo.getName(), "QHD43415.1");
-    assertEquals(mapTo.getDescription(), "orf1ab polyprotein");
+    // the /product qualifier transfers to protein product description
+    assertEquals(mapTo.getDescription(), "orf1ab polyprotein \"foobar\"");
     assertEquals(mapTo.getSequenceAsString(), "MRKLD");
     map = mapping.getMap();
     assertEquals(map.getFromLowest(), 3);
@@ -323,4 +327,13 @@ public class EmblFlatFileTest
     truncated = EmblFlatFile.adjustForProteinLength(7, exons);
     assertSame(exons, truncated);
   }
+
+  @Test(groups = "Functional")
+  public void testRemoveQuotes()
+  {
+    assertNull(EmblFlatFile.removeQuotes(null));
+    assertEquals(EmblFlatFile.removeQuotes("No quotes here"), "No quotes here");
+    assertEquals(EmblFlatFile.removeQuotes("\"Enclosing quotes\""), "Enclosing quotes");
+    assertEquals(EmblFlatFile.removeQuotes("\"Escaped \"\"quotes\"\" example\""), "Escaped \"quotes\" example");
+  }
 }