X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fanalysis%2FAlignmentUtils.java;h=d1217bfa2d67c2303c777e532b642c360ea5cc65;hb=948bd3bcbacc509da0cefaae3eedd97300a6ccce;hp=aa1a98b98dd4a91d7f2811e89da76b9997b29a09;hpb=241bd0223b016b5ad5ec78520310a8de32842722;p=jalview.git diff --git a/src/jalview/analysis/AlignmentUtils.java b/src/jalview/analysis/AlignmentUtils.java index aa1a98b..d1217bf 100644 --- a/src/jalview/analysis/AlignmentUtils.java +++ b/src/jalview/analysis/AlignmentUtils.java @@ -1888,7 +1888,7 @@ public class AlignmentUtils * @param seqMappings * the set of mappings involving dnaSeq * @param aMapping - * an initial candidate from seqMappings + * a transcript-to-peptide mapping * @return */ static SequenceI findCdsForProtein(List mappings, @@ -1913,7 +1913,15 @@ public class AlignmentUtils if (mappedFromLength == dnaLength || mappedFromLength == dnaLength - CODON_LENGTH) { - return seqDss; + /* + * if sequence has CDS features, this is a transcript with no UTR + * - do not take this as the CDS sequence! (JAL-2789) + */ + if (seqDss.getFeatures().getFeaturesByOntology(SequenceOntologyI.CDS) + .isEmpty()) + { + return seqDss; + } } /* @@ -1938,10 +1946,12 @@ public class AlignmentUtils { /* * found a 3:1 mapping to the protein product which covers - * the whole dna sequence i.e. is from CDS; finally check it - * is from the dna start sequence + * the whole dna sequence i.e. is from CDS; finally check the CDS + * is mapped from the given dna start sequence */ SequenceI cdsSeq = map.getFromSeq(); + // todo this test is weak if seqMappings contains multiple mappings; + // we get away with it if transcript:cds relationship is 1:1 List dnaToCdsMaps = MappingUtils .findMappingsForSequence(cdsSeq, seqMappings); if (!dnaToCdsMaps.isEmpty()) @@ -2056,9 +2066,11 @@ public class AlignmentUtils protected static List propagateDBRefsToCDS(SequenceI cdsSeq, SequenceI contig, SequenceI proteinProduct, Mapping mapping) { + // gather direct refs from contig congruent with mapping List direct = new ArrayList<>(); HashSet directSources = new HashSet<>(); + if (contig.getDBRefs() != null) { for (DBRefEntry dbr : contig.getDBRefs()) @@ -2235,12 +2247,13 @@ public class AlignmentUtils int mappedDnaLength = MappingUtils.getLength(ranges); /* - * if not a whole number of codons, something is wrong, - * abort mapping + * if not a whole number of codons, truncate mapping */ - if (mappedDnaLength % CODON_LENGTH > 0) + int codonRemainder = mappedDnaLength % CODON_LENGTH; + if (codonRemainder > 0) { - return null; + mappedDnaLength -= codonRemainder; + MappingUtils.removeEndPositions(codonRemainder, ranges); } int proteinLength = proteinSeq.getLength(); @@ -2430,11 +2443,14 @@ public class AlignmentUtils { for (String base : alleles.split(",")) { - if (!base1.equals(base)) + if (!base1.equalsIgnoreCase(base)) { - String codon = base + base2 + base3; + String codon = base.toUpperCase() + base2.toLowerCase() + + base3.toLowerCase(); + String canonical = base1.toUpperCase() + base2.toLowerCase() + + base3.toLowerCase(); if (addPeptideVariant(peptide, peptidePos, residue, var, - codon)) + codon, canonical)) { count++; } @@ -2456,11 +2472,14 @@ public class AlignmentUtils { for (String base : alleles.split(",")) { - if (!base2.equals(base)) + if (!base2.equalsIgnoreCase(base)) { - String codon = base1 + base + base3; + String codon = base1.toLowerCase() + base.toUpperCase() + + base3.toLowerCase(); + String canonical = base1.toLowerCase() + base2.toUpperCase() + + base3.toLowerCase(); if (addPeptideVariant(peptide, peptidePos, residue, var, - codon)) + codon, canonical)) { count++; } @@ -2482,11 +2501,14 @@ public class AlignmentUtils { for (String base : alleles.split(",")) { - if (!base3.equals(base)) + if (!base3.equalsIgnoreCase(base)) { - String codon = base1 + base2 + base; + String codon = base1.toLowerCase() + base2.toLowerCase() + + base.toUpperCase(); + String canonical = base1.toLowerCase() + base2.toLowerCase() + + base3.toUpperCase(); if (addPeptideVariant(peptide, peptidePos, residue, var, - codon)) + codon, canonical)) { count++; } @@ -2509,10 +2531,13 @@ public class AlignmentUtils * @param residue * @param var * @param codon + * the variant codon e.g. aCg + * @param canonical + * the 'normal' codon e.g. aTg * @return true if a feature was added, else false */ static boolean addPeptideVariant(SequenceI peptide, int peptidePos, - String residue, DnaVariant var, String codon) + String residue, DnaVariant var, String codon, String canonical) { /* * get peptide translation of codon e.g. GAT -> D @@ -2527,7 +2552,7 @@ public class AlignmentUtils { return false; } - String desc = codon; + String desc = canonical + "/" + codon; String featureType = ""; if (trans.equals(residue)) {