X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fio%2FScoreMatrixFileTest.java;h=c5890826a04575e96114790442450b8ab6182897;hb=42ab9fcdad6ea5c39bca0fb8b5564c2d420dc183;hp=97349b5b9fafed4457144463baa9d135c10d3b40;hpb=136c0793b90b72b928c4d77dc109dd5c644e00d3;p=jalview.git
diff --git a/test/jalview/io/ScoreMatrixFileTest.java b/test/jalview/io/ScoreMatrixFileTest.java
index 97349b5..c589082 100644
--- a/test/jalview/io/ScoreMatrixFileTest.java
+++ b/test/jalview/io/ScoreMatrixFileTest.java
@@ -1,3 +1,23 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
package jalview.io;
import static org.testng.Assert.assertEquals;
@@ -13,11 +33,18 @@ import jalview.analysis.scoremodels.ScoreModels;
import java.io.IOException;
import java.net.MalformedURLException;
+import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;
public class ScoreMatrixFileTest
{
+ @AfterMethod(alwaysRun = true)
+ public void tearDownAfterTest()
+ {
+ ScoreModels.getInstance().reset();
+ }
+
/**
* Test a successful parse of a (small) score matrix file
*
@@ -26,8 +53,7 @@ public class ScoreMatrixFileTest
*/
@Test(groups = "Functional")
public void testParseMatrix_ncbiMixedDelimiters()
- throws MalformedURLException,
- IOException
+ throws MalformedURLException, IOException
{
/*
* some messy but valid input data, with comma, space
@@ -255,8 +281,7 @@ public class ScoreMatrixFileTest
fail("expected exception");
} catch (IOException e)
{
- assertEquals(
- e.getMessage(),
+ assertEquals(e.getMessage(),
"Format error: expected 'ScoreMatrix ', found 'ScoreMatrix' at line 1");
}
}
@@ -268,8 +293,8 @@ public class ScoreMatrixFileTest
* @throws MalformedURLException
*/
@Test(groups = "Functional")
- public void testParseMatrix_ncbiFormat() throws MalformedURLException,
- IOException
+ public void testParseMatrix_ncbiFormat()
+ throws MalformedURLException, IOException
{
// input including comment and blank lines
String data = "ScoreMatrix MyTest\n#comment\n\n" + "\tA\tB\tC\n"
@@ -278,7 +303,7 @@ public class ScoreMatrixFileTest
FileParse fp = new FileParse(data, DataSourceType.PASTE);
ScoreMatrixFile parser = new ScoreMatrixFile(fp);
ScoreMatrix sm = parser.parseMatrix();
-
+
assertNotNull(sm);
assertEquals(sm.getName(), "MyTest");
assertEquals(parser.getMatrixName(), "MyTest");
@@ -295,14 +320,13 @@ public class ScoreMatrixFileTest
*/
@Test(groups = "Functional")
public void testParseMatrix_aaIndexBlosum80()
- throws MalformedURLException,
- IOException
+ throws MalformedURLException, IOException
{
FileParse fp = new FileParse("resources/scoreModel/blosum80.scm",
DataSourceType.FILE);
ScoreMatrixFile parser = new ScoreMatrixFile(fp);
ScoreMatrix sm = parser.parseMatrix();
-
+
assertNotNull(sm);
assertEquals(sm.getName(), "HENS920103");
assertEquals(sm.getDescription(),
@@ -323,8 +347,8 @@ public class ScoreMatrixFileTest
* @throws MalformedURLException
*/
@Test(groups = "Functional")
- public void testParseMatrix_aaindexFormat() throws MalformedURLException,
- IOException
+ public void testParseMatrix_aaindexFormat()
+ throws MalformedURLException, IOException
{
/*
* aaindex format has scores for diagonal and below only
@@ -332,13 +356,12 @@ public class ScoreMatrixFileTest
String data = "H MyTest\n" + "D My description\n" + "R PMID:1438297\n"
+ "A Authors, names\n" + "T Journal title\n"
+ "J Journal reference\n" + "* matrix in 1/3 Bit Units\n"
- + "M rows = ABC, cols = ABC\n" + "A\t1.0\n"
- + "B\t4.0\t5.0\n"
+ + "M rows = ABC, cols = ABC\n" + "A\t1.0\n" + "B\t4.0\t5.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.getSize(), 3);
assertEquals(sm.getName(), "MyTest");
@@ -356,14 +379,12 @@ public class ScoreMatrixFileTest
@Test(groups = "Functional")
public void testParseMatrix_aaindex_mMissing()
- throws MalformedURLException,
- IOException
+ throws MalformedURLException, IOException
{
/*
* aaindex format but M cols=, rows= is missing
*/
- String data = "H MyTest\n" + "A\t1.0\n"
- + "B\t4.0\t5.0\n"
+ String data = "H MyTest\n" + "A\t1.0\n" + "B\t4.0\t5.0\n"
+ "C\t7.0\t8.0\t9.0\n";
FileParse fp = new FileParse(data, DataSourceType.PASTE);
ScoreMatrixFile parser = new ScoreMatrixFile(fp);
@@ -379,12 +400,10 @@ public class ScoreMatrixFileTest
@Test(groups = "Functional")
public void testParseMatrix_aaindex_rowColMismatch()
- throws MalformedURLException,
- IOException
+ throws MalformedURLException, IOException
{
String data = "H MyTest\n" + "M rows=ABC, cols=ABD\n" + "A\t1.0\n"
- + "B\t4.0\t5.0\n"
- + "C\t7.0\t8.0\t9.0\n";
+ + "B\t4.0\t5.0\n" + "C\t7.0\t8.0\t9.0\n";
FileParse fp = new FileParse(data, DataSourceType.PASTE);
ScoreMatrixFile parser = new ScoreMatrixFile(fp);
try
@@ -393,8 +412,7 @@ public class ScoreMatrixFileTest
fail("Expected exception");
} catch (FileFormatException e)
{
- assertEquals(
- e.getMessage(),
+ assertEquals(e.getMessage(),
"Unexpected aaIndex score matrix data at line 2: M rows=ABC, cols=ABD rows != cols");
}
}
@@ -417,8 +435,7 @@ public class ScoreMatrixFileTest
@Test(groups = "Functional")
public void testParseMatrix_aaindex_tooManyRows()
- throws MalformedURLException,
- IOException
+ throws MalformedURLException, IOException
{
String data = "H MyTest\n" + "M rows=ABC, cols=ABC\n" + "A\t1.0\n"
+ "B\t4.0\t5.0\n" + "C\t7.0\t8.0\t9.0\n" + "C\t7.0\t8.0\t9.0\n";
@@ -436,8 +453,7 @@ public class ScoreMatrixFileTest
@Test(groups = "Functional")
public void testParseMatrix_aaindex_extraDataLines()
- throws MalformedURLException,
- IOException
+ throws MalformedURLException, IOException
{
String data = "H MyTest\n" + "M rows=ABC, cols=ABC\n" + "A\t1.0\n"
+ "B\t4.0\t5.0\n" + "C\t7.0\t8.0\t9.0\n" + "something extra\n";
@@ -455,8 +471,7 @@ public class ScoreMatrixFileTest
@Test(groups = "Functional")
public void testParseMatrix_aaindex_tooFewColumns()
- throws MalformedURLException,
- IOException
+ throws MalformedURLException, IOException
{
String data = "H MyTest\n" + "M rows=ABC, cols=ABC\n" + "A\t1.0\n"
+ "B\t4.0\t5.0\n" + "C\t7.0\t8.0\n";
@@ -468,8 +483,7 @@ public class ScoreMatrixFileTest
fail("Expected exception");
} catch (FileFormatException e)
{
- assertEquals(
- e.getMessage(),
+ assertEquals(e.getMessage(),
"Expected 3 scores at line 5: 'C\t7.0\t8.0' but found 2");
}
}
@@ -481,8 +495,8 @@ public class ScoreMatrixFileTest
* @throws MalformedURLException
*/
@Test(groups = "Functional")
- public void testParse_ncbiFormat() throws MalformedURLException,
- IOException
+ public void testParse_ncbiFormat()
+ throws MalformedURLException, IOException
{
assertNull(ScoreModels.getInstance().getScoreModel("MyNewTest", null));
@@ -493,9 +507,9 @@ public class ScoreMatrixFileTest
ScoreMatrixFile parser = new ScoreMatrixFile(fp);
parser.parse();
-
- ScoreMatrix sm = (ScoreMatrix) ScoreModels.getInstance().getScoreModel(
- "MyNewTest", null);
+
+ ScoreMatrix sm = (ScoreMatrix) ScoreModels.getInstance()
+ .getScoreModel("MyNewTest", null);
assertNotNull(sm);
assertEquals(sm.getName(), "MyNewTest");
assertEquals(parser.getMatrixName(), "MyNewTest");