case invariant matching of seqeunce feature to sequence id string
authorjprocter <Jim Procter>
Fri, 30 Nov 2007 13:49:42 +0000 (13:49 +0000)
committerjprocter <Jim Procter>
Fri, 30 Nov 2007 13:49:42 +0000 (13:49 +0000)
src/jalview/datamodel/Alignment.java
src/jalview/datamodel/AlignmentI.java
src/jalview/io/FeaturesFile.java

index f36872e..3689433 100755 (executable)
@@ -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();
index 82aff33..558b38d 100755 (executable)
@@ -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 <em>also</em> be tried 
+   * @return matched sequence or null
+   */
+  public SequenceI findName(String token, boolean b);
   
 }
index 3c8ad21..9b39d02 100755 (executable)
@@ -153,7 +153,7 @@ public class FeaturesFile
             // Still possible this is an old Jalview file,\r
             // which does not have type colours at the beginning\r
             token = st.nextToken();\r
-            seq = align.findName(token);\r
+            seq = align.findName(token, true);\r
             if (seq != null)\r
             {\r
               desc = st.nextToken();\r
@@ -225,7 +225,7 @@ public class FeaturesFile
           \r
           if (!token.equals("ID_NOT_SPECIFIED"))\r
           {\r
-            seq = align.findName(token);\r
+            seq = align.findName(token, true);\r
             st.nextToken();\r
           }\r
           else\r