From: Jim Procter Date: Wed, 6 Jun 2018 15:06:03 +0000 (+0100) Subject: JAL-2920 don’t output variant/original sequence as three-letter codes for more than... X-Git-Tag: Release_2_10_5~60^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=dc56d975105f135b5fd37a22913d164df51a02d8;p=jalview.git JAL-2920 don’t output variant/original sequence as three-letter codes for more than three bases (pragmatic deviation from HGVC nomenclature) --- 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());