X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Futil%2FDBRefUtilsTest.java;h=398492015f0fff9bb08ee7be7fd6462f89a305b4;hb=91559a58dfb08d51d85a990296282e1e43b84e70;hp=963ca7c807f7296e1baca5fc685b4e094da64f7f;hpb=43699f9bc6ba2f390d3652f69b6db8975ff727c0;p=jalview.git diff --git a/test/jalview/util/DBRefUtilsTest.java b/test/jalview/util/DBRefUtilsTest.java index 963ca7c..3984920 100644 --- a/test/jalview/util/DBRefUtilsTest.java +++ b/test/jalview/util/DBRefUtilsTest.java @@ -21,7 +21,6 @@ package jalview.util; import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; import static org.testng.AssertJUnit.assertNull; import static org.testng.AssertJUnit.assertSame; import static org.testng.AssertJUnit.assertTrue; @@ -64,7 +63,9 @@ public class DBRefUtilsTest DBRefEntry ref2 = new DBRefEntry("UNIPROT", "1.2", "A12346"); // Source is converted to upper-case by this constructor! DBRefEntry ref3 = new DBRefEntry("Uniprot", "1.2", "A12347"); - List dbrefs = Arrays.asList(new DBRefEntry[] { ref1, ref2, ref3 }); + List dbrefs = Arrays + .asList(new DBRefEntry[] + { ref1, ref2, ref3 }); String[] sources = new String[] { "EMBL", "UNIPROT" }; List selected = DBRefUtils.selectRefs(dbrefs, sources); @@ -109,49 +110,20 @@ public class DBRefUtilsTest assertEquals("PDB", DBRefUtils.getCanonicalName("Pdb")); assertEquals("UNIPROT", DBRefUtils.getCanonicalName("uniprotkb/swiss-prot")); - assertEquals("UNIPROT", DBRefUtils.getCanonicalName("uniprotkb/trembl")); + assertEquals("UNIPROT", + DBRefUtils.getCanonicalName("uniprotkb/trembl")); assertEquals("UNIPROT", DBRefUtils.getCanonicalName("UNIPROTKB/SWISS-PROT")); - assertEquals("UNIPROT", DBRefUtils.getCanonicalName("UNIPROTKB/TREMBL")); + assertEquals("UNIPROT", + DBRefUtils.getCanonicalName("UNIPROTKB/TREMBL")); assertEquals("UNIPROTKB/SWISS-CHEESE", DBRefUtils.getCanonicalName("UNIPROTKB/SWISS-CHEESE")); assertEquals("ENSEMBL", DBRefUtils.getCanonicalName("Ensembl")); // these are not 'known' to Jalview assertEquals("PFAM", DBRefUtils.getCanonicalName("PFAM")); - assertEquals("pfam", DBRefUtils.getCanonicalName("pfam")); - - } + assertEquals("pfam", DBRefUtils.getCanonicalName("PFAM")); // since JAL-1953 Pfam is also a canonical database name - @Test(groups = { "Functional" }) - public void testIsDasCoordinateSystem() - { - assertFalse(DBRefUtils.isDasCoordinateSystem(null, null)); - assertFalse(DBRefUtils.isDasCoordinateSystem("pdbresnum", null)); - assertFalse(DBRefUtils.isDasCoordinateSystem(null, new DBRefEntry( - "PDB", "v1", "a1"))); - - assertTrue(DBRefUtils.isDasCoordinateSystem("pdbresnum", - new DBRefEntry("PDB", "v1", "a1"))); - assertTrue(DBRefUtils.isDasCoordinateSystem("PDBRESNUM", - new DBRefEntry("PDB", "v1", "a1"))); - // "pdb" is converted to upper-case in DBRefEntry constructor - assertTrue(DBRefUtils.isDasCoordinateSystem("pdbresnum", - new DBRefEntry("pdb", "v1", "a1"))); - assertFalse(DBRefUtils.isDasCoordinateSystem("pdb", new DBRefEntry( - "pdb", "v1", "a1"))); - - assertTrue(DBRefUtils.isDasCoordinateSystem("UNIPROT", new DBRefEntry( - "Uniprot", "v1", "a1"))); - assertTrue(DBRefUtils.isDasCoordinateSystem("Uniprot", new DBRefEntry( - "UNIPROT", "v1", "a1"))); - assertFalse(DBRefUtils.isDasCoordinateSystem("UNIPROTKB", - new DBRefEntry("pdb", "v1", "a1"))); - - assertTrue(DBRefUtils.isDasCoordinateSystem("EMBL", new DBRefEntry( - "EMBL", "v1", "a1"))); - assertTrue(DBRefUtils.isDasCoordinateSystem("embl", new DBRefEntry( - "embl", "v1", "a1"))); } /** @@ -169,6 +141,11 @@ public class DBRefUtilsTest assertEquals("1.2", ref.getVersion()); assertEquals("a7890", ref.getAccessionId()); assertTrue(seq.getAllPDBEntries().isEmpty()); + SequenceI seq2 = new Sequence("Seq2", "ABCD"); + // Check that whitespace doesn't confuse parseToDbRef + DBRefEntry ref2 = DBRefUtils.parseToDbRef(seq2, "EMBL", "1.2", + " a7890"); + assertEquals(ref, ref2); } /** @@ -215,12 +192,14 @@ public class DBRefUtilsTest DBRefEntry ref4 = new DBRefEntry("EMBLCDS", "1", "A1234"); // no match // ref5 matches although it has a mapping - ignored DBRefEntry ref5 = new DBRefEntry("EMBL", "1", "A1234"); - ref5.setMap(new Mapping(new MapList(new int[] { 1, 1 }, new int[] { 1, - 1 }, 1, 1))); - - List matches = DBRefUtils.searchRefs( - Arrays.asList(new DBRefEntry[] { - ref1, ref2, ref3, ref4, ref5 }), target, DBRefUtils.SEARCH_MODE_FULL); + ref5.setMap( + new Mapping(new MapList(new int[] + { 1, 1 }, new int[] { 1, 1 }, 1, 1))); + + List matches = DBRefUtils + .searchRefs(Arrays.asList(new DBRefEntry[] + { ref1, ref2, ref3, ref4, ref5 }), target, + DBRefUtils.SEARCH_MODE_FULL); assertEquals(3, matches.size()); assertSame(ref1, matches.get(0)); assertSame(ref2, matches.get(1)); @@ -235,26 +214,29 @@ public class DBRefUtilsTest public void testSearchRefs_withMapping() { DBRefEntry target = new DBRefEntry("EMBL", "2", "A1234"); - final Mapping map1 = new Mapping(new MapList(new int[] { 1, 1 }, - new int[] { 1, 1 }, 1, 1)); + final Mapping map1 = new Mapping( + new MapList(new int[] + { 1, 1 }, new int[] { 1, 1 }, 1, 1)); target.setMap(map1); // these all match target iff mappings match DBRefEntry ref1 = new DBRefEntry("EMBL", "1", "A1234"); // no map: matches DBRefEntry ref2 = new DBRefEntry("EMBL", "1", "A1234"); // =map: matches - final Mapping map2 = new Mapping(new MapList(new int[] { 1, 1 }, - new int[] { 1, 1 }, 1, 1)); + final Mapping map2 = new Mapping( + new MapList(new int[] + { 1, 1 }, new int[] { 1, 1 }, 1, 1)); ref2.setMap(map2); // different map: no match DBRefEntry ref3 = new DBRefEntry("EMBL", "1", "A1234"); - final Mapping map3 = new Mapping(new MapList(new int[] { 1, 1 }, - new int[] { 1, 1 }, 2, 2)); + final Mapping map3 = new Mapping( + new MapList(new int[] + { 1, 1 }, new int[] { 1, 1 }, 2, 2)); ref3.setMap(map3); - List matches = DBRefUtils.searchRefs( - Arrays.asList(new DBRefEntry[] { - ref1, ref2, ref3 }), target, DBRefUtils.SEARCH_MODE_FULL); + List matches = DBRefUtils + .searchRefs(Arrays.asList(new DBRefEntry[] + { ref1, ref2, ref3 }), target, DBRefUtils.SEARCH_MODE_FULL); assertEquals(2, matches.size()); assertSame(ref1, matches.get(0)); assertSame(ref2, matches.get(1)); @@ -275,11 +257,13 @@ public class DBRefUtilsTest DBRefEntry ref4 = new DBRefEntry("EMBLCDS", "1", "A1235"); // no match // ref5 matches although it has a mapping - ignored DBRefEntry ref5 = new DBRefEntry("EMBL", "1", "A1234"); - ref5.setMap(new Mapping(new MapList(new int[] { 1, 1 }, new int[] { 1, - 1 }, 1, 1))); + ref5.setMap( + new Mapping(new MapList(new int[] + { 1, 1 }, new int[] { 1, 1 }, 1, 1))); - List dbrefs = Arrays.asList(new DBRefEntry[] { - ref1, ref2, ref3, ref4, ref5 }); + List dbrefs = Arrays + .asList(new DBRefEntry[] + { ref1, ref2, ref3, ref4, ref5 }); List matches = DBRefUtils.searchRefs(dbrefs, "A1234"); assertEquals(3, matches.size()); assertSame(ref1, matches.get(0)); @@ -304,12 +288,14 @@ public class DBRefUtilsTest DBRefEntry ref4 = new DBRefEntry("EMBLCDS", "1", "A1234"); // no match // ref5 matches although it has a mapping - ignored DBRefEntry ref5 = new DBRefEntry("EMBL", "1", "A1237"); - ref5.setMap(new Mapping(new MapList(new int[] { 1, 1 }, new int[] { 1, - 1 }, 1, 1))); - - List matches = DBRefUtils.searchRefs( - Arrays.asList(new DBRefEntry[] { - ref1, ref2, ref3, ref4, ref5 }), target, DBRefUtils.SEARCH_MODE_FULL); + ref5.setMap( + new Mapping(new MapList(new int[] + { 1, 1 }, new int[] { 1, 1 }, 1, 1))); + + List matches = DBRefUtils + .searchRefs(Arrays.asList(new DBRefEntry[] + { ref1, ref2, ref3, ref4, ref5 }), target, + DBRefUtils.SEARCH_MODE_FULL); assertEquals(4, matches.size()); assertSame(ref1, matches.get(0)); assertSame(ref2, matches.get(1));