From 9efc6af45120e24f7a11cc8ce6409139844e5001 Mon Sep 17 00:00:00 2001 From: jprocter Date: Fri, 30 Nov 2007 13:49:42 +0000 Subject: [PATCH] case invariant matching of seqeunce feature to sequence id string --- src/jalview/datamodel/Alignment.java | 19 ++++++++++++++++--- src/jalview/datamodel/AlignmentI.java | 7 +++++++ src/jalview/io/FeaturesFile.java | 4 ++-- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index f36872e..3689433 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -336,11 +336,25 @@ public class Alignment /** */ public SequenceI findName(String name) { - int i = 0; + return findName(name,false); + } + /* (non-Javadoc) + * @see jalview.datamodel.AlignmentI#findName(java.lang.String, boolean) + */ + public SequenceI findName(String token, boolean b) + { + + int i = 0; + SequenceI sq=null; + String sqname=null; while (i < sequences.size()) { - if (getSequenceAt(i).getName().equals(name)) + sq = getSequenceAt(i); + sqname = sq.getName(); + if (sqname.equals(token) // exact match + || (b && // allow imperfect matches - case varies + (sqname.equalsIgnoreCase(token)))) { return getSequenceAt(i); } @@ -350,7 +364,6 @@ public class Alignment return null; } - public SequenceI[] findSequenceMatch(String name) { Vector matches = new Vector(); diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 82aff33..558b38d 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -294,5 +294,12 @@ public interface AlignmentI * get codon frames involving sequenceI */ public AlignedCodonFrame[] getCodonFrame(SequenceI seq); + /** + * find sequence with given name in alignment + * @param token name to find + * @param b true implies that case insensitive matching will also be tried + * @return matched sequence or null + */ + public SequenceI findName(String token, boolean b); } diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 3c8ad21..9b39d02 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -153,7 +153,7 @@ public class FeaturesFile // Still possible this is an old Jalview file, // which does not have type colours at the beginning token = st.nextToken(); - seq = align.findName(token); + seq = align.findName(token, true); if (seq != null) { desc = st.nextToken(); @@ -225,7 +225,7 @@ public class FeaturesFile if (!token.equals("ID_NOT_SPECIFIED")) { - seq = align.findName(token); + seq = align.findName(token, true); st.nextToken(); } else -- 1.7.10.2