X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FMappedFeatures.java;h=2bc82bc16d0601a553405a488a7db1f4ddce6be8;hb=refs%2Fheads%2Fbug%2FJAL-3706virtualStopCodon;hp=1f672befcc5df3912bfe9f19c1fababb13770479;hpb=881dd37ce1077bce230b6b04690112d9d6eafecd;p=jalview.git diff --git a/src/jalview/datamodel/MappedFeatures.java b/src/jalview/datamodel/MappedFeatures.java index 1f672be..2bc82bc 100644 --- a/src/jalview/datamodel/MappedFeatures.java +++ b/src/jalview/datamodel/MappedFeatures.java @@ -296,21 +296,30 @@ public class MappedFeatures { int[] result = null; MapList map = mapping.getMap(); + + /* + * mapping may be in either direction, so handle either case; + * limit feature extent to the range of the mapping if it is greater + * (e.g. an overlapping exon); if that still fails, try reducing by + * 3 positions (to omit a mapped stop codon) + */ if (mapping.to == featureSequence) { + begin = Math.max(begin, map.getToLowest()); + end = Math.min(end, map.getToHighest()); result = map.locateInFrom(begin, end); if (result == null) { - // fudge for feature (e.g. CDS) extending to a mapped stop codon result = map.locateInFrom(begin, end-3); } } else { + begin = Math.max(begin, map.getFromLowest()); + end = Math.min(end, map.getFromHighest()); result = map.locateInTo(begin, end); if (result == null) { - // fudge for feature (e.g. CDS) extending to a mapped stop codon result = map.locateInTo(begin, end-3); } }