JAL-2506 relocate Uniprot binding classes, bind to UniprotFeature not
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 24 May 2017 15:42:06 +0000 (16:42 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 24 May 2017 15:42:06 +0000 (16:42 +0100)
SequenceFeature

resources/uniprot_mapping.xml
src/jalview/datamodel/xdb/uniprot/UniprotEntry.java [moved from src/jalview/datamodel/UniprotEntry.java with 90% similarity]
src/jalview/datamodel/xdb/uniprot/UniprotFeature.java [new file with mode: 0644]
src/jalview/datamodel/xdb/uniprot/UniprotFile.java [moved from src/jalview/datamodel/UniprotFile.java with 96% similarity]
src/jalview/datamodel/xdb/uniprot/UniprotProteinName.java [moved from src/jalview/datamodel/UniprotProteinName.java with 97% similarity]
src/jalview/datamodel/xdb/uniprot/UniprotSequence.java [moved from src/jalview/datamodel/UniprotSequence.java with 97% similarity]
src/jalview/ws/dbsources/Uniprot.java
test/jalview/schemes/FeatureColourTest.java
test/jalview/ws/dbsources/UniprotTest.java

index 4a981ad..6344d1e 100755 (executable)
  * The Jalview Authors are detailed in the 'AUTHORS' file.
 -->
 <mapping>
-       <class name="jalview.datamodel.UniprotFile">
+       <class name="jalview.datamodel.xdb.uniprot.UniprotFile">
                  <map-to xml="uniprot"/>               
-                 <field name="UniprotEntries" type="jalview.datamodel.UniprotEntry" collection="vector">
+                 <field name="UniprotEntries" type="jalview.datamodel.xdb.uniprot.UniprotEntry" collection="vector">
                      <bind-xml name="entry"/>
                 </field>               
         </class>
                 
-        <class name="jalview.datamodel.UniprotEntry">
+        <class name="jalview.datamodel.xdb.uniprot.UniprotEntry">
                <field name="name" type="string" collection="vector"/>
                <field name="accession" type="string" collection="vector"/>
-               <field name="protein" type="jalview.datamodel.UniprotProteinName"/>
-           <field name="UniprotSequence" type="jalview.datamodel.UniprotSequence">
+               <field name="protein" type="jalview.datamodel.xdb.uniprot.UniprotProteinName"/>
+           <field name="UniprotSequence" type="jalview.datamodel.xdb.uniprot.UniprotSequence">
                <bind-xml name="sequence"/> 
            </field>
-           <field name="feature" type="jalview.datamodel.SequenceFeature" collection="vector"/>
+           <field name="feature" type="jalview.datamodel.xdb.uniprot.UniprotFeature" collection="vector"/>
            <field name="dbReference" type="jalview.datamodel.PDBEntry" collection="vector"/>
                       
         </class>
-       <class name="jalview.datamodel.UniprotProteinName">
+       <class name="jalview.datamodel.xdb.uniprot.UniprotProteinName">
                <field name="name" collection="vector" type="string">
                        <bind-xml name="fullName" location="recommendedName" node="element"/>
                </field>
        </class>
         <!-- uniprot protein name is now a collection of collections - the INCLUDES and CONTAINS entries of the uniprot
                record. This means this doesn't exist anymore...
-        <class name="jalview.datamodel.UniprotProteinName">
+        <class name="jalview.datamodel.xdb.uniprot.UniprotProteinName">
                <field name="name" type="string" collection="vector">
                        <bind-xml name="name"/>
                </field>                
         </class>
         -->
         
-        <class name="jalview.datamodel.SequenceFeature">
+        <class name="jalview.datamodel.xdb.uniprot.UniprotFeature">
                <field name="type">
                        <bind-xml node="attribute"/>
                </field>
@@ -71,7 +71,7 @@
                 </field>
         </class>
        
-          <class name="jalview.datamodel.UniprotSequence">
+          <class name="jalview.datamodel.xdb.uniprot.UniprotSequence">
                     <field name="content" type="string">
                        <bind-xml name="sequence" node="text"/>
                     </field>
similarity index 90%
rename from src/jalview/datamodel/UniprotEntry.java
rename to src/jalview/datamodel/xdb/uniprot/UniprotEntry.java
index 4cf0f13..a3537c9 100755 (executable)
@@ -18,7 +18,9 @@
  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * 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<String> accession;
 
-  Vector<SequenceFeature> feature;
+  Vector<UniprotFeature> feature;
 
   Vector<PDBEntry> dbrefs;
 
@@ -47,12 +49,12 @@ public class UniprotEntry
     accession = items;
   }
 
-  public void setFeature(Vector<SequenceFeature> items)
+  public void setFeature(Vector<UniprotFeature> items)
   {
     feature = items;
   }
 
-  public Vector<SequenceFeature> getFeature()
+  public Vector<UniprotFeature> 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 (file)
index 0000000..4a359ff
--- /dev/null
@@ -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;
+  }
+}
similarity index 96%
rename from src/jalview/datamodel/UniprotFile.java
rename to src/jalview/datamodel/xdb/uniprot/UniprotFile.java
index f0e38d8..9cc0391 100755 (executable)
@@ -18,7 +18,7 @@
  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
-package jalview.datamodel;
+package jalview.datamodel.xdb.uniprot;
 
 import java.util.Vector;
 
@@ -18,7 +18,7 @@
  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
-package jalview.datamodel;
+package jalview.datamodel.xdb.uniprot;
 
 import java.util.Vector;
 
similarity index 97%
rename from src/jalview/datamodel/UniprotSequence.java
rename to src/jalview/datamodel/xdb/uniprot/UniprotSequence.java
index 1150f1e..bdba73f 100755 (executable)
@@ -18,7 +18,7 @@
  * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
  * 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
index 4898b42..6ddd828 100644 (file)
@@ -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);
       }
     }
index c16d541..822fcd4 100644 (file)
@@ -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" })
index 2f548d0..2d4be71 100644 (file)
@@ -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<SequenceFeature> features = entry.getFeature();
+    Vector<UniprotFeature> 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" })