package jalview.ws.sifts;
import jalview.api.DBRefEntryI;
+import jalview.bin.Cache;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.Sequence;
import jalview.datamodel.SequenceI;
import jalview.io.AppletFormatAdapter;
import jalview.structure.StructureMapping;
+import jalview.xml.binding.sifts.Entry.Entity;
import java.io.File;
import java.io.IOException;
@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 });
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
{
+ // read test props before manipulating config
+ Cache.loadProperties("test/jalview/io/testProps.jvprops");
// SIFTs entries are updated weekly - so use saved SIFTs file to enforce
// test reproducibility
new SiftsSettings();
}
}
-
@Test(groups = { "Functional" })
public void getAllMappingAccessionTest()
{
// TODO delete when auto-fetching of DBRefEntry is implemented
DBRefEntry dbRef = new DBRefEntry("uniprot", "", "P00221");
- dbRef.setStartRes(1);
- dbRef.setEndRes(147);
testSeq.addDBRef(dbRef);
// testSeq.setSourceDBRef(dbRef);
try
{
HashMap<Integer, int[]> actualMapping = siftsClient.getGreedyMapping(
- "A", testSeq,
- null);
+ "A", testSeq, null);
Assert.assertEquals(testSeq.getStart(), 1);
Assert.assertEquals(testSeq.getEnd(), 147);
Assert.assertEquals(actualMapping, expectedMapping);
private void populateAtomPositionsNullTest1()
throws IllegalArgumentException, SiftsException
{
- siftsClient.populateAtomPositions(null, null);
-
+ siftsClient.populateAtomPositions(null, null);
}
@Test(
DBRefEntryI expectedDBRef = new DBRefEntry();
expectedDBRef.setSource(DBRefSource.UNIPROT);
expectedDBRef.setAccessionId("P00221");
- expectedDBRef.setStartRes(1);
- expectedDBRef.setEndRes(147);
expectedDBRef.setVersion("");
Assert.assertEquals(actualValidSrcDBRef, expectedDBRef);
} catch (Exception e)
expectedExceptions = SiftsException.class)
public void getValidSourceDBRefExceptionTest() throws SiftsException
{
- SequenceI invalidTestSeq = new Sequence("testSeq", "ABCDEFGH");
+ SequenceI invalidTestSeq = new Sequence("testSeq", "ABCDEFGH");
try
{
siftsClient.getValidSourceDBRef(invalidTestSeq);
DBRefEntryI validDBRef = new DBRefEntry();
validDBRef.setSource(DBRefSource.UNIPROT);
validDBRef.setAccessionId("P00221");
- validDBRef.setStartRes(1);
- validDBRef.setEndRes(147);
validDBRef.setVersion("");
Assert.assertTrue(siftsClient.isValidDBRefEntry(validDBRef));
}
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"
System.out.println("Actual DbVersion: " + actualDbVersion);
Assert.assertEquals(actualDbVersion, "2.0");
}
+
+ @Test(groups = { "Functional" })
+ public void getEntityByMostOptimalMatchedIdTest1()
+ {
+ SiftsClient siftsClientX = null;
+ PDBfile pdbFile;
+ try
+ {
+ pdbFile = new PDBfile(false, false, false, "test/jalview/io/2nq2"
+ + ".pdb", AppletFormatAdapter.FILE);
+ siftsClientX = new SiftsClient(pdbFile);
+ } catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ Entity entityA = siftsClientX.getEntityByMostOptimalMatchedId("A");
+ Assert.assertEquals(entityA.getEntityId(), "A");
+ Entity entityB = siftsClientX.getEntityByMostOptimalMatchedId("B");
+ Assert.assertEquals(entityB.getEntityId(), "C");
+ Entity entityC = siftsClientX.getEntityByMostOptimalMatchedId("C");
+ Assert.assertEquals(entityC.getEntityId(), "B");
+ Entity entityD = siftsClientX.getEntityByMostOptimalMatchedId("D");
+ 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", AppletFormatAdapter.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);
+
+ }
}