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.SequenceFeature;
30 import jalview.datamodel.SequenceI;
31 import jalview.datamodel.UniprotEntry;
33 import java.io.Reader;
34 import java.io.StringReader;
35 import java.util.Vector;
37 import org.testng.annotations.Test;
39 public class UniprotTest
41 // adapted from http://www.uniprot.org/uniprot/A9CKP4.xml
42 private static final String UNIPROT_XML = "<?xml version='1.0' encoding='UTF-8'?>"
44 + "<entry dataset=\"TrEMBL\" created=\"2008-01-15\" modified=\"2015-03-04\" version=\"38\">"
45 + "<accession>A9CKP4</accession>"
46 + "<accession>A9CKP5</accession>"
47 + "<name>A9CKP4_AGRT5</name>"
48 + "<name>A9CKP4_AGRT6</name>"
49 + "<protein><recommendedName><fullName>Mitogen-activated protein kinase 13</fullName><fullName>Henry</fullName></recommendedName></protein>"
50 + "<dbReference type=\"PDB\" id=\"2FSQ\"><property type=\"method\" value=\"X-ray\"/><property type=\"resolution\" value=\"1.40\"/></dbReference>"
51 + "<dbReference type=\"PDBsum\" id=\"2FSR\"/>"
52 + "<dbReference type=\"EMBL\" id=\"AE007869\"><property type=\"protein sequence ID\" value=\"AAK85932.1\"/><property type=\"molecule type\" value=\"Genomic_DNA\"/></dbReference>"
53 + "<feature type=\"signal peptide\" evidence=\"7\"><location><begin position=\"1\"/><end position=\"18\"/></location></feature>"
54 + "<feature type=\"propeptide\" description=\"Activation peptide\" id=\"PRO_0000027399\" evidence=\"9 16 17 18\"><location><begin position=\"19\"/><end position=\"20\"/></location></feature>"
55 + "<feature type=\"chain\" description=\"Granzyme B\" id=\"PRO_0000027400\"><location><begin position=\"21\"/><end position=\"247\"/></location></feature>"
56 + "<sequence length=\"10\" mass=\"27410\" checksum=\"8CB760AACF88FE6C\" modified=\"2008-01-15\" version=\"1\">MHAPL VSKDL</sequence></entry>"
60 * Test the method that unmarshals XML to a Uniprot model
62 @Test(groups = { "Functional" })
63 public void testGetUniprotEntries()
65 Uniprot u = new Uniprot();
66 Reader reader = new StringReader(UNIPROT_XML);
67 Vector<UniprotEntry> entries = u.getUniprotEntries(reader);
68 assertEquals(1, entries.size());
69 UniprotEntry entry = entries.get(0);
70 assertEquals(2, entry.getName().size());
71 assertEquals("A9CKP4_AGRT5", entry.getName().get(0));
72 assertEquals("A9CKP4_AGRT6", entry.getName().get(1));
73 assertEquals(2, entry.getAccession().size());
74 assertEquals("A9CKP4", entry.getAccession().get(0));
75 assertEquals("A9CKP5", entry.getAccession().get(1));
78 * UniprotSequence drops any space characters
80 assertEquals("MHAPLVSKDL", entry.getUniprotSequence().getContent());
82 assertEquals(2, entry.getProtein().getName().size());
83 assertEquals("Mitogen-activated protein kinase 13", entry.getProtein()
85 assertEquals("Henry", entry.getProtein().getName().get(1));
88 * Check sequence features
90 Vector<SequenceFeature> features = entry.getFeature();
91 assertEquals(3, features.size());
92 SequenceFeature sf = features.get(0);
93 assertEquals("signal peptide", sf.getType());
94 assertNull(sf.getDescription());
95 assertNull(sf.getStatus());
96 assertEquals(1, sf.getPosition());
97 assertEquals(1, sf.getBegin());
98 assertEquals(18, sf.getEnd());
100 assertEquals("propeptide", sf.getType());
101 assertEquals("Activation peptide", sf.getDescription());
102 assertEquals(19, sf.getPosition());
103 assertEquals(19, sf.getBegin());
104 assertEquals(20, sf.getEnd());
105 sf = features.get(2);
106 assertEquals("chain", sf.getType());
107 assertEquals("Granzyme B", sf.getDescription());
108 assertEquals(21, sf.getPosition());
109 assertEquals(21, sf.getBegin());
110 assertEquals(247, sf.getEnd());
113 * Check cross-references
115 Vector<PDBEntry> xrefs = entry.getDbReference();
116 assertEquals(3, xrefs.size());
118 PDBEntry xref = xrefs.get(0);
119 assertEquals("2FSQ", xref.getId());
120 assertEquals("PDB", xref.getType());
121 assertEquals("X-ray", xref.getProperty("method"));
122 assertEquals("1.40", xref.getProperty("resolution"));
125 assertEquals("2FSR", xref.getId());
126 assertEquals("PDBsum", xref.getType());
127 assertFalse(xref.getProperties().hasMoreElements());
130 assertEquals("AE007869", xref.getId());
131 assertEquals("EMBL", xref.getType());
132 assertEquals("AAK85932.1",
133 xref.getProperty("protein sequence ID"));
134 assertEquals("Genomic_DNA",
135 xref.getProperty("molecule type"));
138 @Test(groups = { "Functional" })
139 public void testGetUniprotSequence()
141 UniprotEntry entry = new Uniprot().getUniprotEntries(
142 new StringReader(UNIPROT_XML)).get(0);
143 SequenceI seq = new Uniprot().uniprotEntryToSequenceI(entry);
145 assertEquals(6, seq.getDBRefs().length); // 2*Uniprot, PDB, PDBsum, 2*EMBL
150 * Test the method that formats the sequence id
152 @Test(groups = { "Functional" })
153 public void testGetUniprotEntryId()
155 UniprotEntry entry = new Uniprot().getUniprotEntries(
156 new StringReader(UNIPROT_XML)).get(0);
159 * name formatted as source | accession ids | names
160 * source database converted to Jalview canonical name
162 String expectedName = "UNIPROT|A9CKP4|A9CKP5|A9CKP4_AGRT5|A9CKP4_AGRT6";
163 assertEquals(expectedName, Uniprot.getUniprotEntryId(entry));
167 * Test the method that formats the sequence description
169 @Test(groups = { "Functional" })
170 public void testGetUniprotEntryDescription()
172 UniprotEntry entry = new Uniprot().getUniprotEntries(
173 new StringReader(UNIPROT_XML)).get(0);
176 * recommended names concatenated with space separator
178 String expectedDescription = "Mitogen-activated protein kinase 13 Henry";
179 assertEquals(expectedDescription,
180 Uniprot.getUniprotEntryDescription(entry));