X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fws%2Fdbsources%2FEmblXmlSource.java;h=a4d96330c34aeee5f8198264f47d47c08a060e18;hb=6ca8a32d88328b8f2162512f41c657c87e131045;hp=97d7c9f0028b580485242887885f7e45a06b2f87;hpb=ebcef6bb58275b0044d063ab3425cd7325401577;p=jalview.git diff --git a/src/jalview/ws/dbsources/EmblXmlSource.java b/src/jalview/ws/dbsources/EmblXmlSource.java index 97d7c9f..a4d9633 100644 --- a/src/jalview/ws/dbsources/EmblXmlSource.java +++ b/src/jalview/ws/dbsources/EmblXmlSource.java @@ -28,6 +28,7 @@ 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; @@ -42,7 +43,7 @@ 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; @@ -63,12 +64,6 @@ import jalview.xml.binding.embl.EntryType.Feature.Qualifier; import jalview.xml.binding.embl.ROOT; import jalview.xml.binding.embl.XrefType; -/** - * 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 - */ public abstract class EmblXmlSource extends EbiFileRetrievedProxy { private static final Regex ACCESSION_REGEX = new Regex("^[A-Z]+[0-9]+"); @@ -102,14 +97,14 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy try { reply = dbFetch.fetchDataAsFile( - emprefx.toLowerCase() + ":" + query.trim(), "display=xml", - "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); @@ -166,7 +161,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy } else { - System.out.println( + jalview.bin.Console.outPrintln( "No record found for '" + emprefx + ":" + query + "'"); } } @@ -288,11 +283,11 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy } } catch (Exception e) { - System.err.println("EMBL Record Features parsing error!"); + jalview.bin.Console.errPrintln("EMBL Record Features parsing error!"); System.err .println("Please report the following to help@jalview.org :"); - System.err.println("EMBL Record " + accession); - System.err.println("Resulted in exception: " + e.getMessage()); + jalview.bin.Console.errPrintln("EMBL Record " + accession); + jalview.bin.Console.errPrintln("Resulted in exception: " + e.getMessage()); e.printStackTrace(System.err); } @@ -359,7 +354,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy codonStart = Integer.parseInt(value.trim()); } catch (NumberFormatException e) { - System.err.println("Invalid codon_start in XML for " + jalview.bin.Console.errPrintln("Invalid codon_start in XML for " + entry.getAccession() + ": " + e.getMessage()); } } @@ -411,13 +406,13 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy * workaround until we handle dna location for CDS sequence * e.g. location="X53828.1:60..1058" correctly */ - System.err.println( + jalview.bin.Console.errPrintln( "Implementation Notice: EMBLCDS records not properly supported yet - Making up the CDNA region of this sequence... may be incorrect (" + sourceDb + ":" + entry.getAccession() + ")"); int dnaLength = dna.getLength(); if (translationLength * 3 == (1 - codonStart + dnaLength)) { - System.err.println( + jalview.bin.Console.errPrintln( "Not allowing for additional stop codon at end of cDNA fragment... !"); // this might occur for CDS sequences where no features are marked exons = new int[] { dna.getStart() + (codonStart - 1), @@ -428,7 +423,7 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy } if ((translationLength + 1) * 3 == (1 - codonStart + dnaLength)) { - System.err.println( + jalview.bin.Console.errPrintln( "Allowing for additional stop codon at end of cDNA fragment... will probably cause an error in VAMSAs!"); exons = new int[] { dna.getStart() + (codonStart - 1), dna.getEnd() - 3 }; @@ -453,9 +448,8 @@ public abstract class EmblXmlSource extends EbiFileRetrievedProxy else { // final product length truncation check - int[] cdsRanges = adjustForProteinLength(translationLength, - exons); - dnaToProteinMapping = new Mapping(product, cdsRanges, + int[] exons2 = adjustForProteinLength(translationLength, exons); + dnaToProteinMapping = new Mapping(product, exons2, new int[] { 1, translationLength }, 3, 1); if (product != null) @@ -664,7 +658,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 +751,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 +768,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; }