From: gmungoc Date: Wed, 21 Aug 2019 16:01:52 +0000 (+0100) Subject: JAL-3187 minor code tidying, todo removal X-Git-Tag: Release_2_11_1_0~22^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=650c1e87af071e4fd945e725bcd46995fa67d654;p=jalview.git JAL-3187 minor code tidying, todo removal --- diff --git a/src/jalview/datamodel/MappedFeatures.java b/src/jalview/datamodel/MappedFeatures.java index 3f43355..4b558a5 100644 --- a/src/jalview/datamodel/MappedFeatures.java +++ b/src/jalview/datamodel/MappedFeatures.java @@ -84,26 +84,21 @@ public class MappedFeatures * for a peptide-to-CDS mapping */ int[] codonIntervals = mapping.getMap().locateInFrom(toPosition, toPosition); - if (codonIntervals != null) + int[] codonPositions = codonIntervals == null ? null + : MappingUtils.flattenRanges(codonIntervals); + if (codonPositions != null && codonPositions.length == 3) { - codonPos = MappingUtils.flattenRanges(codonIntervals); - if (codonPos.length == 3) - { - baseCodon = new char[3]; - int cdsStart = fromSeq.getStart(); - baseCodon[0] = fromSeq.getCharAt(codonPos[0] - cdsStart); - baseCodon[1] = fromSeq.getCharAt(codonPos[1] - cdsStart); - baseCodon[2] = fromSeq.getCharAt(codonPos[2] - cdsStart); - } - else - { - baseCodon = null; - } + codonPos = codonPositions; + baseCodon = new char[3]; + int cdsStart = fromSeq.getStart(); + baseCodon[0] = fromSeq.getCharAt(codonPos[0] - cdsStart); + baseCodon[1] = fromSeq.getCharAt(codonPos[1] - cdsStart); + baseCodon[2] = fromSeq.getCharAt(codonPos[2] - cdsStart); } else { codonPos = null; - baseCodon = null; // todo tidy! + baseCodon = null; } } @@ -134,14 +129,16 @@ public class MappedFeatures if (colonPos >= 0) { String var = hgvsp.substring(colonPos + 1); - return var; + if (var.contains("p.")) // sanity check + { + return var; + } } } /* * otherwise, compute codon and peptide variant */ - // todo avoid duplication of code in AlignmentUtils.buildDnaVariantsMap int cdsPos = sf.getBegin(); if (cdsPos != sf.getEnd()) {