From e957648a02a9e25795a92a4f39a5e3c1e7adb230 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 24 May 2017 16:42:06 +0100 Subject: [PATCH] JAL-2506 relocate Uniprot binding classes, bind to UniprotFeature not SequenceFeature --- resources/uniprot_mapping.xml | 20 ++--- .../datamodel/{ => xdb/uniprot}/UniprotEntry.java | 10 ++- .../datamodel/xdb/uniprot/UniprotFeature.java | 78 ++++++++++++++++++++ .../datamodel/{ => xdb/uniprot}/UniprotFile.java | 2 +- .../{ => xdb/uniprot}/UniprotProteinName.java | 2 +- .../{ => xdb/uniprot}/UniprotSequence.java | 2 +- src/jalview/ws/dbsources/Uniprot.java | 13 ++-- test/jalview/schemes/FeatureColourTest.java | 9 ++- test/jalview/ws/dbsources/UniprotTest.java | 15 ++-- 9 files changed, 116 insertions(+), 35 deletions(-) rename src/jalview/datamodel/{ => xdb/uniprot}/UniprotEntry.java (90%) create mode 100644 src/jalview/datamodel/xdb/uniprot/UniprotFeature.java rename src/jalview/datamodel/{ => xdb/uniprot}/UniprotFile.java (96%) rename src/jalview/datamodel/{ => xdb/uniprot}/UniprotProteinName.java (97%) rename src/jalview/datamodel/{ => xdb/uniprot}/UniprotSequence.java (97%) diff --git a/resources/uniprot_mapping.xml b/resources/uniprot_mapping.xml index 4a981ad..6344d1e 100755 --- a/resources/uniprot_mapping.xml +++ b/resources/uniprot_mapping.xml @@ -18,39 +18,39 @@ * The Jalview Authors are detailed in the 'AUTHORS' file. --> - + - + - + - - + + - + - + - + @@ -71,7 +71,7 @@ - + diff --git a/src/jalview/datamodel/UniprotEntry.java b/src/jalview/datamodel/xdb/uniprot/UniprotEntry.java similarity index 90% rename from src/jalview/datamodel/UniprotEntry.java rename to src/jalview/datamodel/xdb/uniprot/UniprotEntry.java index 4cf0f13..a3537c9 100755 --- a/src/jalview/datamodel/UniprotEntry.java +++ b/src/jalview/datamodel/xdb/uniprot/UniprotEntry.java @@ -18,7 +18,9 @@ * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ -package jalview.datamodel; +package jalview.datamodel.xdb.uniprot; + +import jalview.datamodel.PDBEntry; import java.util.Vector; @@ -36,7 +38,7 @@ public class UniprotEntry Vector accession; - Vector feature; + Vector feature; Vector dbrefs; @@ -47,12 +49,12 @@ public class UniprotEntry accession = items; } - public void setFeature(Vector items) + public void setFeature(Vector items) { feature = items; } - public Vector getFeature() + public Vector getFeature() { return feature; } diff --git a/src/jalview/datamodel/xdb/uniprot/UniprotFeature.java b/src/jalview/datamodel/xdb/uniprot/UniprotFeature.java new file mode 100644 index 0000000..4a359ff --- /dev/null +++ b/src/jalview/datamodel/xdb/uniprot/UniprotFeature.java @@ -0,0 +1,78 @@ +package jalview.datamodel.xdb.uniprot; + +/** + * A data model class for binding from Uniprot XML via uniprot_mapping.xml + */ +public class UniprotFeature +{ + private String type; + + private String description; + + private String status; + + private int begin; + + private int end; + + public String getType() + { + return type; + } + + public void setType(String t) + { + this.type = t; + } + + public String getDescription() + { + return description; + } + + public void setDescription(String d) + { + this.description = d; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String s) + { + this.status = s; + } + + public int getBegin() + { + return begin; + } + + public void setBegin(int b) + { + this.begin = b; + } + + public int getEnd() + { + return end; + } + + public void setEnd(int e) + { + this.end = e; + } + + public int getPosition() + { + return begin; + } + + public void setPosition(int p) + { + this.begin = p; + this.end = p; + } +} diff --git a/src/jalview/datamodel/UniprotFile.java b/src/jalview/datamodel/xdb/uniprot/UniprotFile.java similarity index 96% rename from src/jalview/datamodel/UniprotFile.java rename to src/jalview/datamodel/xdb/uniprot/UniprotFile.java index f0e38d8..9cc0391 100755 --- a/src/jalview/datamodel/UniprotFile.java +++ b/src/jalview/datamodel/xdb/uniprot/UniprotFile.java @@ -18,7 +18,7 @@ * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ -package jalview.datamodel; +package jalview.datamodel.xdb.uniprot; import java.util.Vector; diff --git a/src/jalview/datamodel/UniprotProteinName.java b/src/jalview/datamodel/xdb/uniprot/UniprotProteinName.java similarity index 97% rename from src/jalview/datamodel/UniprotProteinName.java rename to src/jalview/datamodel/xdb/uniprot/UniprotProteinName.java index 0a317e6..2335e71 100755 --- a/src/jalview/datamodel/UniprotProteinName.java +++ b/src/jalview/datamodel/xdb/uniprot/UniprotProteinName.java @@ -18,7 +18,7 @@ * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ -package jalview.datamodel; +package jalview.datamodel.xdb.uniprot; import java.util.Vector; diff --git a/src/jalview/datamodel/UniprotSequence.java b/src/jalview/datamodel/xdb/uniprot/UniprotSequence.java similarity index 97% rename from src/jalview/datamodel/UniprotSequence.java rename to src/jalview/datamodel/xdb/uniprot/UniprotSequence.java index 1150f1e..bdba73f 100755 --- a/src/jalview/datamodel/UniprotSequence.java +++ b/src/jalview/datamodel/xdb/uniprot/UniprotSequence.java @@ -18,7 +18,7 @@ * along with Jalview. If not, see . * The Jalview Authors are detailed in the 'AUTHORS' file. */ -package jalview.datamodel; +package jalview.datamodel.xdb.uniprot; /** * Data model for the sequence returned by a Uniprot query diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 4898b42..6ddd828 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -28,8 +28,9 @@ import jalview.datamodel.PDBEntry; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; -import jalview.datamodel.UniprotEntry; -import jalview.datamodel.UniprotFile; +import jalview.datamodel.xdb.uniprot.UniprotEntry; +import jalview.datamodel.xdb.uniprot.UniprotFeature; +import jalview.datamodel.xdb.uniprot.UniprotFile; import jalview.ws.ebi.EBIFetchClient; import jalview.ws.seqfetcher.DbSourceProxyImpl; @@ -254,16 +255,16 @@ public class Uniprot extends DbSourceProxyImpl } } - } sequence.setPDBId(onlyPdbEntries); if (entry.getFeature() != null) { - for (SequenceFeature sf : entry.getFeature()) + for (UniprotFeature uf : entry.getFeature()) { - SequenceFeature copy = new SequenceFeature(sf, sf.getBegin(), - sf.getEnd(), "Uniprot"); + SequenceFeature copy = new SequenceFeature(uf.getType(), + uf.getDescription(), uf.getStatus(), uf.getBegin(), + uf.getEnd(), "Uniprot"); sequence.addSequenceFeature(copy); } } diff --git a/test/jalview/schemes/FeatureColourTest.java b/test/jalview/schemes/FeatureColourTest.java index c16d541..822fcd4 100644 --- a/test/jalview/schemes/FeatureColourTest.java +++ b/test/jalview/schemes/FeatureColourTest.java @@ -87,7 +87,8 @@ public class FeatureColourTest public void testIsColored_simpleColour() { FeatureColour fc = new FeatureColour(Color.RED); - assertTrue(fc.isColored(new SequenceFeature())); + assertTrue(fc + .isColored(new SequenceFeature("Cath", "", 1, 2, 0f, null))); } @Test(groups = { "Functional" }) @@ -95,7 +96,8 @@ public class FeatureColourTest { FeatureColour fc = new FeatureColour(); fc.setColourByLabel(true); - assertTrue(fc.isColored(new SequenceFeature())); + assertTrue(fc + .isColored(new SequenceFeature("Cath", "", 1, 2, 0f, null))); } @Test(groups = { "Functional" }) @@ -137,7 +139,8 @@ public class FeatureColourTest public void testGetColor_simpleColour() { FeatureColour fc = new FeatureColour(Color.RED); - assertEquals(Color.RED, fc.getColor(new SequenceFeature())); + assertEquals(Color.RED, + fc.getColor(new SequenceFeature("Cath", "", 1, 2, 0f, null))); } @Test(groups = { "Functional" }) diff --git a/test/jalview/ws/dbsources/UniprotTest.java b/test/jalview/ws/dbsources/UniprotTest.java index 2f548d0..2d4be71 100644 --- a/test/jalview/ws/dbsources/UniprotTest.java +++ b/test/jalview/ws/dbsources/UniprotTest.java @@ -26,9 +26,9 @@ import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNull; import jalview.datamodel.PDBEntry; -import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; -import jalview.datamodel.UniprotEntry; +import jalview.datamodel.xdb.uniprot.UniprotEntry; +import jalview.datamodel.xdb.uniprot.UniprotFeature; import jalview.gui.JvOptionPane; import java.io.Reader; @@ -97,13 +97,12 @@ public class UniprotTest /* * Check sequence features */ - Vector features = entry.getFeature(); + Vector features = entry.getFeature(); assertEquals(3, features.size()); - SequenceFeature sf = features.get(0); + UniprotFeature sf = features.get(0); assertEquals("signal peptide", sf.getType()); assertNull(sf.getDescription()); assertNull(sf.getStatus()); - assertEquals(1, sf.getPosition()); assertEquals(1, sf.getBegin()); assertEquals(18, sf.getEnd()); sf = features.get(1); @@ -139,10 +138,8 @@ public class UniprotTest xref = xrefs.get(2); assertEquals("AE007869", xref.getId()); assertEquals("EMBL", xref.getType()); - assertEquals("AAK85932.1", - xref.getProperty("protein sequence ID")); - assertEquals("Genomic_DNA", - xref.getProperty("molecule type")); + assertEquals("AAK85932.1", xref.getProperty("protein sequence ID")); + assertEquals("Genomic_DNA", xref.getProperty("molecule type")); } @Test(groups = { "Functional" }) -- 1.7.10.2