Merge branch 'develop' into update_212_Dec_merge_with_21125_chamges
[jalview.git] / src / jalview / ws / dbsources / EmblXmlSource.java
index 7bb1977..ba46a6c 100644 (file)
@@ -41,8 +41,9 @@ import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 
+
 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 +58,7 @@ 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,17 +66,20 @@ 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
 {
   // TODO: delete class or update tyhis validator for 2.12 style Platform.regex
-  private static final Regex ACCESSION_REGEX = new Regex("^[A-Z]+[0-9]+");
+    private static final Regex ACCESSION_REGEX = Platform.newRegex("^[A-Z]+[0-9]+");
+
   /*
    * JAL-1856 Embl returns this text for query not found
    */
@@ -659,13 +664,14 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
     {
       return new int[] {};
     }
+
     try
     {
       List<int[]> ranges = DnaUtils.parseLocation(location);
       return listToArray(ranges);
     } catch (ParseException e)
     {
-      Cache.log.warn(
+      Console.warn(
               String.format("Not parsing inexact CDS location %s in ENA %s",
                       location, accession));
       return new int[] {};
@@ -755,10 +761,10 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
     }
     return getAccessionValidator().search(accession);
   }
+
   /**
    * Truncates (if necessary) the exon intervals to match 3 times the length of
-   * the protein; also accepts 3 bases longer (for stop codon not included in
-   * protein)
+   * the protein (including truncation for stop codon included in exon)
    * 
    * @param proteinLength
    * @param exon
@@ -773,15 +779,15 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
     }
     int expectedCdsLength = proteinLength * 3;
     int exonLength = MappingUtils.getLength(Arrays.asList(exon));
+
     /*
-     * if exon length matches protein, or is shorter, or longer by the 
-     * length of a stop codon (3 bases), then leave it unchanged
+     * if exon length matches protein, or is shorter, then leave it unchanged
      */
-    if (expectedCdsLength >= exonLength
-            || expectedCdsLength == exonLength - 3)
+    if (expectedCdsLength >= exonLength)
     {
       return exon;
     }
+
     int origxon[];
     int sxpos = -1;
     int endxon = 0;
@@ -801,6 +807,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
           // .println("Truncating final exon interval on region by "
           // + (cdspos - cdslength));
         }
+
         /*
          * shrink the final exon - reduce end position if forward
          * strand, increase it if reverse
@@ -816,6 +823,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy
         break;
       }
     }
+
     if (sxpos != -1)
     {
       // and trim the exon interval set if necessary