From 1201b837a0431d6a28943972d494a8c4ff36eb34 Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 14 Aug 2006 12:50:35 +0000 Subject: [PATCH] fixed off by one bug in end sequence from getSubSequence and added new subSequence method (not properly tested yet). --- src/jalview/datamodel/Sequence.java | 10 +++++++++- src/jalview/datamodel/SequenceI.java | 11 +++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/jalview/datamodel/Sequence.java b/src/jalview/datamodel/Sequence.java index dee67d3..0225c88 100755 --- a/src/jalview/datamodel/Sequence.java +++ b/src/jalview/datamodel/Sequence.java @@ -351,7 +351,7 @@ public class Sequence implements SequenceI if (seq=="") return null; int nstart = findPosition(start); - int nend=findPosition(end-1)-1; + int nend=findPosition(end)-1; // JBPNote - this is an incomplete copy. SequenceI nseq = new Sequence(this.getName(), seq, nstart, nend); nseq.setDatasetSequence(getDatasetSequence()); @@ -710,4 +710,12 @@ public class Sequence implements SequenceI sequence = newSeq.toString(); } + public SequenceI getSubSequence(int start) + { + int e=getLength(); + if (start>=e) + return null; + return getSubSequence(start, getLength()); + } + } diff --git a/src/jalview/datamodel/SequenceI.java b/src/jalview/datamodel/SequenceI.java index d711788..0842d94 100755 --- a/src/jalview/datamodel/SequenceI.java +++ b/src/jalview/datamodel/SequenceI.java @@ -18,10 +18,10 @@ */ package jalview.datamodel; -import java.awt.*; - import java.util.*; +import java.awt.*; + /** * DOCUMENT ME! @@ -264,4 +264,11 @@ public interface SequenceI public void toggleCase(int start, int end); + /** + * getSubSequence from start to end of sequence + * @param start first residue in subSequence + * @return SequenceI + */ + public SequenceI getSubSequence(int start); + } -- 1.7.10.2