From dc56d975105f135b5fd37a22913d164df51a02d8 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 6 Jun 2018 16:06:03 +0100 Subject: [PATCH] =?utf8?q?JAL-2920=20don=E2=80=99t=20output=20variant/origin?= =?utf8?q?al=20sequence=20as=20three-letter=20codes=20for=20more=20than=20th?= =?utf8?q?ree=20bases=20(pragmatic=20deviation=20from=20HGVC=20nomenclature)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/ws/dbsources/Uniprot.java | 39 ++++++++++++++++++++-------- test/jalview/ws/dbsources/UniprotTest.java | 17 +++++++++--- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 274ad32..d44b104 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -317,24 +317,41 @@ public class Uniprot extends DbSourceProxyImpl for (String var : variants) { // TODO proper HGVC nomenclature for delins structural variations + // for now we are pragmatic - any orig/variant sequence longer than + // three characters is shown with single-character notation rather than + // three-letter notation sb.append("p."); - for (int c = 0, clen = orig.length(); c < clen; c++) + if (orig.length() < 4) { - char origchar = orig.charAt(c); - String orig3 = ResidueProperties.aa2Triplet.get("" + origchar); - sb.append(orig3 == null ? origchar - : StringUtils.toSentenceCase(orig3)); + for (int c = 0, clen = orig.length(); c < clen; c++) + { + char origchar = orig.charAt(c); + String orig3 = ResidueProperties.aa2Triplet.get("" + origchar); + sb.append(orig3 == null ? origchar + : StringUtils.toSentenceCase(orig3)); + } + } + else + { + sb.append(orig); } sb.append(Integer.toString(uf.getPosition())); - for (int c = 0, clen = var.length(); c < clen; c++) + if (var.length() < 4) { - char varchar = var.charAt(c); - String var3 = ResidueProperties.aa2Triplet.get("" + varchar); - - sb.append(var3 != null ? StringUtils.toSentenceCase(var3) - : "" + varchar); + for (int c = 0, clen = var.length(); c < clen; c++) + { + char varchar = var.charAt(c); + String var3 = ResidueProperties.aa2Triplet.get("" + varchar); + + sb.append(var3 != null ? StringUtils.toSentenceCase(var3) + : "" + varchar); + } + } + else + { + sb.append(var); } if (++p != variants.size()) { diff --git a/test/jalview/ws/dbsources/UniprotTest.java b/test/jalview/ws/dbsources/UniprotTest.java index c7f216e..ab79f10 100644 --- a/test/jalview/ws/dbsources/UniprotTest.java +++ b/test/jalview/ws/dbsources/UniprotTest.java @@ -69,6 +69,7 @@ public class UniprotTest + "M" + "LLMVM" + "LLLMVML" + + "LLLMVKMLML" + "MHAPL VSKDL" + ""; @@ -104,7 +105,7 @@ public class UniprotTest * Check sequence features */ Vector features = entry.getFeature(); - assertEquals(8, features.size()); + assertEquals(9, features.size()); UniprotFeature sf = features.get(0); assertEquals("signal peptide", sf.getType()); assertNull(sf.getDescription()); @@ -159,9 +160,17 @@ public class UniprotTest assertEquals(42, sf.getBegin()); assertEquals(43, sf.getEnd()); Assert.assertEquals(Uniprot.getDescription(sf), - "p.MetLeu42LeuLeu" + "\n" + "p.MetLeu42LeuMetVal Foo"); /* - * Check cross-references - */ + "p.MetLeu42LeuLeu" + "\n" + "p.MetLeu42LeuMetVal Foo"); + + sf = features.get(8); + assertEquals(42, sf.getBegin()); + assertEquals(45, sf.getEnd()); + Assert.assertEquals(Uniprot.getDescription(sf), + "p.MLML42LeuLeu" + "\n" + "p.MLML42LMVK Foo Too"); + + /* + * Check cross-references + */ Vector xrefs = entry.getDbReference(); assertEquals(3, xrefs.size()); -- 1.7.10.2