and improved code robustness when dealing with badly formed IDs (null strings).
\r
SeqIdName(String s)\r
{\r
\r
SeqIdName(String s)\r
{\r
+ if (s!=null)\r
+ id = new String(s);\r
+ else\r
+ id = "";\r
}\r
\r
public int hashCode()\r
{\r
}\r
\r
public int hashCode()\r
{\r
- return (id.substring(0, 4).hashCode());\r
+ return ((id.length()>=4) ? id.substring(0, 4).hashCode() : id.hashCode());\r
}\r
\r
public boolean equals(Object s)\r
}\r
\r
public boolean equals(Object s)\r
- * matches if one ID properly contains another at a whitespace boundary.\r
- * TODO: (JBPNote) These are not efficient. should use char[] for speed\r
- * @param s SeqIdName\r
- * @return boolean\r
+ * Characters that define the end of a unique sequence ID at\r
+ * the beginning of an arbitrary ID string\r
+ private String WORD_SEP="~. |#\\/<>!\"£$%^*)}[@',?";\r
+\r
+ /**\r
+ * matches if one ID properly contains another at a whitespace boundary.\r
+ * TODO: (JBPNote) These are not efficient. should use char[] for speed\r
+ * todo: (JBPNote) Set separator characters appropriately\r
+ * @param s SeqIdName\r
+ * @return boolean\r
+ */\r
public boolean equals(SeqIdName s)\r
{\r
if (id.length()>s.id.length()) {\r
return id.startsWith(s.id) ?\r
public boolean equals(SeqIdName s)\r
{\r
if (id.length()>s.id.length()) {\r
return id.startsWith(s.id) ?\r
- (id.equals(s.id) ? true : id.startsWith(s.id+" "))\r
+ (WORD_SEP.indexOf(id.charAt(s.id.length()))>-1)\r
: false;\r
} else\r
return s.id.startsWith(id) ?\r
: false;\r
} else\r
return s.id.startsWith(id) ?\r
- (s.id.equals(id) ? true : s.id.startsWith(id+" "))\r
+ (s.id.equals(id) ? true :\r
+ (WORD_SEP.indexOf(s.id.charAt(id.length()))>-1))\r
{\r
if (id.length()>s.length()) {\r
return id.startsWith(s) ?\r
{\r
if (id.length()>s.length()) {\r
return id.startsWith(s) ?\r
- (id.equals(s) ? true : id.startsWith(s+" "))\r
+ (WORD_SEP.indexOf(id.charAt(s.length()))>-1)\r
: false;\r
} else\r
return s.startsWith(id) ?\r
: false;\r
} else\r
return s.startsWith(id) ?\r
- (s.equals(id) ? true : s.startsWith(id+" "))\r
+ (s.equals(id) ? true :\r
+ (WORD_SEP.indexOf(s.charAt(id.length()))>-1))\r