import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.IOException;
import java.io.PrintStream;
+import java.util.HashMap;
import org.testng.Assert;
import org.testng.FileAssert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
+import MCview.PDBfile;
+
public class SiftsClientTest
{
private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
+ public static final String DEFAULT_SIFTS_DOWNLOAD_DIR = System
+ .getProperty("user.home")
+ + File.separatorChar
+ + ".sifts_downloads" + File.separatorChar;
+
private String testPDBId = "1a70";
private SiftsClient siftsClient = null;
+ "AYKVTLVTPTGNVEFQCPDDVYILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDD"
+ "QSFLDDDQIDEGWVLTCAAYPVSDVTIETHKEEELTA.", 1, 147);
- int[][] expectedMapping = { { -1, 0 }, { -1, 1 }, { -1, 2 }, { -1, 3 },
- { -1, 4 }, { -1, 5 }, { -1, 6 }, { -1, 7 }, { -1, 8 }, { -1, 9 },
- { -1, 10 }, { -1, 11 }, { -1, 12 }, { -1, 13 }, { -1, 14 },
- { -1, 15 }, { -1, 16 }, { -1, 17 }, { -1, 18 }, { -1, 19 },
- { -1, 20 }, { -1, 21 }, { -1, 22 }, { -1, 23 }, { -1, 24 },
- { -1, 25 }, { -1, 26 }, { -1, 27 }, { -1, 28 }, { -1, 29 },
- { -1, 30 }, { -1, 31 }, { -1, 32 }, { -1, 33 }, { -1, 34 },
- { -1, 35 }, { -1, 36 }, { -1, 37 }, { -1, 38 }, { -1, 39 },
- { -1, 40 }, { -1, 41 }, { -1, 42 }, { -1, 43 }, { -1, 44 },
- { -1, 45 }, { -1, 46 }, { -1, 47 }, { -1, 48 }, { -1, 49 },
- { -1, 50 }, { 1, 51 }, { 2, 52 }, { 3, 53 }, { 4, 54 }, { 5, 55 },
- { 6, 56 }, { 7, 57 }, { 8, 58 }, { 9, 59 }, { 10, 60 }, { 11, 61 },
- { 12, 62 }, { 13, 63 }, { 14, 64 }, { 15, 65 }, { 16, 66 },
- { 17, 67 }, { 18, 68 }, { 19, 69 }, { 20, 70 }, { 21, 71 },
- { 22, 72 }, { 23, 73 }, { 24, 74 }, { 25, 75 }, { 26, 76 },
- { 27, 77 }, { 28, 78 }, { 29, 79 }, { 30, 80 }, { 31, 81 },
- { 32, 82 }, { 33, 83 }, { 34, 84 }, { 35, 85 }, { 36, 86 },
- { 37, 87 }, { 38, 88 }, { 39, 89 }, { 40, 90 }, { 41, 91 },
- { 42, 92 }, { 43, 93 }, { 44, 94 }, { 45, 95 }, { 46, 96 },
- { 47, 97 }, { 48, 98 }, { 49, 99 }, { 50, 100 }, { 51, 101 },
- { 52, 102 }, { 53, 103 }, { 54, 104 }, { 55, 105 }, { 56, 106 },
- { 57, 107 }, { 58, 108 }, { 59, 109 }, { 60, 110 }, { 61, 111 },
- { 62, 112 }, { 63, 113 }, { 64, 114 }, { 65, 115 }, { 66, 116 },
- { 67, 117 }, { 68, 118 }, { 69, 119 }, { 70, 120 }, { 71, 121 },
- { 72, 122 }, { 73, 123 }, { 74, 124 }, { 75, 125 }, { 76, 126 },
- { 77, 127 }, { 78, 128 }, { 79, 129 }, { 80, 130 }, { 81, 131 },
- { 82, 132 }, { 83, 133 }, { 84, 134 }, { 85, 135 }, { 86, 136 },
- { 87, 137 }, { 88, 138 }, { 89, 139 }, { 90, 140 }, { 91, 141 },
- { 92, 142 }, { 93, 143 }, { 94, 144 }, { 95, 145 }, { 96, 146 },
- { 97, 147 } };
+ int u = SiftsClient.UNASSIGNED;
+ HashMap<Integer, int[]> expectedMapping = new HashMap<Integer, int[]>();
+
+ @BeforeTest(alwaysRun = true)
+ public void populateExpectedMapping() throws SiftsException
+ {
+ for (int x = 1; x <= 97; x++)
+ {
+ expectedMapping.put(50 + x, new int[] { x, u });
+ }
+ }
+
@BeforeTest(alwaysRun = true)
- public void setUpSiftsClient()
+ public void setUpSiftsClient() throws SiftsException
{
// SIFTs entries are updated weekly - so use saved SIFTs file to enforce
// test reproducibility
+ SiftsSettings.setSiftDownloadDirectory(jalview.bin.Cache.getDefault(
+ "sifts_download_dir", DEFAULT_SIFTS_DOWNLOAD_DIR));
+
File testSiftsFile = new File("test/jalview/io/" + testPDBId
+ ".xml.gz");
- siftsClient = new SiftsClient(testPDBId, testSiftsFile);
+ PDBfile pdbFile = new PDBfile(false, false, false);
+ pdbFile.setId(testPDBId);
+ siftsClient = new SiftsClient(pdbFile, testSiftsFile);
}
@AfterTest(alwaysRun = true)
}
@Test(groups = { "Functional" })
- public void getSIFTsFileTest()
+ public void getSIFTsFileTest() throws SiftsException
{
Assert.assertTrue(SiftsClient.deleteSiftsFileByPDBId(testPDBId));
SiftsClient.getSiftsFile(testPDBId);
}
@Test(groups = { "Functional" })
- public void downloadSiftsFileTest()
+ public void downloadSiftsFileTest() throws SiftsException
{
// Assert that file isn't yet downloaded - if already downloaded, assert it
// is deleted
Assert.assertTrue(SiftsClient.deleteSiftsFileByPDBId(testPDBId));
- File siftsFile = SiftsClient.downloadSiftsFile(testPDBId);
- FileAssert.assertFile(siftsFile);
- SiftsClient.downloadSiftsFile(testPDBId);
+ File siftsFile;
+ try
+ {
+ siftsFile = SiftsClient.downloadSiftsFile(testPDBId);
+ FileAssert.assertFile(siftsFile);
+ SiftsClient.downloadSiftsFile(testPDBId);
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
}
@Test(groups = { "Functional" })
try
{
- int[][] actualMapping = siftsClient.getGreedyMapping("A", testSeq,
+ HashMap<Integer, int[]> actualMapping = siftsClient.getGreedyMapping(
+ "A", testSeq,
null);
Assert.assertEquals(actualMapping, expectedMapping);
Assert.assertEquals(testSeq.getStart(), 1);
}
@Test(groups = { "Functional" })
+ private void getAtomIndexTest()
+ {
+ // siftsClient.getAtomIndex(1, null);
+ // Assert.assertTrue(true);
+ }
+
+ @Test(
+ groups = { "Functional" },
+ expectedExceptions = IllegalArgumentException.class)
+ private void getAtomIndexNullTest()
+ {
+ siftsClient.getAtomIndex(1, null);
+ }
+
+ @Test(groups = { "Functional" })
+ private void padWithGapsTest()
+ {
+
+ }
+
+ @Test(groups = { "Functional" })
+ private void populateAtomPositionsTest()
+ {
+
+ }
+
+ @Test(groups = { "Functional" })
public void getValidSourceDBRefTest()
{