Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.ws.dbsources

File UniprotTest.java

 

Code metrics

0
81
5
1
213
145
5
0.06
16.2
5
1

Classes

Class Line # Actions
UniprotTest 41 81 5 0
1.0100%
 

Contributing tests

This file is covered by 4 tests. .

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.dbsources;
22   
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;
27   
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;
33   
34    import java.io.Reader;
35    import java.io.StringReader;
36    import java.util.Vector;
37   
38    import org.testng.annotations.BeforeClass;
39    import org.testng.annotations.Test;
40   
 
41    public class UniprotTest
42    {
43   
 
44  1 toggle @BeforeClass(alwaysRun = true)
45    public void setUpJvOptionPane()
46    {
47  1 JvOptionPane.setInteractiveMode(false);
48  1 JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
49    }
50   
51    // adapted from http://www.uniprot.org/uniprot/A9CKP4.xml
52    private static final String UNIPROT_XML = "<?xml version='1.0' encoding='UTF-8'?>"
53    + "<uniprot>"
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    + "<sequence length=\"10\" mass=\"27410\" checksum=\"8CB760AACF88FE6C\" modified=\"2008-01-15\" version=\"1\">MHAPL VSKDL</sequence></entry>"
70    + "</uniprot>";
71   
72    /**
73    * Test the method that unmarshals XML to a Uniprot model
74    */
 
75  1 toggle @Test(groups = { "Functional" })
76    public void testGetUniprotEntries()
77    {
78  1 Uniprot u = new Uniprot();
79  1 Reader reader = new StringReader(UNIPROT_XML);
80  1 Vector<UniprotEntry> entries = u.getUniprotEntries(reader);
81  1 assertEquals(1, entries.size());
82  1 UniprotEntry entry = entries.get(0);
83  1 assertEquals(2, entry.getName().size());
84  1 assertEquals("A9CKP4_AGRT5", entry.getName().get(0));
85  1 assertEquals("A9CKP4_AGRT6", entry.getName().get(1));
86  1 assertEquals(2, entry.getAccession().size());
87  1 assertEquals("A9CKP4", entry.getAccession().get(0));
88  1 assertEquals("A9CKP5", entry.getAccession().get(1));
89   
90    /*
91    * UniprotSequence drops any space characters
92    */
93  1 assertEquals("MHAPLVSKDL", entry.getUniprotSequence().getContent());
94   
95  1 assertEquals(2, entry.getProtein().getName().size());
96  1 assertEquals("Mitogen-activated protein kinase 13", entry.getProtein()
97    .getName().get(0));
98  1 assertEquals("Henry", entry.getProtein().getName().get(1));
99   
100    /*
101    * Check sequence features
102    */
103  1 Vector<UniprotFeature> features = entry.getFeature();
104  1 assertEquals(6, features.size());
105  1 UniprotFeature sf = features.get(0);
106  1 assertEquals("signal peptide", sf.getType());
107  1 assertNull(sf.getDescription());
108  1 assertNull(sf.getStatus());
109  1 assertEquals(1, sf.getBegin());
110  1 assertEquals(18, sf.getEnd());
111  1 sf = features.get(1);
112  1 assertEquals("propeptide", sf.getType());
113  1 assertEquals("Activation peptide", sf.getDescription());
114  1 assertEquals(19, sf.getPosition());
115  1 assertEquals(19, sf.getBegin());
116  1 assertEquals(20, sf.getEnd());
117  1 sf = features.get(2);
118  1 assertEquals("chain", sf.getType());
119  1 assertEquals("Granzyme B", sf.getDescription());
120  1 assertEquals(21, sf.getPosition());
121  1 assertEquals(21, sf.getBegin());
122  1 assertEquals(247, sf.getEnd());
123   
124  1 sf = features.get(3);
125  1 assertEquals("sequence variant", sf.getType());
126  1 assertEquals("Variation: 'L' Original: 'M'", sf.getDescription());
127  1 assertEquals(41, sf.getPosition());
128  1 assertEquals(41, sf.getBegin());
129  1 assertEquals(41, sf.getEnd());
130   
131  1 sf = features.get(4);
132  1 assertEquals("sequence variant", sf.getType());
133  1 assertEquals("Pathogenic Variation: 'L' Original: 'M'",
134    sf.getDescription());
135  1 assertEquals(41, sf.getPosition());
136  1 assertEquals(41, sf.getBegin());
137  1 assertEquals(41, sf.getEnd());
138   
139  1 sf = features.get(5);
140  1 assertEquals("sequence variant", sf.getType());
141  1 assertEquals("Pathogenic Original: 'M'", sf.getDescription());
142  1 assertEquals(41, sf.getPosition());
143  1 assertEquals(41, sf.getBegin());
144  1 assertEquals(41, sf.getEnd());
145    /*
146    * Check cross-references
147    */
148  1 Vector<PDBEntry> xrefs = entry.getDbReference();
149  1 assertEquals(3, xrefs.size());
150   
151  1 PDBEntry xref = xrefs.get(0);
152  1 assertEquals("2FSQ", xref.getId());
153  1 assertEquals("PDB", xref.getType());
154  1 assertEquals("X-ray", xref.getProperty("method"));
155  1 assertEquals("1.40", xref.getProperty("resolution"));
156   
157  1 xref = xrefs.get(1);
158  1 assertEquals("2FSR", xref.getId());
159  1 assertEquals("PDBsum", xref.getType());
160  1 assertFalse(xref.getProperties().hasMoreElements());
161   
162  1 xref = xrefs.get(2);
163  1 assertEquals("AE007869", xref.getId());
164  1 assertEquals("EMBL", xref.getType());
165  1 assertEquals("AAK85932.1", xref.getProperty("protein sequence ID"));
166  1 assertEquals("Genomic_DNA", xref.getProperty("molecule type"));
167    }
168   
 
169  1 toggle @Test(groups = { "Functional" })
170    public void testGetUniprotSequence()
171    {
172  1 UniprotEntry entry = new Uniprot().getUniprotEntries(
173    new StringReader(UNIPROT_XML)).get(0);
174  1 SequenceI seq = new Uniprot().uniprotEntryToSequenceI(entry);
175  1 assertNotNull(seq);
176  1 assertEquals(6, seq.getDBRefs().length); // 2*Uniprot, PDB, PDBsum, 2*EMBL
177   
178    }
179   
180    /**
181    * Test the method that formats the sequence id
182    */
 
183  1 toggle @Test(groups = { "Functional" })
184    public void testGetUniprotEntryId()
185    {
186  1 UniprotEntry entry = new Uniprot().getUniprotEntries(
187    new StringReader(UNIPROT_XML)).get(0);
188   
189    /*
190    * name formatted with Uniprot Entry name
191    */
192  1 String expectedName = "A9CKP4_AGRT5|A9CKP4_AGRT6";
193  1 assertEquals(expectedName,
194    Uniprot.getUniprotEntryId(entry));
195    }
196   
197    /**
198    * Test the method that formats the sequence description
199    */
 
200  1 toggle @Test(groups = { "Functional" })
201    public void testGetUniprotEntryDescription()
202    {
203  1 UniprotEntry entry = new Uniprot().getUniprotEntries(
204    new StringReader(UNIPROT_XML)).get(0);
205   
206    /*
207    * recommended names concatenated with space separator
208    */
209  1 String expectedDescription = "Mitogen-activated protein kinase 13 Henry";
210  1 assertEquals(expectedDescription,
211    Uniprot.getUniprotEntryDescription(entry));
212    }
213    }