JAL-3210 Ensure skip transpile errors flag is 'false' when channel is RELEASE or...
[jalview.git] / src / jalview / ws / dbsources / EmblXmlSource.java
index 8f55080..668aab5 100644 (file)
@@ -40,6 +40,8 @@ import jalview.ws.ebi.EBIFetchClient;
 import jalview.xml.binding.embl.EntryType;
 import jalview.xml.binding.embl.EntryType.Feature;
 import jalview.xml.binding.embl.EntryType.Feature.Qualifier;
+import jalview.xml.binding.jalview.JalviewModel;
+import jalview.xml.binding.embl.ROOT;
 import jalview.xml.binding.embl.XrefType;
 
 import java.io.File;
@@ -55,6 +57,7 @@ import java.util.Map.Entry;
 import java.util.regex.Pattern;
 
 import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.stream.FactoryConfigurationError;
 import javax.xml.stream.XMLInputFactory;
@@ -85,7 +88,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
    * @return
    * @throws Exception
    */
-  public AlignmentI getEmblSequenceRecords(String emprefx, String query)
+  protected AlignmentI getEmblSequenceRecords(String emprefx, String query)
           throws Exception
   {
     startQuery();
@@ -118,7 +121,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
    * @return
    * @throws Exception
    */
-  public AlignmentI getEmblSequenceRecords(String emprefx, String query,
+  protected AlignmentI getEmblSequenceRecords(String emprefx, String query,
           File reply) throws Exception
   {
     List<EntryType> entries = null;
@@ -183,8 +186,8 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
       XMLStreamReader streamReader = XMLInputFactory.newInstance()
               .createXMLStreamReader(is);
       javax.xml.bind.Unmarshaller um = jc.createUnmarshaller();
-      jalview.xml.binding.embl.ROOT root = (jalview.xml.binding.embl.ROOT) um
-              .unmarshal(streamReader);
+      JAXBElement<ROOT> rootElement =  um.unmarshal(streamReader, ROOT.class);
+      ROOT root = rootElement.getValue();
 
       /*
        * document root contains either "entry" or "entrySet"
@@ -244,14 +247,18 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
     /*
      * add db references
      */
-    List<XrefType> dbRefs = entry.getXref();
-    if (dbRefs != null)
+    List<XrefType> xrefs = entry.getXref();
+    if (xrefs != null)
     {
-      for (XrefType dbref : dbRefs)
+      for (XrefType xref : xrefs)
       {
-        String acc = dbref.getId();
-        String source = DBRefUtils.getCanonicalName(dbref.getDb());
-        String version = dbref.getSecondaryId();
+        String acc = xref.getId();
+        String source = DBRefUtils.getCanonicalName(xref.getDb());
+        String version = xref.getSecondaryId();
+        if (version == null || "".equals(version))
+        {
+          version = "0";
+        }
         dna.addDBRef(new DBRefEntry(source, version, acc));
       }
     }
@@ -524,10 +531,14 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
          * ensure UniProtKB/Swiss-Prot converted to UNIPROT
          */
         String source = DBRefUtils.getCanonicalName(xref.getDb());
-        DBRefEntry dbref = new DBRefEntry(source, xref.getSecondaryId(),
-                xref.getId());
-        DBRefEntry proteinDbRef = new DBRefEntry(dbref.getSource(),
-                dbref.getVersion(), dbref.getAccessionId());
+        String version = xref.getSecondaryId();
+        if (version == null || "".equals(version))
+        {
+          version = "0";
+        }
+        DBRefEntry dbref = new DBRefEntry(source, version, xref.getId());
+        DBRefEntry proteinDbRef = new DBRefEntry(source, version,
+                dbref.getAccessionId());
         if (source.equals(DBRefSource.UNIPROT))
         {
           String proteinSeqName = DBRefSource.UNIPROT + "|"