X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=test%2Fjalview%2Fws%2Fsifts%2FSiftsClientTest.java;h=45c5412545aa45a47f6478ff37c4ac0fa8da59a8;hb=483e7163b1fb8d4bcb9393014816c944befce328;hp=d3b485e867292fd684304d9f12e590a2bac25f0e;hpb=4bdfd889545ff56e3b697f7b59b0c5320cf6028f;p=jalview.git diff --git a/test/jalview/ws/sifts/SiftsClientTest.java b/test/jalview/ws/sifts/SiftsClientTest.java index d3b485e..45c5412 100644 --- a/test/jalview/ws/sifts/SiftsClientTest.java +++ b/test/jalview/ws/sifts/SiftsClientTest.java @@ -26,7 +26,8 @@ import jalview.datamodel.DBRefEntry; import jalview.datamodel.DBRefSource; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceI; -import jalview.io.AppletFormatAdapter; +import jalview.gui.JvOptionPane; +import jalview.io.DataSourceType; import jalview.structure.StructureMapping; import jalview.xml.binding.sifts.Entry.Entity; @@ -38,6 +39,7 @@ import java.util.HashMap; import org.testng.Assert; import org.testng.FileAssert; import org.testng.annotations.AfterTest; +import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeTest; import org.testng.annotations.Test; @@ -47,6 +49,13 @@ import MCview.PDBfile; public class SiftsClientTest { + @BeforeClass(alwaysRun = true) + public void setUpJvOptionPane() + { + JvOptionPane.setInteractiveMode(false); + JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); + } + public static final String DEFAULT_SIFTS_DOWNLOAD_DIR = System .getProperty("user.home") + File.separatorChar @@ -68,7 +77,7 @@ public class SiftsClientTest @BeforeTest(alwaysRun = true) public void populateExpectedMapping() throws SiftsException - { + { expectedMapping.put(51, new int[] { 1, 2 }); expectedMapping.put(52, new int[] { 2, 7 }); expectedMapping.put(53, new int[] { 3, 12 }); @@ -166,8 +175,8 @@ public class SiftsClientTest expectedMapping.put(145, new int[] { 95, 714 }); expectedMapping.put(146, new int[] { 96, 722 }); expectedMapping.put(147, new int[] { 97, 729 }); - } - + } + @BeforeTest(alwaysRun = true) public void setUpSiftsClient() throws SiftsException { @@ -185,7 +194,7 @@ public class SiftsClientTest try { pdbFile = new PDBfile(false, false, false, "test/jalview/io/" - + testPDBId + ".pdb", AppletFormatAdapter.FILE); + + testPDBId + ".pdb", DataSourceType.FILE); siftsClient = new SiftsClient(pdbFile); } catch (Exception e) { @@ -236,7 +245,6 @@ public class SiftsClientTest } } - @Test(groups = { "Functional" }) public void getAllMappingAccessionTest() { @@ -260,8 +268,7 @@ public class SiftsClientTest try { HashMap actualMapping = siftsClient.getGreedyMapping( - "A", testSeq, - null); + "A", testSeq, null); Assert.assertEquals(testSeq.getStart(), 1); Assert.assertEquals(testSeq.getEnd(), 147); Assert.assertEquals(actualMapping, expectedMapping); @@ -306,7 +313,7 @@ public class SiftsClientTest private void populateAtomPositionsNullTest1() throws IllegalArgumentException, SiftsException { - siftsClient.populateAtomPositions(null, null); + siftsClient.populateAtomPositions(null, null); } @Test( @@ -340,7 +347,7 @@ public class SiftsClientTest expectedExceptions = SiftsException.class) public void getValidSourceDBRefExceptionTest() throws SiftsException { - SequenceI invalidTestSeq = new Sequence("testSeq", "ABCDEFGH"); + SequenceI invalidTestSeq = new Sequence("testSeq", "ABCDEFGH"); try { siftsClient.getValidSourceDBRef(invalidTestSeq); @@ -389,8 +396,8 @@ public class SiftsClientTest testSeq, testPDBId, "A"); String expectedMappingOutput = "\nSequence ⟷ Structure mapping details\n" + "Method: SIFTS\n\n" - + "P00221 : 1 - 97 Maps to \n" - + "1A70|A : 51 - 147\n\n" + + "P00221 : 51 - 147 Maps to \n" + + "1A70|A : 1 - 97\n\n" + "P00221 AAYKVTLVTPTGNVEFQCPDDVYILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDDQSFLD\n" + " |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n" + "1A70|A AAYKVTLVTPTGNVEFQCPDDVYILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDDQSFLD\n\n" @@ -451,14 +458,14 @@ public class SiftsClientTest } @Test(groups = { "Functional" }) - public void getEntityByMostOptimalMatchedIdTest() + public void getEntityByMostOptimalMatchedIdTest1() { SiftsClient siftsClientX = null; PDBfile pdbFile; try { pdbFile = new PDBfile(false, false, false, "test/jalview/io/2nq2" - + ".pdb", AppletFormatAdapter.FILE); + + ".pdb", DataSourceType.FILE); siftsClientX = new SiftsClient(pdbFile); } catch (Exception e) { @@ -474,4 +481,34 @@ public class SiftsClientTest Assert.assertEquals(entityD.getEntityId(), "D"); } + + @Test(groups = { "Functional" }) + public void getEntityByMostOptimalMatchedIdTest2() + { + // This test is for a SIFTS file in which entity A should map to chain P for + // the given PDB Id. All the other chains shouldn't be mapped as there are + // no SIFTS entity records for them. + SiftsClient siftsClientX = null; + PDBfile pdbFile; + try + { + pdbFile = new PDBfile(false, false, false, + "test/jalview/io/3ucu.cif", DataSourceType.FILE); + siftsClientX = new SiftsClient(pdbFile); + } catch (Exception e) + { + e.printStackTrace(); + } + Entity entityA = siftsClientX.getEntityByMostOptimalMatchedId("P"); + Entity entityP = siftsClientX.getEntityByMostOptimalMatchedId("A"); + Entity entityR = siftsClientX.getEntityByMostOptimalMatchedId("R"); + Assert.assertEquals(entityA.getEntityId(), "A"); + Assert.assertNotEquals(entityR, "A"); + Assert.assertNotEquals(entityP, "A"); + Assert.assertNotEquals(entityR, "R"); + Assert.assertNotEquals(entityP, "P"); + Assert.assertNull(entityR); + Assert.assertNull(entityP); + + } }