initial support for EMBL file parsing.
authorjprocter <Jim Procter>
Mon, 19 Mar 2007 13:44:18 +0000 (13:44 +0000)
committerjprocter <Jim Procter>
Mon, 19 Mar 2007 13:44:18 +0000 (13:44 +0000)
resources/embl_mapping.xml [new file with mode: 0644]
src/jalview/datamodel/xdb/embl/BasePosition.java [new file with mode: 0644]
src/jalview/datamodel/xdb/embl/EmblEntry.java [new file with mode: 0644]
src/jalview/datamodel/xdb/embl/EmblError.java [new file with mode: 0644]
src/jalview/datamodel/xdb/embl/EmblFeature.java [new file with mode: 0644]
src/jalview/datamodel/xdb/embl/EmblFeatureLocElement.java [new file with mode: 0644]
src/jalview/datamodel/xdb/embl/EmblFeatureLocations.java [new file with mode: 0644]
src/jalview/datamodel/xdb/embl/EmblFile.java [new file with mode: 0644]
src/jalview/datamodel/xdb/embl/EmblSequence.java [new file with mode: 0644]
src/jalview/datamodel/xdb/embl/Qualifier.java [new file with mode: 0644]

diff --git a/resources/embl_mapping.xml b/resources/embl_mapping.xml
new file mode 100644 (file)
index 0000000..7238e89
--- /dev/null
@@ -0,0 +1,135 @@
+<?xml version="1.0"?>\r
+<mapping xmlns="http://castor.exolab.org/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+       xsi:schemaLocation="http://castor.exolab.org/ castor-mapping.xsd">\r
+       <!-- -->\r
+       <class name="jalview.datamodel.xdb.embl.EmblFile">\r
+               <map-to xml="EMBL_Services"/>\r
+               <field name="entries" type="jalview.datamodel.xdb.embl.EmblEntry" collection="vector">\r
+                       <bind-xml name="entry"/>\r
+               </field>\r
+               \r
+               <field name="errors" type="jalview.datamodel.xdb.embl.EmblError" collection="vector">\r
+                       <bind-xml name="Error"/>\r
+               </field>\r
+       </class>\r
+       <class name="jalview.datamodel.xdb.embl.EmblEntry">\r
+               <map-to xml="entry"/>\r
+               <field name="accession" type="string">
+                       <bind-xml location="accession" node="attribute"/>
+               </field>\r
+               <field name="lastUpdated" type="string">\r
+                       <bind-xml location="last-updated" node="attribute"/>\r
+               </field>\r
+               <field name="version" type="string">\r
+                       <bind-xml location="version" node="attribute"/>\r
+               </field>\r
+               \r
+               <field name="rCreated" type="string">\r
+                       <bind-xml location="releaseCreated" node="attribute"/>\r
+               </field>\r
+               <field name="rLastUpdated" type="string">\r
+                       <bind-xml location="releaseLastUpdated" node="attribute"/>\r
+               </field>\r
+               <field name="desc" type="string">
+                       <bind-xml name="description" node="element"/>
+               </field>\r
+               <field name="Keywords" type="string" collection="vector">\r
+                       <bind-xml name="keyword" node="element"/>\r
+               </field>\r
+               <field name="sequence" type="jalview.datamodel.xdb.embl.EmblSequence">\r
+                       <bind-xml location="sequence" node="element"/>\r
+               </field>\r
+               <field name="features" type="jalview.datamodel.xdb.embl.EmblFeature" collection="vector">\r
+                       <bind-xml name="feature"/>
+               </field>\r
+               <field name="dbRefs" type="jalview.datamodel.DBRefEntry" collection="vector">\r
+                       <bind-xml name="dbreference" />\r
+               </field>\r
+       </class>\r
+       <class name="jalview.datamodel.xdb.embl.EmblSequence">
+               <map-to xml="sequence"/>\r
+               <field name="type" type="string">\r
+                       <bind-xml name="type" node="attribute" location="type"/>\r
+               </field>\r
+               <field name="version" type="string">\r
+                       <bind-xml name="version" node="attribute" location="version"/>\r
+               </field>\r
+               <field name="sequence" type="string">\r
+                       <bind-xml node="text"/>\r
+               </field>
+       </class>\r
+       <class name="jalview.datamodel.xdb.embl.EmblFeature" verify-constructable="false">\r
+               <map-to xml="feature"/>\r
+               <field name="name" type="string">
+                       <bind-xml name="name" node="attribute"/>
+               </field>\r
+               <field name="dbRefs" type="jalview.datamodel.DBRefEntry" collection="vector">
+                       <bind-xml name="dbreference" node="element"/>
+               </field>\r
+               <field name="qualifiers" type="jalview.datamodel.xdb.embl.Qualifier" collection="vector">\r
+                       <bind-xml name="qualifier"/>\r
+               </field>                                        \r
+               <field name="locations" type="jalview.datamodel.xdb.embl.EmblFeatureLocations" collection="vector">\r
+                       <bind-xml name="location"/>\r
+               </field>\r
+       </class>\r
+       <class name="jalview.datamodel.DBRefEntry" verify-constructable="false">\r
+               <field name="accessionId" type="java.lang.String"><!-- set-method="setAccessionId" get-method="getAccessionId"> -->\r
+                       <bind-xml name="primary" node="attribute"/>\r
+               </field>\r
+               <field name="source" type="java.lang.String"> <!--set-method="setSource" get-method="getSource"> -->\r
+                       <bind-xml name="db" node="attribute"/>\r
+               </field>\r
+               <field name="version" type="string"><!-- set-method="setVersion" get-method="getVersion"> -->\r
+                       <bind-xml name="secondary" node="attribute"/>\r
+               </field>\r
+       </class>\r
+       <class  name="jalview.datamodel.xdb.embl.Qualifier" verify-constructable="false">
+               <map-to xml="Qualifier"/>\r
+               <field name="name">\r
+                       <bind-xml name="name" node="attribute"/>\r
+               </field>\r
+               <field name="value">
+                       <bind-xml node="text"/>
+               </field>\r
+       </class>\r
+       <class name="jalview.datamodel.xdb.embl.EmblFeatureLocations">\r
+               <map-to xml="location"/>\r
+               <field name="locationType" type="string">\r
+                       <bind-xml name="type" node="attribute"/>\r
+               </field>\r
+               <field name="locationComplement" type="boolean">\r
+                       <bind-xml name="complement" node="attribute"/>\r
+               </field>\r
+               <field name="locElements" type="jalview.datamodel.xdb.embl.EmblFeatureLocElement" collection="vector">\r
+                       <bind-xml name="locationElement"/>\r
+               </field>\r
+       </class>\r
+       <class name="jalview.datamodel.xdb.embl.EmblFeatureLocElement">\r
+               <map-to xml="locationElement"/>\r
+               <field name="type" type="string">\r
+                       <bind-xml name="type" node="attribute"/>\r
+               </field>\r
+               <field name="accession" type="string">\r
+                       <bind-xml name="accession" node="attribute"/>                   \r
+               </field>\r
+               <field name="version" type="string">\r
+                       <bind-xml name="version" node="attribute"/>\r
+               </field>\r
+               <field name="complement" type="boolean">\r
+                       <bind-xml name="complement"/>\r
+               </field>\r
+               <field name="basePositions" type="jalview.datamodel.xdb.embl.BasePosition" collection="array">\r
+                       <bind-xml name="basePosition" node="element"/>\r
+               </field>\r
+       </class>\r
+       <class name="jalview.datamodel.xdb.embl.BasePosition">
+               <map-to xml="basePosition"/>\r
+               <field name="type">
+                       <bind-xml name="type" node="attribute"/>
+               </field>\r
+               <field name="pos">
+                       <bind-xml node="text"/>\r
+               </field>\r
+       </class>\r
+</mapping>\r
diff --git a/src/jalview/datamodel/xdb/embl/BasePosition.java b/src/jalview/datamodel/xdb/embl/BasePosition.java
new file mode 100644 (file)
index 0000000..0b2dcbe
--- /dev/null
@@ -0,0 +1,30 @@
+package jalview.datamodel.xdb.embl;\r
+\r
+public class BasePosition {\r
+    String type;\r
+    String pos;\r
+    /**\r
+     * @return the pos\r
+     */\r
+    public String getPos() {\r
+        return pos;\r
+    }\r
+    /**\r
+     * @param pos the pos to set\r
+     */\r
+    public void setPos(String pos) {\r
+        this.pos = pos;\r
+    }\r
+    /**\r
+     * @return the type\r
+     */\r
+    public String getType() {\r
+        return type;\r
+    }\r
+    /**\r
+     * @param type the type to set\r
+     */\r
+    public void setType(String type) {\r
+        this.type = type;\r
+    }\r
+}\r
diff --git a/src/jalview/datamodel/xdb/embl/EmblEntry.java b/src/jalview/datamodel/xdb/embl/EmblEntry.java
new file mode 100644 (file)
index 0000000..ffe138b
--- /dev/null
@@ -0,0 +1,304 @@
+package jalview.datamodel.xdb.embl;\r
+\r
+import jalview.datamodel.DBRefEntry;\r
+import jalview.datamodel.Sequence;\r
+import jalview.datamodel.SequenceFeature;\r
+import jalview.datamodel.SequenceI;\r
+\r
+import java.util.Iterator;\r
+import java.util.Vector;\r
+\r
+public class EmblEntry {\r
+  String accession;\r
+  String version;\r
+  String taxDivision;\r
+  String desc;\r
+  String rCreated;\r
+  String rLastUpdated;\r
+  String lastUpdated;\r
+  Vector keywords;\r
+  Vector refs;\r
+  Vector dbRefs;\r
+  Vector features;\r
+  EmblSequence sequence;\r
+  /**\r
+   * @return the accession\r
+   */\r
+  public String getAccession() {\r
+    return accession;\r
+  }\r
+  /**\r
+   * @param accession the accession to set\r
+   */\r
+  public void setAccession(String accession) {\r
+    this.accession = accession;\r
+  }\r
+  /**\r
+   * @return the dbRefs\r
+   */\r
+  public Vector getDbRefs() {\r
+    return dbRefs;\r
+  }\r
+  /**\r
+   * @param dbRefs the dbRefs to set\r
+   */\r
+  public void setDbRefs(Vector dbRefs) {\r
+    this.dbRefs = dbRefs;\r
+  }\r
+  /**\r
+   * @return the desc\r
+   */\r
+  public String getDesc() {\r
+    return desc;\r
+  }\r
+  /**\r
+   * @param desc the desc to set\r
+   */\r
+  public void setDesc(String desc) {\r
+    this.desc = desc;\r
+  }\r
+  /**\r
+   * @return the features\r
+   */\r
+  public Vector getFeatures() {\r
+    return features;\r
+  }\r
+  /**\r
+   * @param features the features to set\r
+   */\r
+  public void setFeatures(Vector features) {\r
+    this.features = features;\r
+  }\r
+  /**\r
+   * @return the keywords\r
+   */\r
+  public Vector getKeywords() {\r
+    return keywords;\r
+  }\r
+  /**\r
+   * @param keywords the keywords to set\r
+   */\r
+  public void setKeywords(Vector keywords) {\r
+    this.keywords = keywords;\r
+  }\r
+  /**\r
+   * @return the lastUpdated\r
+   */\r
+  public String getLastUpdated() {\r
+    return lastUpdated;\r
+  }\r
+  /**\r
+   * @param lastUpdated the lastUpdated to set\r
+   */\r
+  public void setLastUpdated(String lastUpdated) {\r
+    this.lastUpdated = lastUpdated;\r
+  }\r
+  /**\r
+   * @return the refs\r
+   */\r
+  public Vector getRefs() {\r
+    return refs;\r
+  }\r
+  /**\r
+   * @param refs the refs to set\r
+   */\r
+  public void setRefs(Vector refs) {\r
+    this.refs = refs;\r
+  }\r
+  /**\r
+   * @return the releaseCreated\r
+   */\r
+  public String getRCreated() {\r
+    return rCreated;\r
+  }\r
+  /**\r
+   * @param releaseCreated the releaseCreated to set\r
+   */\r
+  public void setRcreated(String releaseCreated) {\r
+    this.rCreated = releaseCreated;\r
+  }\r
+  /**\r
+   * @return the releaseLastUpdated\r
+   */\r
+  public String getRLastUpdated() {\r
+    return rLastUpdated;\r
+  }\r
+  /**\r
+   * @param releaseLastUpdated the releaseLastUpdated to set\r
+   */\r
+  public void setRLastUpdated(String releaseLastUpdated) {\r
+    this.rLastUpdated = releaseLastUpdated;\r
+  }\r
+  /**\r
+   * @return the sequence\r
+   */\r
+  public EmblSequence getSequence() {\r
+    return sequence;\r
+  }\r
+  /**\r
+   * @param sequence the sequence to set\r
+   */\r
+  public void setSequence(EmblSequence sequence) {\r
+    this.sequence = sequence;\r
+  }\r
+  /**\r
+   * @return the taxDivision\r
+   */\r
+  public String getTaxDivision() {\r
+    return taxDivision;\r
+  }\r
+  /**\r
+   * @param taxDivision the taxDivision to set\r
+   */\r
+  public void setTaxDivision(String taxDivision) {\r
+    this.taxDivision = taxDivision;\r
+  }\r
+  /**\r
+   * @return the version\r
+   */\r
+  public String getVersion() {\r
+    return version;\r
+  }\r
+  /**\r
+   * @param version the version to set\r
+   */\r
+  public void setVersion(String version) {\r
+    this.version = version;\r
+  }\r
+\r
+  /**\r
+   * Recover annotated sequences from EMBL file\r
+   * @param noNa don't return nucleic acid sequences \r
+   * @param sourceDb TODO\r
+   * @param noProtein don't return any translated protein sequences marked in features\r
+   * @return dataset sequences with DBRefs and features - DNA always comes first\r
+   */\r
+  public jalview.datamodel.SequenceI[] getSequences(boolean noNa, boolean noPeptide, String sourceDb) {\r
+    Vector seqs=new Vector();\r
+    Sequence dna=null;\r
+    if (!noNa) {\r
+      dna = new Sequence(sourceDb+"|"+accession, sequence.getSequence());\r
+      dna.setDescription(desc);\r
+      dna.addDBRef(new DBRefEntry(sourceDb, version, accession));\r
+      // TODO: add mapping for parentAccession attribute\r
+      // TODO: transform EMBL Database refs to canonical form\r
+      if (dbRefs!=null)\r
+        for (Iterator i=dbRefs.iterator(); i.hasNext(); dna.addDBRef((DBRefEntry)i.next()));\r
+    }\r
+    for (Iterator i=features.iterator(); i.hasNext(); ) {\r
+      EmblFeature feature = (EmblFeature) i.next();\r
+      if (!noNa) {\r
+        if (feature.dbRefs!=null && feature.dbRefs.size()>0) {\r
+          for (Iterator dbr=feature.dbRefs.iterator(); dbr.hasNext(); dna.addDBRef((DBRefEntry)dbr.next()) )\r
+            ;\r
+        }\r
+      }\r
+      if (feature.getName().equalsIgnoreCase("CDS")) {\r
+        // extract coding region(s)\r
+        jalview.datamodel.Mapping map = null;\r
+        int[] exon=null;\r
+        if (feature.locations!=null && feature.locations.size()>0) {\r
+          for (Iterator locs=feature.locations.iterator();\r
+          locs.hasNext(); ) {\r
+            EmblFeatureLocations loc = (EmblFeatureLocations) locs.next();\r
+            int[] se = loc.getElementRanges();\r
+            if (exon==null) {\r
+              exon=se;\r
+            } else {\r
+              int[] t=new int[exon.length+se.length];\r
+              System.arraycopy(exon, 0, t, 0, exon.length);\r
+              System.arraycopy(se, 0, t, exon.length,se.length);\r
+              exon=t;\r
+            }\r
+          }\r
+        }\r
+        String prseq=null;\r
+        String prname=null;\r
+        String prid=null;\r
+        int prstart=1;\r
+        // get qualifiers\r
+        if (feature.getQualifiers()!=null && feature.getQualifiers().size()>0) {\r
+          for (Iterator quals=feature.getQualifiers().iterator(); quals.hasNext(); ) {\r
+            Qualifier q = (Qualifier) quals.next();\r
+            if (q.getName().equals("translation")) \r
+            {\r
+              prseq=q.getValue();\r
+            } \r
+            else\r
+              if (q.getName().equals("protein_id")) \r
+              {\r
+                prid=q.getValue();\r
+              }\r
+              else\r
+                if (q.getName().equals("codon_start"))\r
+                {\r
+                  prstart = Integer.parseInt(q.getValue());\r
+                }\r
+                else\r
+                  if (q.getName().equals("product")) {\r
+                    prname = q.getValue();\r
+                  }\r
+          }\r
+        }\r
+        Sequence product=null;\r
+        if (prseq!=null && prname!=null && prid!=null) {\r
+          // extract proteins.\r
+          if (!noPeptide) {\r
+            product = new Sequence(sourceDb+"|"+"EMBLCDS|"+prid+"|"+prname, prseq, prstart, prstart+prseq.length()-1);\r
+            product.setDescription("Protein Product from "+sourceDb);\r
+            seqs.add(product);\r
+          }\r
+          // we have everything - create the mapping and perhaps the protein sequence\r
+          map = new jalview.datamodel.Mapping(product, exon, new int[] { prstart, prstart+prseq.length()-1}, 3, 1);\r
+          // add cds feature to dna seq - this may include the stop codon\r
+          for (int xint=0;xint<exon.length; xint+=2) {\r
+            SequenceFeature sf = new SequenceFeature();\r
+            sf.setBegin(exon[xint]);\r
+            sf.setEnd(exon[xint+1]);\r
+            sf.setType(feature.getName());\r
+            sf.setFeatureGroup(jalview.datamodel.DBRefSource.EMBL);\r
+            sf.setDescription("Exon "+(1+xint)+" for protein '"+prname+"' EMBLCDS:"+prid);\r
+            dna.addSequenceFeature(sf);\r
+          }\r
+        }\r
+        // add dbRefs to sequence\r
+        if (feature.dbRefs!=null && feature.dbRefs.size()>0) \r
+        {\r
+          for (Iterator dbr=feature.dbRefs.iterator(); dbr.hasNext();  ) \r
+          {\r
+            DBRefEntry ref = (DBRefEntry)dbr.next();\r
+            ref.setSource(jalview.util.DBRefUtils.getCanonicalName(ref.getSource()));\r
+            if (ref.getSource().equals(jalview.datamodel.DBRefSource.UNIPROT)) \r
+            {\r
+              ref.setMap(map);\r
+            }\r
+            if (product!=null) {\r
+              DBRefEntry pref = new DBRefEntry(ref.getSource(), ref.getVersion(), ref.getAccessionId());\r
+              pref.setMap(null); // reference is direct\r
+            }\r
+            dna.addDBRef(ref);\r
+          }\r
+        }\r
+        \r
+      } else {\r
+        // General feature type.\r
+        if (!noNa) {\r
+          if (feature.dbRefs!=null && feature.dbRefs.size()>0) {\r
+            for (Iterator dbr=feature.dbRefs.iterator(); dbr.hasNext(); dna.addDBRef((DBRefEntry)dbr.next()) )\r
+              ;\r
+          }\r
+        }\r
+      }\r
+\r
+    }\r
+    if (!noNa) {\r
+      seqs.add(dna);\r
+    }\r
+    SequenceI[] sqs = new SequenceI[seqs.size()];\r
+    for (int i=0,j=seqs.size();i<j; i++) {\r
+      sqs[i] = (SequenceI) seqs.elementAt(i);\r
+      seqs.set(i, null);\r
+    }\r
+    return sqs;\r
+  }\r
+}\r
diff --git a/src/jalview/datamodel/xdb/embl/EmblError.java b/src/jalview/datamodel/xdb/embl/EmblError.java
new file mode 100644 (file)
index 0000000..c528022
--- /dev/null
@@ -0,0 +1,19 @@
+package jalview.datamodel.xdb.embl;\r
+\r
+public class EmblError {\r
+    String accession;\r
+\r
+    /**\r
+     * @return the accession\r
+     */\r
+    public String getAccession() {\r
+        return accession;\r
+    }\r
+\r
+    /**\r
+     * @param accession the accession to set\r
+     */\r
+    public void setAccession(String accession) {\r
+        this.accession = accession;\r
+    }\r
+}\r
diff --git a/src/jalview/datamodel/xdb/embl/EmblFeature.java b/src/jalview/datamodel/xdb/embl/EmblFeature.java
new file mode 100644 (file)
index 0000000..dff4161
--- /dev/null
@@ -0,0 +1,58 @@
+package jalview.datamodel.xdb.embl;\r
+import java.util.Hashtable;\r
+import java.util.Vector;\r
+public class EmblFeature {\r
+    String name;\r
+    Vector dbRefs;\r
+    Vector qualifiers;\r
+    Vector locations;\r
+    \r
+    /**\r
+     * @return the dbRefs\r
+     */\r
+    public Vector getDbRefs() {\r
+        return dbRefs;\r
+    }\r
+    /**\r
+     * @param dbRefs the dbRefs to set\r
+     */\r
+    public void setDbRefs(Vector dbRefs) {\r
+        this.dbRefs = dbRefs;\r
+    }\r
+    /**\r
+     * @return the locations\r
+     */\r
+    public Vector getLocations() {\r
+        return locations;\r
+    }\r
+    /**\r
+     * @param locations the locations to set\r
+     */\r
+    public void setLocations(Vector locations) {\r
+        this.locations = locations;\r
+    }\r
+    /**\r
+     * @return the name\r
+     */\r
+    public String getName() {\r
+        return name;\r
+    }\r
+    /**\r
+     * @param name the name to set\r
+     */\r
+    public void setName(String name) {\r
+        this.name = name;\r
+    }\r
+    /**\r
+     * @return the qualifiers\r
+     */\r
+    public Vector getQualifiers() {\r
+        return qualifiers;\r
+    }\r
+    /**\r
+     * @param qualifiers the qualifiers to set\r
+     */\r
+    public void setQualifiers(Vector qualifiers) {\r
+        this.qualifiers = qualifiers;\r
+    }\r
+}\r
diff --git a/src/jalview/datamodel/xdb/embl/EmblFeatureLocElement.java b/src/jalview/datamodel/xdb/embl/EmblFeatureLocElement.java
new file mode 100644 (file)
index 0000000..8cce8a9
--- /dev/null
@@ -0,0 +1,70 @@
+package jalview.datamodel.xdb.embl;\r
+\r
+public class EmblFeatureLocElement {\r
+        String type;\r
+        String accession;\r
+        String version;\r
+        boolean complement;\r
+        BasePosition basePositions[]; \r
+        /**\r
+         * @return the accession\r
+         */\r
+        public String getAccession() {\r
+            return accession;\r
+        }\r
+        /**\r
+         * @param accession the accession to set\r
+         */\r
+        public void setAccession(String accession) {\r
+            this.accession = accession;\r
+        }\r
+        /**\r
+         * @return the basePositions\r
+         */\r
+        public BasePosition[] getBasePositions() {\r
+            return basePositions;\r
+        }\r
+        /**\r
+         * @param basePositions the basePositions to set\r
+         */\r
+        public void setBasePositions(BasePosition[] basePositions) {\r
+            this.basePositions = basePositions;\r
+        }\r
+        /**\r
+         * @return the complement\r
+         */\r
+        public boolean isComplement() {\r
+            return complement;\r
+        }\r
+        /**\r
+         * @param complement the complement to set\r
+         */\r
+        public void setComplement(boolean complement) {\r
+            this.complement = complement;\r
+        }\r
+        /**\r
+         * @return the type\r
+         */\r
+        public String getType() {\r
+            return type;\r
+        }\r
+        /**\r
+         * @param type the type to set\r
+         */\r
+        public void setType(String type) {\r
+            this.type = type;\r
+        }\r
+        /**\r
+         * @return the version\r
+         */\r
+        public String getVersion() {\r
+            return version;\r
+        }\r
+        /**\r
+         * @param version the version to set\r
+         */\r
+        public void setVersion(String version) {\r
+            this.version = version;\r
+        }\r
+    }\r
+    \r
diff --git a/src/jalview/datamodel/xdb/embl/EmblFeatureLocations.java b/src/jalview/datamodel/xdb/embl/EmblFeatureLocations.java
new file mode 100644 (file)
index 0000000..878042d
--- /dev/null
@@ -0,0 +1,66 @@
+package jalview.datamodel.xdb.embl;\r
+\r
+import java.util.Iterator;\r
+import java.util.Vector;\r
+\r
+public class EmblFeatureLocations {\r
+    Vector locElements;\r
+    String locationType;\r
+    boolean locationComplement;\r
+    /**\r
+     * @return the locationComplement\r
+     */\r
+    public boolean isLocationComplement() {\r
+        return locationComplement;\r
+    }\r
+    /**\r
+     * @param locationComplement the locationComplement to set\r
+     */\r
+    public void setLocationComplement(boolean locationComplement) {\r
+        this.locationComplement = locationComplement;\r
+    }\r
+    /**\r
+     * @return the locationType\r
+     */\r
+    public String getLocationType() {\r
+        return locationType;\r
+    }\r
+    /**\r
+     * @param locationType the locationType to set\r
+     */\r
+    public void setLocationType(String locationType) {\r
+        this.locationType = locationType;\r
+    }\r
+    /**\r
+     * @return the locElements\r
+     */\r
+    public Vector getLocElements() {\r
+        return locElements;\r
+    }\r
+    /**\r
+     * @param locElements the locElements to set\r
+     */\r
+    public void setLocElements(Vector locElements) {\r
+        this.locElements = locElements;\r
+    }\r
+    /**\r
+     * Return all location elements as start-end pairs on referenced sequence \r
+     * @return int[] { start1, end1, ... }\r
+     */\r
+    public int[] getElementRanges() {\r
+        if (locationType.equalsIgnoreCase("single")) {\r
+            int[] se = new int[locElements.size()*2];            \r
+            int sepos=0;\r
+            for (Iterator le=locElements.iterator();le.hasNext();) {\r
+                EmblFeatureLocElement loce = (EmblFeatureLocElement) le.next();\r
+                BasePosition bp[] = loce.getBasePositions();\r
+                if (bp.length==2) {\r
+                    se[sepos++] = Integer.parseInt(bp[0].getPos());\r
+                    se[sepos++] = Integer.parseInt(bp[1].getPos());\r
+                }\r
+            }\r
+            return se;\r
+        }\r
+        return null;\r
+    }\r
+}
\ No newline at end of file
diff --git a/src/jalview/datamodel/xdb/embl/EmblFile.java b/src/jalview/datamodel/xdb/embl/EmblFile.java
new file mode 100644 (file)
index 0000000..bc8cbbe
--- /dev/null
@@ -0,0 +1,90 @@
+package jalview.datamodel.xdb.embl;\r
+\r
+\r
+import java.io.File;\r
+import java.io.FileReader;\r
+import java.io.Reader;\r
+import java.util.Vector;\r
+\r
+import org.exolab.castor.mapping.Mapping;\r
+import org.exolab.castor.xml.Unmarshaller;\r
+\r
+public class EmblFile {\r
+    Vector entries;\r
+    Vector errors;\r
+    /**\r
+     * @return the entries\r
+     */\r
+    public Vector getEntries() {\r
+        return entries;\r
+    }\r
+    /**\r
+     * @param entries the entries to set\r
+     */\r
+    public void setEntries(Vector entries) {\r
+        this.entries = entries;\r
+    }\r
+    /**\r
+     * @return the errors\r
+     */\r
+    public Vector getErrors() {\r
+        return errors;\r
+    }\r
+    /**\r
+     * @param errors the errors to set\r
+     */\r
+    public void setErrors(Vector errors) {\r
+        this.errors = errors;\r
+    }\r
+    /**\r
+     * Parse an EmblXML file into an EmblFile object\r
+     * @param file\r
+     * @return parsed EmblXML or null if exceptions were raised\r
+     */\r
+    public static EmblFile getEmblFile(File file)\r
+    {\r
+        if (file==null)\r
+            return null;\r
+        try {\r
+            return EmblFile.getEmblFile(new FileReader(file));\r
+        }\r
+        catch (Exception e) {\r
+            System.err.println("Exception whilst reading EMBLfile from "+file);\r
+            e.printStackTrace(System.err);\r
+        }\r
+        return null;\r
+    }\r
+    public static EmblFile getEmblFile(Reader file) {\r
+        EmblFile record = new EmblFile();\r
+        try\r
+        {\r
+          // 1. Load the mapping information from the file\r
+          Mapping map = new Mapping(record.getClass().getClassLoader());\r
+          java.net.URL url = record.getClass().getResource("/embl_mapping.xml");\r
+          map.loadMapping(url);\r
+\r
+          // 2. Unmarshal the data\r
+          Unmarshaller unmar = new Unmarshaller(record);\r
+          try {\r
+              // uncomment to DEBUG EMBLFile reading unmar.setDebug(jalview.bin.Cache.log.isDebugEnabled());\r
+          } catch (Exception e) {};\r
+          unmar.setIgnoreExtraElements(true);\r
+          unmar.setMapping(map);\r
+\r
+          record = (EmblFile) unmar.unmarshal(file);\r
+        }\r
+        catch (Exception e)\r
+        {\r
+          e.printStackTrace(System.err);\r
+          record=null;\r
+        }\r
+\r
+\r
+        return record;\r
+      }\r
+    public static void main(String args[]) {\r
+        EmblFile myfile = EmblFile.getEmblFile(new File("C:\\Documents and Settings\\JimP\\workspace-3.2\\Jalview Release\\schemas\\embleRecord.xml"));\r
+        if (myfile!=null && myfile.entries!=null && myfile.entries.size()>0)\r
+            System.out.println(myfile.entries.size()+" Records read.");\r
+        }\r
+}\r
diff --git a/src/jalview/datamodel/xdb/embl/EmblSequence.java b/src/jalview/datamodel/xdb/embl/EmblSequence.java
new file mode 100644 (file)
index 0000000..ac0bfef
--- /dev/null
@@ -0,0 +1,43 @@
+package jalview.datamodel.xdb.embl;\r
+\r
+public class EmblSequence {\r
+    String version;\r
+    String sequence;\r
+    String type;\r
+    /**\r
+     * @return the sequence\r
+     */\r
+    public String getSequence() {\r
+        return sequence;\r
+    }\r
+    /**\r
+     * @param sequence the sequence to set\r
+     */\r
+    public void setSequence(String sequence) {\r
+        this.sequence = sequence;\r
+    }\r
+    /**\r
+     * @return the type\r
+     */\r
+    public String getType() {\r
+        return type;\r
+    }\r
+    /**\r
+     * @param type the type to set\r
+     */\r
+    public void setType(String type) {\r
+        this.type = type;\r
+    }\r
+    /**\r
+     * @return the version\r
+     */\r
+    public String getVersion() {\r
+        return version;\r
+    }\r
+    /**\r
+     * @param version the version to set\r
+     */\r
+    public void setVersion(String version) {\r
+        this.version = version;\r
+    }\r
+}\r
diff --git a/src/jalview/datamodel/xdb/embl/Qualifier.java b/src/jalview/datamodel/xdb/embl/Qualifier.java
new file mode 100644 (file)
index 0000000..1c2d66e
--- /dev/null
@@ -0,0 +1,31 @@
+package jalview.datamodel.xdb.embl;\r
+\r
+public class Qualifier {\r
+    String name;\r
+    String value;\r
+    /**\r
+     * @return the name\r
+     */\r
+    public String getName() {\r
+        return name;\r
+    }\r
+    /**\r
+     * @param name the name to set\r
+     */\r
+    public void setName(String name) {\r
+        this.name = name;\r
+    }\r
+    /**\r
+     * @return the value\r
+     */\r
+    public String getValue() {\r
+        return value;\r
+    }\r
+    /**\r
+     * @param value the value to set\r
+     */\r
+    public void setValue(String value) {\r
+        this.value = value;\r
+    }\r
+    \r
+}\r