import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.api.FeatureRenderer;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceDummy;
parseResult);
checkDatasetfromSimpleGff3(dataset);
}
+
+ @Test(groups = { "Functional" })
+ public void testPrintJalviewFormat() throws Exception
+ {
+ File f = new File("examples/uniref50.fa");
+ AlignmentI al = readAlignmentFile(f);
+ AlignFrame af = new AlignFrame(al, 500, 500);
+ Map<String, Object> colours = af.getFeatureRenderer()
+ .getFeatureColours();
+ String features = "METAL\tcc9900\n"
+ + "GAMMA-TURN\tred|0,255,255|20.0|95.0|below|66.0\n"
+ + "Pfam\tred\n"
+ + "STARTGROUP\tuniprot\n"
+ + "Iron\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
+ + "Turn\tFER_CAPAA\t-1\t36\t38\tGAMMA-TURN\n"
+ + "<html>Pfam domain<a href=\"http://pfam.sanger.ac.uk/family/PF00111\">Pfam_3_4</a></html>\tFER_CAPAA\t-1\t20\t20\tPfam\n"
+ + "ENDGROUP\tuniprot\n";
+ FeaturesFile featuresFile = new FeaturesFile(features,
+ FormatAdapter.PASTE);
+ featuresFile.parse(al.getDataset(), colours, false);
+
+ /*
+ * first with no features displayed
+ */
+ FeatureRenderer fr = af.alignPanel.getFeatureRenderer();
+ Map<String, Object> visible = fr
+ .getDisplayedFeatureCols();
+ String exported = featuresFile.printJalviewFormat(
+ al.getSequencesArray(), visible);
+ String expected = "No Features Visible";
+ assertEquals(expected, exported);
+
+ /*
+ * set METAL (in uniprot group) and GAMMA-TURN visible, but not Pfam
+ */
+ fr.setVisible("METAL");
+ fr.setVisible("GAMMA-TURN");
+ visible = fr.getDisplayedFeatureCols();
+ exported = featuresFile.printJalviewFormat(al.getSequencesArray(),
+ visible);
+ expected = "METAL\tcc9900\n"
+ + "GAMMA-TURN\tff0000|00ffff|20.0|95.0|below|66.0\n"
+ + "\nSTARTGROUP\tuniprot\n"
+ + "Iron\tFER_CAPAA\t-1\t39\t39\tMETAL\t0.0\n"
+ + "Turn\tFER_CAPAA\t-1\t36\t38\tGAMMA-TURN\t0.0\n"
+ + "ENDGROUP\tuniprot\n";
+ assertEquals(expected, exported);
+
+ /*
+ * now set Pfam visible
+ */
+ fr.setVisible("Pfam");
+ visible = fr.getDisplayedFeatureCols();
+ exported = featuresFile.printJalviewFormat(al.getSequencesArray(),
+ visible);
+ /*
+ * note the order of feature types is uncontrolled - derives from
+ * FeaturesDisplayed.featuresDisplayed which is a HashSet
+ */
+ expected = "METAL\tcc9900\n"
+ + "Pfam\tff0000\n"
+ + "GAMMA-TURN\tff0000|00ffff|20.0|95.0|below|66.0\n"
+ + "\nSTARTGROUP\tuniprot\n"
+ + "Iron\tFER_CAPAA\t-1\t39\t39\tMETAL\t0.0\n"
+ + "Turn\tFER_CAPAA\t-1\t36\t38\tGAMMA-TURN\t0.0\n"
+ + "<html>Pfam domain<a href=\"http://pfam.sanger.ac.uk/family/PF00111\">Pfam_3_4</a></html>\tFER_CAPAA\t-1\t20\t20\tPfam\t0.0\n"
+ + "ENDGROUP\tuniprot\n";
+ assertEquals(expected, exported);
+ }
}