From 8be401021a3c729aeb6226397ae1d941ccac08da Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 10 Feb 2015 14:57:50 +0000 Subject: [PATCH] JAL-1382 slightly more efficient detection of non-gap entry in deleted region of sequence --- src/jalview/datamodel/Sequence.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index fb559eb..1479d94 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -729,9 +729,10 @@ public class Sequence implements SequenceI char[] tmp = StringUtils.deleteChars(sequence, i, j); boolean createNewDs = false; - // TODO: take a look at the new dataset creation validation method below - - // this could become time comsuming for large sequences - consider making it - // more efficient + // TODO: take a (second look) at the dataset creation validation method for + // the very large sequence case + int eindex = -1, sindex = -1; + boolean ecalc = false, scalc = false; for (int s = i; s < j; s++) { if (jalview.schemes.ResidueProperties.aaIndex[sequence[s]] != 23) @@ -742,7 +743,11 @@ public class Sequence implements SequenceI } else { - int sindex = findIndex(start) - 1; + if (!scalc) + { + sindex = findIndex(start) - 1; + scalc = true; + } if (sindex == s) { // delete characters including start of sequence @@ -752,7 +757,11 @@ public class Sequence implements SequenceI else { // delete characters after start. - int eindex = findIndex(end) - 1; + if (!ecalc) + { + eindex = findIndex(end) - 1; + ecalc = true; + } if (eindex < j) { // delete characters at end of sequence -- 1.7.10.2