2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
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.
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.
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.
23 import static org.testng.Assert.assertEquals;
24 import static org.testng.AssertJUnit.assertTrue;
26 import jalview.bin.Cache;
27 import jalview.datamodel.AlignmentI;
28 import jalview.datamodel.SequenceFeature;
29 import jalview.datamodel.SequenceI;
30 import jalview.gui.JvOptionPane;
31 import jalview.structure.StructureImportSettings;
32 import jalview.structure.StructureImportSettings.StructureParser;
33 import jalview.ws.seqfetcher.DbSourceProxy;
35 import java.util.Arrays;
36 import java.util.List;
38 import org.testng.annotations.BeforeClass;
39 import org.testng.annotations.BeforeMethod;
40 import org.testng.annotations.Test;
42 public class PDBSequenceFetcherTest
45 @BeforeClass(alwaysRun = true)
46 public void setUpJvOptionPane()
48 JvOptionPane.setInteractiveMode(false);
49 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
54 @BeforeMethod(alwaysRun = true)
55 public void setUp() throws Exception
57 Cache.loadProperties("test/jalview/io/testProps.jvprops");
58 // ensure 'add annotation from structure' is selected
59 Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
60 Boolean.TRUE.toString());
61 Cache.applicationProperties.setProperty("ADD_SS_ANN",
62 Boolean.TRUE.toString());
64 sf = new SequenceFetcher(false);
68 * Test that RNA structure can be added by a call to the RNAML service.
70 * Note this test depends on http://arn-ibmc.in2p3.fr/api/compute/2d which is
71 * not always reliable.
75 @Test(groups = { "Network" }, enabled = true)
76 public void testRnaSeqRetrieve() throws Exception
78 Cache.applicationProperties.setProperty("PDB_DOWNLOAD_FORMAT", "PDB");
79 List<DbSourceProxy> sps = sf.getSourceProxy("PDB");
80 AlignmentI response = sps.get(0).getSequenceRecords("2GIS");
81 assertTrue(response != null);
82 assertTrue(response.getHeight() == 1);
83 for (SequenceI sq : response.getSequences())
85 assertTrue("No annotation transfered to sequence.",
86 sq.getAnnotation().length > 0);
87 assertTrue("No PDBEntry on sequence.",
88 sq.getAllPDBEntries().size() > 0);
90 "No RNA annotation on sequence, possibly http://arn-ibmc.in2p3.fr/api/compute/2d not available?",
95 @Test(groups = { "Network" }, enabled = true)
96 public void testPdbSeqRetrieve() throws Exception
98 StructureImportSettings.setDefaultStructureFileFormat("PDB");
99 StructureImportSettings
100 .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
102 testRetrieveProteinSeqFromPDB();
105 @Test(groups = { "Network" }, enabled = true)
106 public void testmmCifSeqRetrieve() throws Exception
108 StructureImportSettings.setDefaultStructureFileFormat("mmCIF");
109 testRetrieveProteinSeqFromPDB();
112 private class TestRetrieveObject
118 public TestRetrieveObject(String id, int expectedHeight)
122 this.expectedHeight = expectedHeight;
127 private List<TestRetrieveObject> toRetrieve = Arrays.asList(
128 new TestRetrieveObject("1QIP", 4),
129 new TestRetrieveObject("4IM2", 1));
131 private void testRetrieveProteinSeqFromPDB() throws Exception
133 List<DbSourceProxy> sps = sf.getSourceProxy("PDB");
134 for (TestRetrieveObject str : toRetrieve)
136 AlignmentI response = sps.get(0).getSequenceRecords(str.id);
137 assertTrue("No aligment for " + str.id, response != null);
138 assertEquals(response.getHeight(), str.expectedHeight,
139 "Number of chains for " + str.id);
140 for (SequenceI sq : response.getSequences())
142 assertTrue("No annotation transfered to sequence " + sq.getName(),
143 sq.getAnnotation().length > 0);
144 assertTrue("No PDBEntry on sequence " + sq.getName(),
145 sq.getAllPDBEntries().size() > 0);
146 // FIXME: should test that all residues extracted as sequences from
147 // chains in structure have a mapping to data in the structure
149 for (int rs = sq.getStart(); rs < sq.getStart()
150 + sq.getLength(); rs++)
152 List<SequenceFeature> sf = sq.findFeatures(rs, rs, "RESNUM");
153 assertEquals(sf.size(), 1);