.toArray(new String[visible.keySet().size()]);
/*
- * sort groups alphabetically, and ensure that null group is output last
+ * sort groups alphabetically, and ensure that features with a
+ * null or empty group are output after those in named groups
*/
List<String> sortedGroups = new ArrayList<String>(visibleFeatureGroups);
sortedGroups.remove(null);
+ sortedGroups.remove("");
Collections.sort(sortedGroups);
sortedGroups.add(null);
+ sortedGroups.add("");
boolean foundSome = false;
for (String group : sortedGroups)
{
- if (group != null)
+ boolean isNamedGroup = (group != null && !"".equals(group));
+ if (isNamedGroup)
{
out.append(newline);
out.append("STARTGROUP").append(TAB);
}
}
- if (group != null)
+ if (isNamedGroup)
{
out.append("ENDGROUP").append(TAB);
out.append(group);
featuresFile.parse(al.getDataset(), colours, false);
/*
+ * add positional and non-positional features with null and
+ * empty feature group to check handled correctly
+ */
+ SequenceI seq = al.getSequenceAt(1); // FER_CAPAN
+ seq.addSequenceFeature(new SequenceFeature("Pfam", "desc1", 0, 0, 1.3f,
+ null));
+ seq.addSequenceFeature(new SequenceFeature("Pfam", "desc2", 4, 9,
+ Float.NaN, null));
+ seq = al.getSequenceAt(2); // FER1_SOLLC
+ seq.addSequenceFeature(new SequenceFeature("Pfam", "desc3", 0, 0,
+ Float.NaN, ""));
+ seq.addSequenceFeature(new SequenceFeature("Pfam", "desc4", 5, 8,
+ -2.6f, ""));
+
+ /*
* first with no features displayed, exclude non-positional features
*/
FeatureRenderer fr = af.alignPanel.getFeatureRenderer();
visibleGroups.add("uniprot");
exported = featuresFile.printJalviewFormat(al.getSequencesArray(),
visible, visibleGroups, true);
- expected = "Cath\tFER_CAPAA\t-1\t0\t0\tDomain\t0.0\n\nSTARTGROUP\tuniprot\nENDGROUP\tuniprot\n";
+ expected = "Cath\tFER_CAPAA\t-1\t0\t0\tDomain\t0.0\n"
+ + "desc1\tFER_CAPAN\t-1\t0\t0\tPfam\t1.3\n"
+ + "desc3\tFER1_SOLLC\t-1\t0\t0\tPfam\n" // NaN is not output
+ + "\nSTARTGROUP\tuniprot\nENDGROUP\tuniprot\n";
assertEquals(expected, exported);
/*
+ "Turn\tFER_CAPAA\t-1\t36\t38\tGAMMA-TURN\t0.0\n"
+ "Iron\tFER_CAPAA\t-1\t39\t39\tMETAL\t0.0\n"
+ "<html>Pfam domain<a href=\"http://pfam.xfam.org/family/PF00111\">Pfam_3_4</a></html>\tFER_CAPAA\t-1\t20\t20\tPfam\t0.0\n"
- + "ENDGROUP\tuniprot\n";
+ + "ENDGROUP\tuniprot\n"
+ // null / empty group features output after features in named
+ // groups:
+ + "desc2\tFER_CAPAN\t-1\t4\t9\tPfam\n"
+ + "desc4\tFER1_SOLLC\t-1\t5\t8\tPfam\t-2.6\n";
assertEquals(expected, exported);
}