Clover icon

Coverage Report

  1. Project Clover database Thu Dec 4 2025 14:43:25 GMT
  2. Package jalview.ws.sifts

File SiftsClientTest.java

 

Code metrics

4
235
26
1
536
440
31
0.13
9.04
26
1.19

Classes

Class Line # Actions
SiftsClientTest 55 235 31
0.4377358643.8%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
20    */
21    package jalview.ws.sifts;
22   
23    import static org.testng.Assert.assertEquals;
24    import static org.testng.Assert.assertTrue;
25   
26   
27    import java.io.File;
28    import java.io.IOException;
29    import java.util.ArrayList;
30    import java.util.HashMap;
31    import java.util.Iterator;
32    import java.util.Map;
33   
34    import org.testng.Assert;
35    import org.testng.FileAssert;
36    import org.testng.annotations.AfterTest;
37    import org.testng.annotations.BeforeClass;
38    import org.testng.annotations.BeforeTest;
39    import org.testng.annotations.Test;
40   
41    import jalview.api.DBRefEntryI;
42    import jalview.bin.Cache;
43    import jalview.datamodel.DBRefEntry;
44    import jalview.datamodel.DBRefSource;
45    import jalview.datamodel.Sequence;
46    import jalview.datamodel.SequenceI;
47    import jalview.gui.JvOptionPane;
48    import jalview.io.DataSourceType;
49    import jalview.structure.StructureMapping;
50    import jalview.xml.binding.sifts.Entry.Entity;
51    import mc_view.Atom;
52    import mc_view.PDBfile;
53   
54    @Test(enabled=false)
 
