X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2FEmblXmlSource.java;h=ba46a6c3ad5f44c053bbef5386a7ac05445a697d;hb=d043ce47fc710d3eb2629ba926a8a7417bd67d8c;hp=97d7c9f0028b580485242887885f7e45a06b2f87;hpb=582096635d0502a9bc8415c8f1ef3bcc9c545a44;p=jalview.git diff --git a/src/jalview/ws/dbsources/EmblXmlSource.java b/src/jalview/ws/dbsources/EmblXmlSource.java index 97d7c9f..ba46a6c 100644 --- a/src/jalview/ws/dbsources/EmblXmlSource.java +++ b/src/jalview/ws/dbsources/EmblXmlSource.java @@ -20,6 +20,8 @@ */ package jalview.ws.dbsources; +import java.util.Locale; + import java.io.File; import java.io.FileInputStream; import java.io.InputStream; @@ -39,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; @@ -56,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; @@ -63,15 +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 @@ -102,14 +109,14 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy try { reply = dbFetch.fetchDataAsFile( - emprefx.toLowerCase() + ":" + query.trim(), "display=xml", + emprefx.toLowerCase(Locale.ROOT) + ":" + query.trim(), "display=xml", "xml"); } catch (Exception e) { stopQuery(); throw new Exception( String.format("EBI EMBL XML retrieval failed for %s:%s", - emprefx.toLowerCase(), query.trim()), + emprefx.toLowerCase(Locale.ROOT), query.trim()), e); } return getEmblSequenceRecords(emprefx, query, reply); @@ -664,7 +671,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy 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[] {}; @@ -757,8 +764,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy /** * 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 @@ -775,11 +781,9 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy 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; }