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.assertNull;
27 import jalview.datamodel.PDBEntry;
28 import jalview.datamodel.SequenceFeature;
29 import jalview.datamodel.UniprotEntry;
31 import java.io.Reader;
32 import java.io.StringReader;
33 import java.util.Vector;
35 import org.testng.annotations.Test;
37 public class UniprotTest
39 // adapted from http://www.uniprot.org/uniprot/A9CKP4.xml
40 private static final String UNIPROT_XML = "<?xml version='1.0' encoding='UTF-8'?>"
42 + "<entry dataset=\"TrEMBL\" created=\"2008-01-15\" modified=\"2015-03-04\" version=\"38\">"
43 + "<accession>A9CKP4</accession>"
44 + "<accession>A9CKP5</accession>"
45 + "<name>A9CKP4_AGRT5</name>"
46 + "<name>A9CKP4_AGRT6</name>"
47 + "<protein><recommendedName><fullName>Mitogen-activated protein kinase 13</fullName><fullName>Henry</fullName></recommendedName></protein>"
48 + "<dbReference type=\"PDB\" id=\"2FSQ\"><property type=\"method\" value=\"X-ray\"/><property type=\"resolution\" value=\"1.40\"/></dbReference>"
49 + "<dbReference type=\"PDBsum\" id=\"2FSR\"/>"
50 + "<feature type=\"signal peptide\" evidence=\"7\"><location><begin position=\"1\"/><end position=\"18\"/></location></feature>"
51 + "<feature type=\"propeptide\" description=\"Activation peptide\" id=\"PRO_0000027399\" evidence=\"9 16 17 18\"><location><begin position=\"19\"/><end position=\"20\"/></location></feature>"
52 + "<feature type=\"chain\" description=\"Granzyme B\" id=\"PRO_0000027400\"><location><begin position=\"21\"/><end position=\"247\"/></location></feature>"
53 + "<sequence length=\"10\" mass=\"27410\" checksum=\"8CB760AACF88FE6C\" modified=\"2008-01-15\" version=\"1\">MHAPL VSKDL</sequence></entry>"
57 * Test the method that unmarshals XML to a Uniprot model
59 @Test(groups = { "Functional" })
60 public void testGetUniprotEntries()
62 Uniprot u = new Uniprot();
63 Reader reader = new StringReader(UNIPROT_XML);
64 Vector<UniprotEntry> entries = u.getUniprotEntries(reader);
65 assertEquals(1, entries.size());
66 UniprotEntry entry = entries.get(0);
67 assertEquals(2, entry.getName().size());
68 assertEquals("A9CKP4_AGRT5", entry.getName().get(0));
69 assertEquals("A9CKP4_AGRT6", entry.getName().get(1));
70 assertEquals(2, entry.getAccession().size());
71 assertEquals("A9CKP4", entry.getAccession().get(0));
72 assertEquals("A9CKP5", entry.getAccession().get(1));
75 * UniprotSequence drops any space characters
77 assertEquals("MHAPLVSKDL", entry.getUniprotSequence().getContent());
79 assertEquals(2, entry.getProtein().getName().size());
80 assertEquals("Mitogen-activated protein kinase 13", entry.getProtein()
82 assertEquals("Henry", entry.getProtein().getName().get(1));
85 * Check sequence features
87 Vector<SequenceFeature> features = entry.getFeature();
88 assertEquals(3, features.size());
89 SequenceFeature sf = features.get(0);
90 assertEquals("signal peptide", sf.getType());
91 assertNull(sf.getDescription());
92 assertNull(sf.getStatus());
93 assertEquals(1, sf.getPosition());
94 assertEquals(1, sf.getBegin());
95 assertEquals(18, sf.getEnd());
97 assertEquals("propeptide", sf.getType());
98 assertEquals("Activation peptide", sf.getDescription());
99 assertEquals(19, sf.getPosition());
100 assertEquals(19, sf.getBegin());
101 assertEquals(20, sf.getEnd());
102 sf = features.get(2);
103 assertEquals("chain", sf.getType());
104 assertEquals("Granzyme B", sf.getDescription());
105 assertEquals(21, sf.getPosition());
106 assertEquals(21, sf.getBegin());
107 assertEquals(247, sf.getEnd());
110 * Check cross-references
112 Vector<PDBEntry> xrefs = entry.getDbReference();
113 assertEquals(2, xrefs.size());
115 PDBEntry xref = xrefs.get(0);
116 assertEquals("2FSQ", xref.getId());
117 assertEquals("PDB", xref.getType());
118 assertEquals("X-ray", xref.getProperty("method"));
119 assertEquals("1.40", xref.getProperty("resolution"));
122 assertEquals("2FSR", xref.getId());
123 assertEquals("PDBsum", xref.getType());
124 assertFalse(xref.getProperties().hasMoreElements());
128 * Test the method that formats the sequence id
130 @Test(groups = { "Functional" })
131 public void testGetUniprotEntryId()
133 UniprotEntry entry = new Uniprot().getUniprotEntries(
134 new StringReader(UNIPROT_XML)).get(0);
137 * name formatted as source | accession ids | names
138 * source database converted to Jalview canonical name
140 String expectedName = "UNIPROT|A9CKP4|A9CKP5|A9CKP4_AGRT5|A9CKP4_AGRT6";
141 assertEquals(expectedName, Uniprot.getUniprotEntryId(entry));
145 * Test the method that formats the sequence description
147 @Test(groups = { "Functional" })
148 public void testGetUniprotEntryDescription()
150 UniprotEntry entry = new Uniprot().getUniprotEntries(
151 new StringReader(UNIPROT_XML)).get(0);
154 * recommended names concatenated with space separator
156 String expectedDescription = "Mitogen-activated protein kinase 13 Henry";
157 assertEquals(expectedDescription,
158 Uniprot.getUniprotEntryDescription(entry));