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.
21 package jalview.ws.dbsources;
23 import static org.testng.AssertJUnit.assertEquals;
24 import static org.testng.AssertJUnit.assertFalse;
25 import static org.testng.AssertJUnit.assertNotNull;
26 import static org.testng.AssertJUnit.assertNull;
28 import jalview.datamodel.PDBEntry;
29 import jalview.datamodel.SequenceI;
30 import jalview.datamodel.xdb.uniprot.UniprotEntry;
31 import jalview.datamodel.xdb.uniprot.UniprotFeature;
32 import jalview.gui.JvOptionPane;
34 import java.io.Reader;
35 import java.io.StringReader;
36 import java.util.Vector;
38 import org.testng.annotations.BeforeClass;
39 import org.testng.annotations.Test;
41 public class UniprotTest
44 @BeforeClass(alwaysRun = true)
45 public void setUpJvOptionPane()
47 JvOptionPane.setInteractiveMode(false);
48 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
51 // adapted from http://www.uniprot.org/uniprot/A9CKP4.xml
52 private static final String UNIPROT_XML = "<?xml version='1.0' encoding='UTF-8'?>"
54 + "<entry dataset=\"TrEMBL\" created=\"2008-01-15\" modified=\"2015-03-04\" version=\"38\">"
55 + "<accession>A9CKP4</accession>"
56 + "<accession>A9CKP5</accession>"
57 + "<name>A9CKP4_AGRT5</name>"
58 + "<name>A9CKP4_AGRT6</name>"
59 + "<protein><recommendedName><fullName>Mitogen-activated protein kinase 13</fullName><fullName>Henry</fullName></recommendedName></protein>"
60 + "<dbReference type=\"PDB\" id=\"2FSQ\"><property type=\"method\" value=\"X-ray\"/><property type=\"resolution\" value=\"1.40\"/></dbReference>"
61 + "<dbReference type=\"PDBsum\" id=\"2FSR\"/>"
62 + "<dbReference type=\"EMBL\" id=\"AE007869\"><property type=\"protein sequence ID\" value=\"AAK85932.1\"/><property type=\"molecule type\" value=\"Genomic_DNA\"/></dbReference>"
63 + "<feature type=\"signal peptide\" evidence=\"7\"><location><begin position=\"1\"/><end position=\"18\"/></location></feature>"
64 + "<feature type=\"propeptide\" description=\"Activation peptide\" id=\"PRO_0000027399\" evidence=\"9 16 17 18\"><location><begin position=\"19\"/><end position=\"20\"/></location></feature>"
65 + "<feature type=\"chain\" description=\"Granzyme B\" id=\"PRO_0000027400\"><location><begin position=\"21\"/><end position=\"247\"/></location></feature>"
66 + "<feature type=\"sequence variant\"><original>M</original><variation>L</variation><location><position position=\"41\"/></location></feature>"
67 + "<feature type=\"sequence variant\" description=\"Pathogenic\"><original>M</original><variation>L</variation><location><position position=\"41\"/></location></feature>"
68 + "<feature type=\"sequence variant\" description=\"Pathogenic\"><original>M</original><location><position position=\"41\"/></location></feature>"
69 + "<feature type=\"sequence variant\" description=\"Foo\"><variation>L</variation><variation>LMV</variation><original>M</original><location><position position=\"42\"/></location></feature>"
70 + "<sequence length=\"10\" mass=\"27410\" checksum=\"8CB760AACF88FE6C\" modified=\"2008-01-15\" version=\"1\">MHAPL VSKDL</sequence></entry>"
74 * Test the method that unmarshals XML to a Uniprot model
76 @Test(groups = { "Functional" })
77 public void testGetUniprotEntries()
79 Uniprot u = new Uniprot();
80 Reader reader = new StringReader(UNIPROT_XML);
81 Vector<UniprotEntry> entries = u.getUniprotEntries(reader);
82 assertEquals(1, entries.size());
83 UniprotEntry entry = entries.get(0);
84 assertEquals(2, entry.getName().size());
85 assertEquals("A9CKP4_AGRT5", entry.getName().get(0));
86 assertEquals("A9CKP4_AGRT6", entry.getName().get(1));
87 assertEquals(2, entry.getAccession().size());
88 assertEquals("A9CKP4", entry.getAccession().get(0));
89 assertEquals("A9CKP5", entry.getAccession().get(1));
92 * UniprotSequence drops any space characters
94 assertEquals("MHAPLVSKDL", entry.getUniprotSequence().getContent());
96 assertEquals(2, entry.getProtein().getName().size());
97 assertEquals("Mitogen-activated protein kinase 13", entry.getProtein()
99 assertEquals("Henry", entry.getProtein().getName().get(1));
102 * Check sequence features
104 Vector<UniprotFeature> features = entry.getFeature();
105 assertEquals(7, features.size());
106 UniprotFeature sf = features.get(0);
107 assertEquals("signal peptide", sf.getType());
108 assertNull(sf.getDescription());
109 assertNull(sf.getStatus());
110 assertEquals(1, sf.getBegin());
111 assertEquals(18, sf.getEnd());
112 sf = features.get(1);
113 assertEquals("propeptide", sf.getType());
114 assertEquals("Activation peptide", sf.getDescription());
115 assertEquals(19, sf.getPosition());
116 assertEquals(19, sf.getBegin());
117 assertEquals(20, sf.getEnd());
118 sf = features.get(2);
119 assertEquals("chain", sf.getType());
120 assertEquals("Granzyme B", sf.getDescription());
121 assertEquals(21, sf.getPosition());
122 assertEquals(21, sf.getBegin());
123 assertEquals(247, sf.getEnd());
125 sf = features.get(3);
126 assertEquals("sequence variant", sf.getType());
127 assertEquals("Variation: 'L' Original: 'M'", sf.getDescription());
128 assertEquals(41, sf.getPosition());
129 assertEquals(41, sf.getBegin());
130 assertEquals(41, sf.getEnd());
132 sf = features.get(4);
133 assertEquals("sequence variant", sf.getType());
134 assertEquals("Pathogenic Variation: 'L' Original: 'M'",
135 sf.getDescription());
136 assertEquals(41, sf.getPosition());
137 assertEquals(41, sf.getBegin());
138 assertEquals(41, sf.getEnd());
140 sf = features.get(5);
141 assertEquals("sequence variant", sf.getType());
142 assertEquals("Pathogenic Original: 'M'", sf.getDescription());
143 assertEquals(41, sf.getPosition());
144 assertEquals(41, sf.getBegin());
145 assertEquals(41, sf.getEnd());
147 sf = features.get(6);
148 assertEquals("sequence variant", sf.getType());
149 assertEquals("Foo Variation: 'L', Variation: 'LMV' Original: 'M'",
150 sf.getDescription());
151 assertEquals(42, sf.getPosition());
152 assertEquals(42, sf.getBegin());
153 assertEquals(42, sf.getEnd());
155 * Check cross-references
157 Vector<PDBEntry> xrefs = entry.getDbReference();
158 assertEquals(3, xrefs.size());
160 PDBEntry xref = xrefs.get(0);
161 assertEquals("2FSQ", xref.getId());
162 assertEquals("PDB", xref.getType());
163 assertEquals("X-ray", xref.getProperty("method"));
164 assertEquals("1.40", xref.getProperty("resolution"));
167 assertEquals("2FSR", xref.getId());
168 assertEquals("PDBsum", xref.getType());
169 assertFalse(xref.getProperties().hasMoreElements());
172 assertEquals("AE007869", xref.getId());
173 assertEquals("EMBL", xref.getType());
174 assertEquals("AAK85932.1", xref.getProperty("protein sequence ID"));
175 assertEquals("Genomic_DNA", xref.getProperty("molecule type"));
178 @Test(groups = { "Functional" })
179 public void testGetUniprotSequence()
181 UniprotEntry entry = new Uniprot().getUniprotEntries(
182 new StringReader(UNIPROT_XML)).get(0);
183 SequenceI seq = new Uniprot().uniprotEntryToSequenceI(entry);
185 assertEquals(6, seq.getDBRefs().length); // 2*Uniprot, PDB, PDBsum, 2*EMBL
190 * Test the method that formats the sequence id
192 @Test(groups = { "Functional" })
193 public void testGetUniprotEntryId()
195 UniprotEntry entry = new Uniprot().getUniprotEntries(
196 new StringReader(UNIPROT_XML)).get(0);
199 * name formatted with Uniprot Entry name
201 String expectedName = "A9CKP4_AGRT5|A9CKP4_AGRT6";
202 assertEquals(expectedName,
203 Uniprot.getUniprotEntryId(entry));
207 * Test the method that formats the sequence description
209 @Test(groups = { "Functional" })
210 public void testGetUniprotEntryDescription()
212 UniprotEntry entry = new Uniprot().getUniprotEntries(
213 new StringReader(UNIPROT_XML)).get(0);
216 * recommended names concatenated with space separator
218 String expectedDescription = "Mitogen-activated protein kinase 13 Henry";
219 assertEquals(expectedDescription,
220 Uniprot.getUniprotEntryDescription(entry));