55    public class SiftsClientTest
56    {
57   
 
58  1 toggle @BeforeClass(alwaysRun = true)
59    public void setUpJvOptionPane()
60    {
61  1 JvOptionPane.setInteractiveMode(false);
62  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
63    }
64   
65    public static final String DEFAULT_SIFTS_DOWNLOAD_DIR = System
66    .getProperty("user.home")
67    + File.separatorChar
68    + ".sifts_downloads" + File.separatorChar;
69   
70    // FIXME 1a70 has no sifts mapping any more !!! all tests fail
71    private String testPDBId = "1a70";
72   
73    private SiftsClient siftsClient = null;
74   
75    SequenceI testSeq = new Sequence(
76    "P00221",
77    "MAAT..TTTMMG..MATTFVPKPQAPPMMAALPSNTGR..SLFGLKT.GSR..GGRMTMA"
78    + "AYKVTLVTPTGNVEFQCPDDVYILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDD"
79    + "QSFLDDDQIDEGWVLTCAAYPVSDVTIETHKEEELTA.", 1, 147);
80   
81    int u = SiftsClient.UNASSIGNED;
82   
83    HashMap<Integer, int[]> expectedMapping = new HashMap<Integer, int[]>();
84   
 
85  4 toggle @BeforeTest(alwaysRun = true)
86    public void populateExpectedMapping() throws SiftsException
87    {
88  4 expectedMapping.put(51, new int[] { 1, 2, 1 });
89  4 expectedMapping.put(52, new int[] { 2, 7, 2 });
90  4 expectedMapping.put(53, new int[] { 3, 12, 3 });
91  4 expectedMapping.put(54, new int[] { 4, 24, 4 });
92  4 expectedMapping.put(55, new int[] { 5, 33, 5 });
93  4 expectedMapping.put(56, new int[] { 6, 40, 6 });
94  4 expectedMapping.put(57, new int[] { 7, 47, 7 });
95  4 expectedMapping.put(58, new int[] { 8, 55, 8 });
96  4 expectedMapping.put(59, new int[] { 9, 62, 9 });
97  4 expectedMapping.put(60, new int[] { 10, 69, 10 });
98  4 expectedMapping.put(61, new int[] { 11, 76, 11 });
99  4 expectedMapping.put(62, new int[] { 12, 83, 12 });
100  4 expectedMapping.put(63, new int[] { 13, 87, 13 });
101  4 expectedMapping.put(64, new int[] { 14, 95, 14 });
102  4 expectedMapping.put(65, new int[] { 15, 102, 15 });
103  4 expectedMapping.put(66, new int[] { 16, 111, 16 });
104  4 expectedMapping.put(67, new int[] { 17, 122, 17 });
105  4 expectedMapping.put(68, new int[] { 18, 131, 18 });
106  4 expectedMapping.put(69, new int[] { 19, 137, 19 });
107  4 expectedMapping.put(70, new int[] { 20, 144, 20 });
108  4 expectedMapping.put(71, new int[] { 21, 152, 21 });
109  4 expectedMapping.put(72, new int[] { 22, 160, 22 });
110  4 expectedMapping.put(73, new int[] { 23, 167, 23 });
111  4 expectedMapping.put(74, new int[] { 24, 179, 24 });
112  4 expectedMapping.put(75, new int[] { 25, 187, 25 });
113  4 expectedMapping.put(76, new int[] { 26, 195, 26 });
114  4 expectedMapping.put(77, new int[] { 27, 203, 27 });
115  4 expectedMapping.put(78, new int[] { 28, 208, 28 });
116  4 expectedMapping.put(79, new int[] { 29, 213, 29 });
117  4 expectedMapping.put(80, new int[] { 30, 222, 30 });
118  4 expectedMapping.put(81, new int[] { 31, 231, 31 });
119  4 expectedMapping.put(82, new int[] { 32, 240, 32 });
120  4 expectedMapping.put(83, new int[] { 33, 244, 33 });
121  4 expectedMapping.put(84, new int[] { 34, 252, 34 });
122  4 expectedMapping.put(85, new int[] { 35, 260, 35 });
123  4 expectedMapping.put(86, new int[] { 36, 268, 36 });
124  4 expectedMapping.put(87, new int[] { 37, 275, 37 });
125  4 expectedMapping.put(88, new int[] { 38, 287, 38 });
126  4 expectedMapping.put(89, new int[] { 39, 293, 39 });
127  4 expectedMapping.put(90, new int[] { 40, 299, 40 });
128  4 expectedMapping.put(91, new int[] { 41, 310, 41 });
129  4 expectedMapping.put(92, new int[] { 42, 315, 42 });
130  4 expectedMapping.put(93, new int[] { 43, 319, 43 });
131  4 expectedMapping.put(94, new int[] { 44, 325, 44 });
132  4 expectedMapping.put(95, new int[] { 45, 331, 45 });
133  4 expectedMapping.put(96, new int[] { 46, 337, 46 });
134  4 expectedMapping.put(97, new int[] { 47, 343, 47 });
135  4 expectedMapping.put(98, new int[] { 48, 349, 48 });
136  4 expectedMapping.put(99, new int[] { 49, 354, 49 });
137  4 expectedMapping.put(100, new int[] { 50, 358, 50 });
138  4 expectedMapping.put(101, new int[] { 51, 367, 51 });
139  4 expectedMapping.put(102, new int[] { 52, 375, 52 });
140  4 expectedMapping.put(103, new int[] { 53, 384, 53 });
141  4 expectedMapping.put(104, new int[] { 54, 391, 54 });
142  4 expectedMapping.put(105, new int[] { 55, 395, 55 });
143  4 expectedMapping.put(106, new int[] { 56, 401, 56 });
144  4 expectedMapping.put(107, new int[] { 57, 409, 57 });
145  4 expectedMapping.put(108, new int[] { 58, 417, 58 });
146  4 expectedMapping.put(109, new int[] { 59, 426, 59 });
147  4 expectedMapping.put(110, new int[] { 60, 434, 60 });
148  4 expectedMapping.put(111, new int[] { 61, 442, 61 });
149  4 expectedMapping.put(112, new int[] { 62, 451, 62 });
150  4 expectedMapping.put(113, new int[] { 63, 457, 63 });
151  4 expectedMapping.put(114, new int[] { 64, 468, 64 });
152  4 expectedMapping.put(115, new int[] { 65, 476, 65 });
153  4 expectedMapping.put(116, new int[] { 66, 484, 66 });
154  4 expectedMapping.put(117, new int[] { 67, 492, 67 });
155  4 expectedMapping.put(118, new int[] { 68, 500, 68 });
156  4 expectedMapping.put(119, new int[] { 69, 509, 69 });
157  4 expectedMapping.put(120, new int[] { 70, 517, 70 });
158  4 expectedMapping.put(121, new int[] { 71, 525, 71 });
159  4 expectedMapping.put(122, new int[] { 72, 534, 72 });
160  4 expectedMapping.put(123, new int[] { 73, 538, 73 });
161  4 expectedMapping.put(124, new int[] { 74, 552, 74 });
162  4 expectedMapping.put(125, new int[] { 75, 559, 75 });
163  4 expectedMapping.put(126, new int[] { 76, 567, 76 });
164  4 expectedMapping.put(127, new int[] { 77, 574, 77 });
165  4 expectedMapping.put(128, new int[] { 78, 580, 78 });
166  4 expectedMapping.put(129, new int[] { 79, 585, 79 });
167  4 expectedMapping.put(130, new int[] { 80, 590, 80 });
168  4 expectedMapping.put(131, new int[] { 81, 602, 81 });
169  4 expectedMapping.put(132, new int[] { 82, 609, 82 });
170  4 expectedMapping.put(133, new int[] { 83, 616, 83 });
171  4 expectedMapping.put(134, new int[] { 84, 622, 84 });
172  4 expectedMapping.put(135, new int[] { 85, 630, 85 });
173  4 expectedMapping.put(136, new int[] { 86, 637, 86 });
174  4 expectedMapping.put(137, new int[] { 87, 644, 87 });
175  4 expectedMapping.put(138, new int[] { 88, 652, 88 });
176  4 expectedMapping.put(139, new int[] { 89, 661, 89 });
177  4 expectedMapping.put(140, new int[] { 90, 668, 90 });
178  4 expectedMapping.put(141, new int[] { 91, 678, 91 });
179  4 expectedMapping.put(142, new int[] { 92, 687, 92 });
180  4 expectedMapping.put(143, new int[] { 93, 696, 93 });
181  4 expectedMapping.put(144, new int[] { 94, 705, 94 });
182  4 expectedMapping.put(145, new int[] { 95, 714, 95 });
183  4 expectedMapping.put(146, new int[] { 96, 722, 96 });
184  4 expectedMapping.put(147, new int[] { 97, 729, 97 });
185    }
186   
 
187  4 toggle @BeforeTest(alwaysRun = true)
188    public void setUpSiftsClient() throws SiftsException, IOException
189    {
190    // read test props before manipulating config
191  4 Cache.loadProperties("test/jalview/io/testProps.jvprops");
192    // SIFTs entries are updated weekly - so use saved SIFTs file to enforce
193    // test reproducibility
194  4 SiftsSettings.setSiftDownloadDirectory(jalview.bin.Cache.getDefault(
195    "sifts_download_dir", DEFAULT_SIFTS_DOWNLOAD_DIR));
196  4 SiftsSettings.setMapWithSifts(true);
197  4 SiftsSettings.setCacheThresholdInDays("2");
198  4 SiftsSettings.setFailSafePIDThreshold("70");
199  4 PDBfile pdbFile;
200   
201  4 pdbFile = new PDBfile(false, false, false, "test/jalview/io/"
202    + testPDBId + ".pdb", DataSourceType.FILE);
203    // TODO: this uses a network connection - we should mock the sifts
204    // testPDBId.xml.gz
205  4 try {
206  4 siftsClient = new SiftsClient(pdbFile);
207    }
208    catch (Exception x)
209    {
210  0 System.err.println("SiftsClientTest setupSiftsClient failed.");
211    }
212    }
213   
 
214  3 toggle @AfterTest(alwaysRun = true)
215    public void cleanUpSiftsClient()
216    {
217  3 siftsClient = null;
218    }
219   
 
220  1 toggle @Test(groups = { "Functional" })
221    public void testSIFTsDownloadURL()
222    {
223  1 String expectedUrl = "https://ftp.ebi.ac.uk/pub/databases/msd/sifts/split_xml/xy/1xyz.sifts.xml.gz";
224  1 Assert.assertEquals(SiftsClient.getDownloadUrlFor("1xyz.sifts.xml.gz"),
225    expectedUrl);
226    }
227   
 
228  0 toggle @Test(groups = { "Network" })
229    public void getSIFTsFileTest() throws SiftsException, IOException
230    {
231  0 File siftsFile;
232  0 siftsFile = SiftsClient.downloadSiftsFile(testPDBId);
233  0 FileAssert.assertFile(siftsFile);
234  0 long t1 = siftsFile.lastModified();
235   
236    // re-read file should be returned from cache
237  0 siftsFile = SiftsClient.getSiftsFile(testPDBId);
238  0 FileAssert.assertFile(siftsFile);
239  0 long t2 = siftsFile.lastModified();
240  0 assertEquals(t1, t2);
241   
242    /*
243    * force fetch by having 0 expiry of cache
244    * also wait one second, because file timestamp does not
245    * give millisecond resolution :-(
246    */
247  0 synchronized (this)
248    {
249  0 try
250    {
251  0 wait(1000);
252    } catch (InterruptedException e)
253    {
254    }
255    }
256  0 SiftsSettings.setCacheThresholdInDays("0");
257  0 siftsFile = SiftsClient.getSiftsFile(testPDBId);
258  0 FileAssert.assertFile(siftsFile);
259  0 long t3 = siftsFile.lastModified();
260  0 assertTrue(t3 > t2, "file timestamp unchanged at " + t3);
261   
262  0 SiftsSettings.setCacheThresholdInDays("2");
263    }
264   
 
265  0 toggle @Test(groups = { "Network" })
266    public void downloadSiftsFileTest() throws SiftsException, IOException
267    {
268    // Assert that file isn't yet downloaded - if already downloaded, assert it
269    // is deleted
270  0 Assert.assertTrue(SiftsClient.deleteSiftsFileByPDBId(testPDBId));
271  0 File siftsFile;
272  0 siftsFile = SiftsClient.downloadSiftsFile(testPDBId);
273  0 FileAssert.assertFile(siftsFile);
274  0 SiftsClient.downloadSiftsFile(testPDBId);
275    }
276   
 
277  0 toggle @Test(groups = { "Network" })
278    public void getAllMappingAccessionTest()
279    {
280  0 Assert.assertNotNull(siftsClient);
281  0 Assert.assertNotNull(siftsClient.getAllMappingAccession());
282  0 Assert.assertTrue(siftsClient.getAllMappingAccession().size() > 1);
283    }
284   
 
285  0 toggle @Test(groups = { "Network" })
286    public void getGreedyMappingTest()
287    {
288  0 Assert.assertNotNull(siftsClient);
289  0 Assert.assertNotNull(testSeq);
290  0 Assert.assertNotNull(expectedMapping);
291   
292    // TODO delete when auto-fetching of DBRefEntry is implemented
293  0 DBRefEntry dbRef = new DBRefEntry("uniprot", "", "P00221");
294  0 testSeq.addDBRef(dbRef);
295    // testSeq.setSourceDBRef(dbRef);
296   
297  0 try
298    {
299  0 HashMap<Integer, int[]> actualMapping = siftsClient.getGreedyMapping(
300    "A", testSeq, null);
301  0 Assert.assertEquals(testSeq.getStart(), 1);
302  0 Assert.assertEquals(testSeq.getEnd(), 147);
303    // Can't do Assert.assertEquals(actualMapping, expectedMapping);
304    // because this fails in our version of TestNG
305  0 Assert.assertEquals(actualMapping.size(), expectedMapping.size());
306  0 Iterator<Map.Entry<Integer, int[]>> it = expectedMapping.entrySet()
307    .iterator();
308  0 while (it.hasNext())
309    {
310  0 Map.Entry<Integer, int[]> pair = it.next();
311  0 Assert.assertTrue(actualMapping.containsKey(pair.getKey()));
312  0 Assert.assertEquals(actualMapping.get(pair.getKey()),
313    pair.getValue());
314    }
315   
316    } catch (Exception e)
317    {
318  0 e.printStackTrace();
319  0 Assert.fail("Exception thrown while generating mapping...");
320    }
321    }
322   
 
323  0 toggle @Test(groups = { "Network" })
324    private void getAtomIndexTest()
325    {
326  0 ArrayList<Atom> atoms = new ArrayList<Atom>();
327  0 Atom atom = new Atom(u, u, u);
328  0 atom.resNumber = 43;
329  0 atom.atomIndex = 7;
330  0 atoms.add(atom);
331  0 int actualAtomIndex = siftsClient.getAtomIndex(1, atoms);
332  0 Assert.assertEquals(actualAtomIndex, SiftsClient.UNASSIGNED);
333  0 actualAtomIndex = siftsClient.getAtomIndex(43, atoms);
334  0 Assert.assertEquals(actualAtomIndex, 7);
335    }
336   
 
337  0 toggle @Test(
338    groups = { "Network" },
339    expectedExceptions = IllegalArgumentException.class)
340    private void getAtomIndexNullTest()
341    {
342  0 siftsClient.getAtomIndex(1, null);
343    }
344   
 
345  0 toggle @Test(groups = { "Network" })
346    private void padWithGapsTest()
347    {
348   
349    }
350   
 
351  0 toggle @Test(
352    groups = { "Network" },
353    expectedExceptions = SiftsException.class)
354    private void populateAtomPositionsNullTest1()
355    throws IllegalArgumentException, SiftsException
356    {
357  0 siftsClient.populateAtomPositions(null, null);
358    }
359   
 
360  0 toggle @Test(
361    groups = { "Network" },
362    expectedExceptions = SiftsException.class)
363    private void populateAtomPositionsNullTest2()
364    throws IllegalArgumentException, SiftsException
365    {
366  0 siftsClient.populateAtomPositions("A", null);
367    }
368   
 
369  0 toggle @Test(groups = { "Network" })
370    public void getValidSourceDBRefTest() throws SiftsException
371    {
372  0 DBRefEntryI actualValidSrcDBRef = siftsClient
373    .getValidSourceDBRef(testSeq);
374  0 DBRefEntryI expectedDBRef = new DBRefEntry();
375  0 expectedDBRef.setSource(DBRefSource.UNIPROT);
376  0 expectedDBRef.setAccessionId("P00221");
377  0 expectedDBRef.setVersion("");
378  0 Assert.assertEquals(actualValidSrcDBRef, expectedDBRef);
379    }
380   
 
381  0 toggle @Test(
382    groups = { "Network" },
383    expectedExceptions = SiftsException.class)
384    public void getValidSourceDBRefExceptionTest() throws SiftsException
385    {
386  0 SequenceI invalidTestSeq = new Sequence("testSeq", "ABCDEFGH");
387  0 siftsClient.getValidSourceDBRef(invalidTestSeq);
388    }
389   
 
390  0 toggle @Test(
391    groups = { "Network" },
392    expectedExceptions = SiftsException.class)
393    public void getValidSourceDBRefExceptionXTest() throws SiftsException
394    {
395  0 SequenceI invalidTestSeq = new Sequence("testSeq", "ABCDEFGH");
396  0 DBRefEntry invalidDBRef = new DBRefEntry();
397  0 invalidDBRef.setAccessionId("BLAR"); // note no version is set, so also
398    // invalid
399  0 invalidTestSeq.addDBRef(invalidDBRef);
400  0 siftsClient.getValidSourceDBRef(invalidTestSeq);
401    }
402   
 
403  0 toggle @Test(groups = { "Network" })
404    public void isValidDBRefEntryTest()
405    {
406  0 DBRefEntryI validDBRef = new DBRefEntry();
407  0 validDBRef.setSource(DBRefSource.UNIPROT);
408  0 validDBRef.setAccessionId("P00221");
409  0 validDBRef.setVersion("");
410  0 Assert.assertTrue(siftsClient.isValidDBRefEntry(validDBRef));
411    }
412   
 
413  0 toggle @Test(groups = { "Network" })
414    public void getSiftsStructureMappingTest() throws SiftsException
415    {
416  0 Assert.assertTrue(SiftsSettings.isMapWithSifts());
417  0 StructureMapping strucMapping = siftsClient.getSiftsStructureMapping(
418    testSeq, testPDBId, "A");
419  0 String expectedMappingOutput = "\nSequence ⟷ Structure mapping details\n"
420    + "Method: SIFTS\n\n"
421    + "P00221 : 51 - 147 Maps to \n"
422    + "1A70|A : 1 - 97\n\n"
423    + "P00221 AAYKVTLVTPTGNVEFQCPDDVYILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDDQSFLD\n"
424    + " |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||\n"
425    + "1A70|A AAYKVTLVTPTGNVEFQCPDDVYILDAAEEEGIDLPYSCRAGSCSSCAGKLKTGSLNQDDQSFLD\n\n"
426   
427    + "P00221 DDQIDEGWVLTCAAYPVSDVTIETHKEEELTA\n"
428    + " |||||||||||||||||||||||||| |||||\n"
429    + "1A70|A DDQIDEGWVLTCAAYPVSDVTIETHKKEELTA\n\n" +
430   
431    "Length of alignment = 97\n" + "Percentage ID = 98.97\n";
432   
433  0 Assert.assertEquals(strucMapping.getMappingDetailsOutput(),
434    expectedMappingOutput);
435   
436    // Can't do Assert.assertEquals(strucMapping.getMapping(), expectedMapping);
437    // because this fails in our version of TestNG
438  0 Assert.assertEquals(strucMapping.getMapping().size(),
439    expectedMapping.size());
440  0 Iterator<Map.Entry<Integer, int[]>> it = expectedMapping.entrySet()
441    .iterator();
442  0 while (it.hasNext())
443    {
444  0 Map.Entry<Integer, int[]> pair = it.next();
445  0 Assert.assertTrue(strucMapping.getMapping()
446    .containsKey(pair.getKey()));
447  0 Assert.assertEquals(strucMapping.getMapping().get(pair.getKey()),
448    pair.getValue());
449    }
450    }
451   
 
452  0 toggle @Test(groups = { "Network" })
453    public void getEntityCountTest()
454    {
455  0 int actualEntityCount = siftsClient.getEntityCount();
456  0 System.out.println("actual entity count : " + actualEntityCount);
457  0 Assert.assertEquals(actualEntityCount, 1);
458    }
459   
 
460  0 toggle @Test(groups = { "Network" })
461    public void getDbAccessionIdTest()
462    {
463  0 String actualDbAccId = siftsClient.getDbAccessionId();
464  0 System.out.println("Actual Db Accession Id: " + actualDbAccId);
465  0 Assert.assertEquals(actualDbAccId, "1a70");
466    }
467   
 
468  0 toggle @Test(groups = { "Network" })
469    public void getDbCoordSysTest()
470    {
471  0 String actualDbCoordSys = siftsClient.getDbCoordSys();
472  0 System.out.println("Actual DbCoordSys: " + actualDbCoordSys);
473  0 Assert.assertEquals(actualDbCoordSys, "PDBe");
474    }
475   
 
476  0 toggle @Test(groups = { "Network" })
477    public void getDbSourceTest()
478    {
479  0 String actualDbSource = siftsClient.getDbSource();
480  0 System.out.println("Actual DbSource: " + actualDbSource);
481  0 Assert.assertEquals(actualDbSource, "PDBe");
482    }
483   
 
484  0 toggle @Test(groups = { "Network" })
485    public void getDbVersionTest()
486    {
487  0 String actualDbVersion = siftsClient.getDbVersion();
488  0 System.out.println("Actual DbVersion: " + actualDbVersion);
489  0 Assert.assertEquals(actualDbVersion, "2.0");
490    }
491   
 
492  0 toggle @Test(groups = { "Network" })
493    public void getEntityByMostOptimalMatchedIdTest1() throws IOException,
494    SiftsException
495    {
496  0 SiftsClient siftsClientX = null;
497  0 PDBfile pdbFile;
498  0 pdbFile = new PDBfile(false, false, false, "test/jalview/io/2nq2"
499    + ".pdb", DataSourceType.FILE);
500  0 siftsClientX = new SiftsClient(pdbFile);
501  0 Entity entityA = siftsClientX.getEntityByMostOptimalMatchedId("A");
502  0 Assert.assertEquals(entityA.getEntityId(), "A");
503  0 Entity entityB = siftsClientX.getEntityByMostOptimalMatchedId("B");
504  0 Assert.assertEquals(entityB.getEntityId(), "C");
505  0 Entity entityC = siftsClientX.getEntityByMostOptimalMatchedId("C");
506  0 Assert.assertEquals(entityC.getEntityId(), "B");
507  0 Entity entityD = siftsClientX.getEntityByMostOptimalMatchedId("D");
508  0 Assert.assertEquals(entityD.getEntityId(), "D");
509   
510    }
511   
 
512  0 toggle @Test(groups = { "Network" })
513    public void getEntityByMostOptimalMatchedIdTest2() throws IOException,
514    SiftsException
515    {
516    // This test is for a SIFTS file in which entity A should map to chain P for
517    // the given PDB Id. All the other chains shouldn't be mapped as there are
518    // no SIFTS entity records for them.
519  0 SiftsClient siftsClientX = null;
520  0 PDBfile pdbFile;
521  0 pdbFile = new PDBfile(false, false, false, "test/jalview/io/3ucu.cif",
522    DataSourceType.FILE);
523  0 siftsClientX = new SiftsClient(pdbFile);
524  0 Entity entityA = siftsClientX.getEntityByMostOptimalMatchedId("P");
525  0 Entity entityP = siftsClientX.getEntityByMostOptimalMatchedId("A");
526  0 Entity entityR = siftsClientX.getEntityByMostOptimalMatchedId("R");
527  0 Assert.assertEquals(entityA.getEntityId(), "A");
528  0 Assert.assertNotEquals(entityR, "A");
529  0 Assert.assertNotEquals(entityP, "A");
530  0 Assert.assertNotEquals(entityR, "R");
531  0 Assert.assertNotEquals(entityP, "P");
532  0 Assert.assertNull(entityR);
533  0 Assert.assertNull(entityP);
534   
535    }
536    }