/*
* Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
* Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Jalview. If not, see .
* The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.ws.dbsources;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNull;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.UniprotEntry;
import java.io.Reader;
import java.io.StringReader;
import java.util.Vector;
import org.testng.annotations.Test;
public class UniprotTest
{
// adapted from http://www.uniprot.org/uniprot/A9CKP4.xml
private static final String UNIPROT_XML = ""
+ ""
+ ""
+ "A9CKP4"
+ "A9CKP5"
+ "A9CKP4_AGRT5"
+ "A9CKP4_AGRT6"
+ "Mitogen-activated protein kinase 13Henry"
+ ""
+ ""
+ ""
+ ""
+ ""
+ "MHAPL VSKDL"
+ "";
/**
* Test the method that unmarshals XML to a Uniprot model
*/
@Test(groups = { "Functional" })
public void testGetUniprotEntries()
{
Uniprot u = new Uniprot();
Reader reader = new StringReader(UNIPROT_XML);
Vector entries = u.getUniprotEntries(reader);
assertEquals(1, entries.size());
UniprotEntry entry = entries.get(0);
assertEquals(2, entry.getName().size());
assertEquals("A9CKP4_AGRT5", entry.getName().get(0));
assertEquals("A9CKP4_AGRT6", entry.getName().get(1));
assertEquals(2, entry.getAccession().size());
assertEquals("A9CKP4", entry.getAccession().get(0));
assertEquals("A9CKP5", entry.getAccession().get(1));
/*
* UniprotSequence drops any space characters
*/
assertEquals("MHAPLVSKDL", entry.getUniprotSequence().getContent());
assertEquals(2, entry.getProtein().getName().size());
assertEquals("Mitogen-activated protein kinase 13", entry.getProtein()
.getName().get(0));
assertEquals("Henry", entry.getProtein().getName().get(1));
/*
* Check sequence features
*/
Vector features = entry.getFeature();
assertEquals(3, features.size());
SequenceFeature sf = features.get(0);
assertEquals("signal peptide", sf.getType());
assertNull(sf.getDescription());
assertNull(sf.getStatus());
assertEquals(1, sf.getPosition());
assertEquals(1, sf.getBegin());
assertEquals(18, sf.getEnd());
sf = features.get(1);
assertEquals("propeptide", sf.getType());
assertEquals("Activation peptide", sf.getDescription());
assertEquals(19, sf.getPosition());
assertEquals(19, sf.getBegin());
assertEquals(20, sf.getEnd());
sf = features.get(2);
assertEquals("chain", sf.getType());
assertEquals("Granzyme B", sf.getDescription());
assertEquals(21, sf.getPosition());
assertEquals(21, sf.getBegin());
assertEquals(247, sf.getEnd());
/*
* Check cross-references
*/
Vector xrefs = entry.getDbReference();
assertEquals(2, xrefs.size());
PDBEntry xref = xrefs.get(0);
assertEquals("2FSQ", xref.getId());
assertEquals("PDB", xref.getType());
assertEquals(2, xref.getProperty().size());
assertEquals("X-ray", xref.getProperty().get("method"));
assertEquals("1.40", xref.getProperty().get("resolution"));
xref = xrefs.get(1);
assertEquals("2FSR", xref.getId());
assertEquals("PDBsum", xref.getType());
assertNull(xref.getProperty());
}
/**
* Test the method that formats the sequence id
*/
@Test(groups = { "Functional" })
public void testGetUniprotEntryId()
{
UniprotEntry entry = new Uniprot().getUniprotEntries(
new StringReader(UNIPROT_XML)).get(0);
/*
* name formatted as source | accession ids | names
* source database converted to Jalview canonical name
*/
String expectedName = "UNIPROT|A9CKP4|A9CKP5|A9CKP4_AGRT5|A9CKP4_AGRT6";
assertEquals(expectedName, Uniprot.getUniprotEntryId(entry));
}
/**
* Test the method that formats the sequence description
*/
@Test(groups = { "Functional" })
public void testGetUniprotEntryDescription()
{
UniprotEntry entry = new Uniprot().getUniprotEntries(
new StringReader(UNIPROT_XML)).get(0);
/*
* recommended names concatenated with space separator
*/
String expectedDescription = "Mitogen-activated protein kinase 13 Henry";
assertEquals(expectedDescription,
Uniprot.getUniprotEntryDescription(entry));
}
}