From 0cddb5c5bf43803985172d28a09597563ec4ae7b Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sat, 2 Jun 2018 14:17:31 +0100 Subject: [PATCH] JAL-3017 parse multiple variant elements for uniprot feature --- resources/uniprot_mapping.xml | 2 +- .../datamodel/xdb/uniprot/UniprotFeature.java | 47 +++++++++++++++----- test/jalview/ws/dbsources/UniprotTest.java | 11 ++++- 3 files changed, 46 insertions(+), 14 deletions(-) diff --git a/resources/uniprot_mapping.xml b/resources/uniprot_mapping.xml index 832d3e5..4c9ad5f 100755 --- a/resources/uniprot_mapping.xml +++ b/resources/uniprot_mapping.xml @@ -69,7 +69,7 @@ - + diff --git a/src/jalview/datamodel/xdb/uniprot/UniprotFeature.java b/src/jalview/datamodel/xdb/uniprot/UniprotFeature.java index 4c2ae24..3bae87e 100644 --- a/src/jalview/datamodel/xdb/uniprot/UniprotFeature.java +++ b/src/jalview/datamodel/xdb/uniprot/UniprotFeature.java @@ -20,6 +20,8 @@ */ package jalview.datamodel.xdb.uniprot; +import java.util.Vector; + /** * A data model class for binding from Uniprot XML via uniprot_mapping.xml */ @@ -31,7 +33,7 @@ public class UniprotFeature private String original = null; - private String variation = null; + private Vector variation = null; private String status; @@ -55,15 +57,36 @@ public class UniprotFeature { return null; } - return (description == null ? "" : description) - + (variation != null - ? (description != null ? " " : "") + "Variation: '" - + variation + "'" - : "") - + (original != null - ? ((description != null || variation != null) ? " " - : "") + "Original: '" + original + "'" - : ""); + StringBuilder sb = new StringBuilder(); + if (description != null) + { + sb.append(description); + } + if (variation != null && variation.size() > 0) + { + int i = 0; + for (String var : variation) + { + if (i++ > 0) + { + sb.append(","); + } + if (sb.length() > 0) + { + sb.append(" "); + } + sb.append("Variation: '" + var + "'"); + } + } + if (original != null) + { + if (sb.length() > 0) + { + sb.append(" "); + } + sb.append("Original: '" + original + "'"); + } + return sb.toString(); } public void setDescription(String d) @@ -122,12 +145,12 @@ public class UniprotFeature this.original = original; } - public String getVariation() + public Vector getVariation() { return variation; } - public void setVariation(String variant) + public void setVariation(Vector variant) { this.variation = variant; } diff --git a/test/jalview/ws/dbsources/UniprotTest.java b/test/jalview/ws/dbsources/UniprotTest.java index c603a11..b70e581 100644 --- a/test/jalview/ws/dbsources/UniprotTest.java +++ b/test/jalview/ws/dbsources/UniprotTest.java @@ -66,6 +66,7 @@ public class UniprotTest + "ML" + "ML" + "M" + + "LLMVM" + "MHAPL VSKDL" + ""; @@ -101,7 +102,7 @@ public class UniprotTest * Check sequence features */ Vector features = entry.getFeature(); - assertEquals(6, features.size()); + assertEquals(7, features.size()); UniprotFeature sf = features.get(0); assertEquals("signal peptide", sf.getType()); assertNull(sf.getDescription()); @@ -142,6 +143,14 @@ public class UniprotTest assertEquals(41, sf.getPosition()); assertEquals(41, sf.getBegin()); assertEquals(41, sf.getEnd()); + + sf = features.get(6); + assertEquals("sequence variant", sf.getType()); + assertEquals("Foo Variation: 'L', Variation: 'LMV' Original: 'M'", + sf.getDescription()); + assertEquals(42, sf.getPosition()); + assertEquals(42, sf.getBegin()); + assertEquals(42, sf.getEnd()); /* * Check cross-references */ -- 1.7.10.2