public static final char GAP_DASH = '-';
+ public static final char GAP_TILDE = '~';
+
+ public static final char GAP_PIPE = '|';
+
+ public static final char GAP_COLON = ':';
+
+ public static final char GAP_LPAREN = '(';
+
+ public static final char GAP_RPAREN = ')';
+
+ public static final char GAP_LSQBR = '[';
+
+ public static final char GAP_RSQBR = ']';
+
+ public static final char GAP_LBRACE = '{';
+
+ public static final char GAP_RBRACE = '}';
+
public static final String GapChars = new String(
new char[]
- { GAP_SPACE, GAP_DOT, GAP_DASH });
+ { GAP_SPACE, GAP_DOT, GAP_DASH, GAP_TILDE, GAP_PIPE, GAP_COLON,
+ GAP_LPAREN,
+ GAP_RPAREN, GAP_LSQBR, GAP_RSQBR, GAP_LBRACE, GAP_RBRACE });
/**
* DOCUMENT ME!
*/
public static final boolean isGap(char c)
{
- return (c == GAP_DASH || c == GAP_DOT || c == GAP_SPACE) ? true : false;
+ switch (c)
+ {
+ case GAP_SPACE:
+ case GAP_DOT:
+ case GAP_DASH:
+ case GAP_TILDE:
+ case GAP_PIPE:
+ case GAP_COLON:
+ case GAP_LPAREN:
+ case GAP_RPAREN:
+ case GAP_LSQBR:
+ case GAP_RSQBR:
+ case GAP_LBRACE:
+ case GAP_RBRACE:
+ return true;
+ default:
+ return false;
+ }
}
/**
{
return false;
}
- List<SequenceI> flattened = new ArrayList<SequenceI>();
+ List<SequenceI> flattened = new ArrayList<>();
for (SequenceI[] ss : seqs)
{
for (SequenceI s : ss)
import jalview.datamodel.SequenceI;
import jalview.gui.JvOptionPane;
+import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
assertFalse(Comparison.isGap('x'));
assertFalse(Comparison.isGap('*'));
assertFalse(Comparison.isGap('G'));
+
+ // consistency - test Comparison.isGap covers all gapChars
+ StringBuilder missing = new StringBuilder();
+ for (int i = 0, iSize = Comparison.GapChars.length(); i < iSize; i++)
+ {
+ char gc = Comparison.GapChars.charAt(i);
+ if (!Comparison.isGap(gc))
+ {
+ missing.append(gc);
+ }
+ }
+ if (missing.length() > 0)
+ {
+ Assert.fail(
+ "Comparison.GapChars contains symbols not covered by Comparison.isGap: '"
+ + missing.toString() + "'");
+ }
}
/**