+
+ /**
+ * Test with a regex that looks for numbers separated by words - as currently
+ * used in Jalview (May 2015)
+ *
+ * @see AlignFrame.extractScores_actionPerformed
+ */
+ @Test(groups = { "Functional" })
+ public void testGetScoresFromDescription_wordBoundaries()
+ {
+ String regex = "\\W*([-+eE0-9.]+)";
+ List<SequenceI> seqs = al.getSequences();
+ seqs.get(0).setDescription("Ferredoxin");
+ seqs.get(1).setDescription(" Ferredoxin-1, chloroplast precursor");
+ seqs.get(2).setDescription("GH28E30p");
+ seqs.get(3).setDescription("At1g10960/T19D16_12");
+ final int count = pp.getScoresFromDescription("description column",
+ "score in description column ", regex, true);
+ assertEquals(3, count);
+
+ /*
+ * No score parsable from seq1 description
+ */
+ AlignmentAnnotation[] anns = al.getSequenceAt(0).getAnnotation();
+ assertNull(anns);
+
+ /*
+ * Seq2 description has a '1' in it
+ */
+ anns = al.getSequenceAt(1).getAnnotation();
+ assertEquals(1, anns.length);
+ assertEquals(1d, anns[0].getScore(), 0.001d);
+
+ /*
+ * Seq3 description has '28E30' in it
+ *
+ * Note: 1.8E308 or larger would result in 'Infinity'
+ */
+ anns = al.getSequenceAt(2).getAnnotation();
+ assertEquals(1, anns.length);
+ assertEquals(2.8E31d, anns[0].getScore(), 0.001d);
+
+ /*
+ * Seq4 description has several numbers in it
+ */
+ anns = al.getSequenceAt(3).getAnnotation();
+ assertEquals(5, anns.length);
+ assertEquals(1d, anns[0].getScore(), 0.001d);
+ assertEquals(10960d, anns[1].getScore(), 0.001d);
+ assertEquals(19d, anns[2].getScore(), 0.001d);
+ assertEquals(16d, anns[3].getScore(), 0.001d);
+ assertEquals(12d, anns[4].getScore(), 0.001d);
+ }