From c9296c060f69f3eeab1f6da2a07dbdb87c946e52 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Wed, 16 Sep 2020 17:33:26 +0100 Subject: [PATCH] =?utf8?q?JAL-3700=20JAL-3748=20AlignedCodonFrame.covers(seq?= =?utf8?q?,true)=20to=20verify=20mapping=20matches=20seq=E2=80=99s=20dataset?= =?utf8?q?=20sequence=20start/end=20rather=20than=20seq?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/datamodel/AlignedCodonFrame.java | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/jalview/datamodel/AlignedCodonFrame.java b/src/jalview/datamodel/AlignedCodonFrame.java index 6103df5..9fa11cc 100644 --- a/src/jalview/datamodel/AlignedCodonFrame.java +++ b/src/jalview/datamodel/AlignedCodonFrame.java @@ -118,14 +118,36 @@ public class AlignedCodonFrame */ public boolean covers(SequenceI seq) { + return covers(seq,false); + } + /** + * + * @param seq + * @param localCover - when true - compare extent of seq's dataset sequence rather than the local extent + * @return true if mapping covers full length of given sequence + */ + public boolean covers(SequenceI seq, boolean localCover) + { List mappedRanges = null; MapList mapList = mapping.getMap(); + int mstart=seq.getStart(),mend=seq.getEnd() + ; if (fromSeq == seq || fromSeq == seq.getDatasetSequence()) { + if (localCover && fromSeq !=seq) + { + mstart=fromSeq.getStart(); + mend=fromSeq.getEnd(); + } mappedRanges = mapList.getFromRanges(); } else if (mapping.to == seq || mapping.to == seq.getDatasetSequence()) { + if (localCover && mapping.to !=seq) + { + mstart=mapping.to.getStart(); + mend=mapping.to.getEnd(); + } mappedRanges = mapList.getToRanges(); } else @@ -143,14 +165,14 @@ public class AlignedCodonFrame { int from = Math.min(range[0], range[1]); int to = Math.max(range[0], range[1]); - if (from < seq.getStart() || to > seq.getEnd()) + if (from < mstart || to > mend) { return false; } length += (to - from + 1); } // add 1 to mapped length to allow for a mapped stop codon - if (length + 1 < (seq.getEnd() - seq.getStart() + 1)) + if (length + 1 < (mend - mstart + 1)) { return false; } -- 1.7.10.2