Merge branch 'develop' into update_212_Dec_merge_with_21125_chamges
[jalview.git] / src / jalview / ws / dbsources / EmblXmlSource.java
index b3b99ca..ba46a6c 100644 (file)
@@ -20,6 +20,8 @@
  */
 package jalview.ws.dbsources;
 
+import java.util.Locale;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.InputStream;
@@ -28,7 +30,6 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Hashtable;
 import java.util.List;
-import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
 
@@ -40,10 +41,9 @@ import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
-import com.stevesoft.pat.Regex;
 
 import jalview.analysis.SequenceIdMatcher;
-import jalview.bin.Cache;
+import jalview.bin.Console;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.DBRefEntry;
@@ -57,6 +57,8 @@ import jalview.util.DBRefUtils;
 import jalview.util.DnaUtils;
 import jalview.util.MapList;
 import jalview.util.MappingUtils;
+import jalview.util.MessageManager;
+import jalview.util.Platform;
 import jalview.ws.ebi.EBIFetchClient;
 import jalview.xml.binding.embl.EntryType;
 import jalview.xml.binding.embl.EntryType.Feature;
@@ -64,9 +66,19 @@ import jalview.xml.binding.embl.EntryType.Feature.Qualifier;
 import jalview.xml.binding.embl.ROOT;
 import jalview.xml.binding.embl.XrefType;
 
+import com.stevesoft.pat.Regex;
+
+/**
+ * Provides XML binding and parsing of EMBL or EMBLCDS records retrieved from
+ * (e.g.) {@code https://www.ebi.ac.uk/ena/data/view/x53828&display=xml}.
+ * 
+ * @deprecated endpoint withdrawn August 2020 (JAL-3692), use EmblFlatfileSource
+ */
+@Deprecated
 public abstract class EmblXmlSource extends EbiFileRetrievedProxy
 {
-  private static final Regex ACCESSION_REGEX = new Regex("^[A-Z]+[0-9]+");
+  // TODO: delete class or update tyhis validator for 2.12 style Platform.regex
+    private static final Regex ACCESSION_REGEX = Platform.newRegex("^[A-Z]+[0-9]+");
 
   /*
    * JAL-1856 Embl returns this text for query not found
@@ -97,8 +109,8 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
     try
     {
       reply = dbFetch.fetchDataAsFile(
-              emprefx.toLowerCase(Locale.ROOT) + ":" + query.trim(),
-              "display=xml", "xml");
+              emprefx.toLowerCase(Locale.ROOT) + ":" + query.trim(), "display=xml",
+              "xml");
     } catch (Exception e)
     {
       stopQuery();
@@ -448,8 +460,9 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
         else
         {
           // final product length truncation check
-          int[] exons2 = adjustForProteinLength(translationLength, exons);
-          dnaToProteinMapping = new Mapping(product, exons2,
+          int[] cdsRanges = adjustForProteinLength(translationLength,
+                  exons);
+          dnaToProteinMapping = new Mapping(product, cdsRanges,
                   new int[]
                   { 1, translationLength }, 3, 1);
           if (product != null)
@@ -658,7 +671,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
       return listToArray(ranges);
     } catch (ParseException e)
     {
-      Cache.warn(
+      Console.warn(
               String.format("Not parsing inexact CDS location %s in ENA %s",
                       location, accession));
       return new int[] {};