import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.util.List;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.SequenceI;
import jalview.xml.binding.uniprot.LocationType;
import jalview.xml.binding.uniprot.PositionType;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.math.BigInteger;
-import java.util.List;
-
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
public class UniprotTest
{
+ "<uniprot xmlns=\"http://uniprot.org/uniprot\">"
+ "<entry dataset=\"TrEMBL\" created=\"2008-01-15\" modified=\"2015-03-04\" version=\"38\">"
+ "<accession>A9CKP4</accession>"
- + "<accession>A9CKP5</accession>"
- + "<name>A9CKP4_AGRT5</name>"
+ + "<accession>A9CKP5</accession>" + "<name>A9CKP4_AGRT5</name>"
+ "<name>A9CKP4_AGRT6</name>"
+ "<protein><recommendedName><fullName>Mitogen-activated protein kinase 13</fullName></recommendedName></protein>"
+ "<dbReference type=\"PDB\" id=\"2FSQ\"><property type=\"method\" value=\"X-ray\"/><property type=\"resolution\" value=\"1.40\"/></dbReference>"
sf = features.get(6);
assertEquals("sequence variant", sf.getType());
- assertEquals("Foo",
- sf.getDescription());
+ assertEquals("Foo", sf.getDescription());
assertEquals(42,
sf.getLocation().getPosition().getPosition().intValue());
assertNull(sf.getLocation().getBegin());
assertNull(sf.getLocation().getEnd());
- Assert.assertEquals(Uniprot.getDescription(sf),
- "<html>p.Met42Leu" + "<br/> "
- + "p.Met42LeuMetVal Foo</html>");
+ Assert.assertEquals(Uniprot.getDescription(sf), "<html>p.Met42Leu"
+ + "<br/> " + "p.Met42LeuMetVal Foo</html>");
sf = features.get(7);
assertNull(sf.getLocation().getPosition());
assertEquals(42, sf.getLocation().getBegin().getPosition().intValue());
assertEquals(43, sf.getLocation().getEnd().getPosition().intValue());
- Assert.assertEquals(Uniprot.getDescription(sf),
- "<html>p.MetLeu42LeuLeu" + "<br/> "
- + "p.MetLeu42LeuMetVal Foo</html>");
+ Assert.assertEquals(Uniprot.getDescription(sf), "<html>p.MetLeu42LeuLeu"
+ + "<br/> " + "p.MetLeu42LeuMetVal Foo</html>");
sf = features.get(8);
assertNull(sf.getLocation().getPosition());
assertEquals(42, sf.getLocation().getBegin().getPosition().intValue());
assertEquals(45, sf.getLocation().getEnd().getPosition().intValue());
- Assert.assertEquals(Uniprot.getDescription(sf),
- "<html>p.MLML42LeuLeu" + "<br/> "
- + "p.MLML42LMVK Foo Too</html>");
+ Assert.assertEquals(Uniprot.getDescription(sf), "<html>p.MLML42LeuLeu"
+ + "<br/> " + "p.MLML42LMVK Foo Too</html>");
/*
* Check cross-references
public void testGetUniprotSequence() throws UnsupportedEncodingException
{
InputStream is = new ByteArrayInputStream(UNIPROT_XML.getBytes());
- Entry entry = new Uniprot().getUniprotEntries(
- is).get(0);
+ Entry entry = new Uniprot().getUniprotEntries(is).get(0);
SequenceI seq = new Uniprot().uniprotEntryToSequence(entry);
assertNotNull(seq);
assertEquals(6, seq.getDBRefs().size()); // 2*Uniprot, PDB, PDBsum, 2*EMBL
assertEquals(seq.getSequenceAsString(),
seq.createDatasetSequence().getSequenceAsString());
- assertEquals(2,seq.getPrimaryDBRefs().size());
- List<DBRefEntry> res = DBRefUtils.searchRefs(seq.getPrimaryDBRefs(), "A9CKP4");
- assertEquals(1,res.size());
+ assertEquals(2, seq.getPrimaryDBRefs().size());
+ List<DBRefEntry> res = DBRefUtils.searchRefs(seq.getPrimaryDBRefs(),
+ "A9CKP4");
+ assertEquals(1, res.size());
assertTrue(res.get(0).isCanonical());
- res = DBRefUtils.searchRefsForSource(seq.getDBRefs(), DBRefSource.UNIPROT);
- assertEquals(2,res.size());
+ res = DBRefUtils.searchRefsForSource(seq.getDBRefs(),
+ DBRefSource.UNIPROT);
+ assertEquals(2, res.size());
/*
* NB this test fragile - relies on ordering being preserved
*/
assertTrue(res.get(0).isCanonical());
assertFalse(res.get(1).isCanonical());
+
+ // check version is preserved for EMBLCDS
+ res = DBRefUtils.searchRefs(seq.getDBRefs(), "AAK85932");
+ assertEquals(1, res.size());
+ // Ideally we would expect AAK85932.1 -> AAK85932
+ // assertTrue("1".equals(res.get(0).getVersion()));
+ // but it also passes through DBrefUtils.ensurePrimaries which adds
+ // (promoted) to the version string
+ // FIXME: Jim needs to specify what (promoted) means !! - or perhaps we just
+ // ignore it !
+ assertEquals("1 (promoted)", (res.get(0).getVersion()));
}
/**
* name formatted with Uniprot Entry name
*/
String expectedName = "A9CKP4_AGRT5|A9CKP4_AGRT6";
- assertEquals(expectedName,
- Uniprot.getUniprotEntryId(entry));
+ assertEquals(expectedName, Uniprot.getUniprotEntryId(entry));
}
/**