From 650c1e87af071e4fd945e725bcd46995fa67d654 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Wed, 21 Aug 2019 17:01:52 +0100 Subject: [PATCH] JAL-3187 minor code tidying, todo removal --- src/jalview/datamodel/MappedFeatures.java | 31 +++++++++++++---------------- 1 file changed, 14 insertions(+), 17 deletions(-) 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()) { -- 1.7.10.2