JAL-2416 support roundtrip print/parse of ScoreMatrix
[jalview.git] / test / jalview / io / ScoreMatrixFileTest.java
index 123de6b..44bb8aa 100644 (file)
@@ -257,4 +257,28 @@ public class ScoreMatrixFileTest
               "Format error: expected 'ScoreMatrix <name>', found 'ScoreMatrix' at line 1");
     }
   }
+
+  /**
+   * Test a successful parse of a (small) score matrix file
+   * 
+   * @throws IOException
+   * @throws MalformedURLException
+   */
+  @Test(groups = "Functional")
+  public void testParse_withResidueHeading() throws MalformedURLException,
+          IOException
+  {
+    String data = "ScoreMatrix MyTest\n" + "ABC\n" + "\tA\tB\tC\n"
+            + "A\t1.0\t2.0\t3.0\n" + "B\t4.0\t5.0\t6.0\n"
+            + "C\t7.0\t8.0\t9.0\n";
+    FileParse fp = new FileParse(data, DataSourceType.PASTE);
+    ScoreMatrixFile parser = new ScoreMatrixFile(fp);
+    ScoreMatrix sm = parser.parseMatrix();
+  
+    assertNotNull(sm);
+    assertEquals(sm.getName(), "MyTest");
+    assertEquals(sm.getPairwiseScore('A', 'A'), 1.0f);
+    assertEquals(sm.getPairwiseScore('B', 'c'), 6.0f);
+    assertEquals(sm.getSize(), 3);
+  }
 }