X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2FScoreMatrixFileTest.java;fp=test%2Fjalview%2Fio%2FScoreMatrixFileTest.java;h=c5890826a04575e96114790442450b8ab6182897;hb=9c98d4bd666346f6ad3892c5394b7da3be82d93e;hp=254feaa625523aa68249d2a622ccaeaf7eb4fd72;hpb=c7b2143c9cf7c5e05ad63251f7d3910751b16d20;p=jalview.git diff --git a/test/jalview/io/ScoreMatrixFileTest.java b/test/jalview/io/ScoreMatrixFileTest.java index 254feaa..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; @@ -19,7 +39,7 @@ import org.testng.annotations.Test; public class ScoreMatrixFileTest { - @AfterMethod(alwaysRun=true) + @AfterMethod(alwaysRun = true) public void tearDownAfterTest() { ScoreModels.getInstance().reset(); @@ -33,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 @@ -262,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"); } } @@ -275,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" @@ -285,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"); @@ -302,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(), @@ -330,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 @@ -339,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"); @@ -363,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); @@ -386,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 @@ -400,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"); } } @@ -424,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"; @@ -443,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"; @@ -462,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"; @@ -475,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"); } } @@ -488,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)); @@ -500,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");