}
/*
+ * permit an uncommented line with delimited residue headings
+ */
+ if (isHeaderLine(data, alphabet))
+ {
+ continue;
+ }
+
+ /*
* subsequent lines should be the symbol scores
* optionally with the symbol as the first column for readability
*/
return sm;
}
+ /**
+ * Answers true if the data line consists of the alphabet characters,
+ * delimited (as to provide a heading row). Otherwise returns false (e.g. if
+ * the data is a row of score values).
+ *
+ * @param data
+ * @param alphabet
+ * @return
+ */
+ private boolean isHeaderLine(String data, String alphabet)
+ {
+ StringTokenizer scoreLine = new StringTokenizer(data, DELIMITERS);
+ int i = 0;
+ while (scoreLine.hasMoreElements())
+ {
+ /*
+ * skip over characters in the alphabet that are
+ * also a delimiter (e.g. space)
+ */
+ char symbol = alphabet.charAt(i++);
+ if (!DELIMITERS.contains(String.valueOf(symbol)))
+ {
+ if (!String.valueOf(symbol).equals(scoreLine.nextToken()))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
public String getMatrixName()
{
return matrixName;