From: gmungoc Date: Fri, 12 Feb 2016 16:58:15 +0000 (+0000) Subject: JAL-1270 remove trailing space + test X-Git-Tag: Release_2_10_0~296^2~25 X-Git-Url: http://source.jalview.org/gitweb/?p=jalview.git;a=commitdiff_plain;h=f225620636ce3b7ec768b4bed98ba000f09efc2a JAL-1270 remove trailing space + test --- diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 02da009..455dcb5 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -248,9 +248,15 @@ public class Uniprot extends DbSourceProxyImpl StringBuilder desc = new StringBuilder(32); if (entry.getProtein() != null && entry.getProtein().getName() != null) { + boolean first = true; for (String nm : entry.getProtein().getName()) { - desc.append(nm).append(" "); + if (!first) + { + desc.append(" "); + } + first = false; + desc.append(nm); } } return desc.toString(); diff --git a/test/jalview/ws/dbsources/UniprotTest.java b/test/jalview/ws/dbsources/UniprotTest.java index 7e387bd..ed3ac77 100644 --- a/test/jalview/ws/dbsources/UniprotTest.java +++ b/test/jalview/ws/dbsources/UniprotTest.java @@ -89,19 +89,19 @@ public class UniprotTest assertEquals("signal peptide", sf.getType()); assertNull(sf.getDescription()); assertNull(sf.getStatus()); - assertEquals(1, sf.getPosition()); // wrong - Castor bug?? + 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()); // wrong - Castor bug?? + 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()); // wrong - Castor bug?? + assertEquals(21, sf.getPosition()); assertEquals(21, sf.getBegin()); assertEquals(247, sf.getEnd()); @@ -125,22 +125,34 @@ public class UniprotTest } /** - * Test the method that formats the sequence name in Fasta style + * Test the method that formats the sequence id */ @Test(groups = { "Functional" }) - public void testConstructSequenceFastaHeader() + public void testGetUniprotEntryId() { - Uniprot u = new Uniprot(); - Reader reader = new StringReader(UNIPROT_XML); - Vector entries = u.getUniprotEntries(reader); - UniprotEntry entry = entries.get(0); + UniprotEntry entry = new Uniprot().getUniprotEntries( + new StringReader(UNIPROT_XML)).get(0); - // source + accession ids + names + /* + * name formatted as source | accession ids | names + */ String expectedName = "UniProt/Swiss-Prot|A9CKP4|A9CKP5|A9CKP4_AGRT5|A9CKP4_AGRT6"; - // protein names - String expectedDescription = "Mitogen-activated protein kinase 13 Henry "; - 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)); }