X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2FFeaturesFileTest.java;h=81d5b05c4476de50fe65551ef0687be6424dab99;hb=ecb334f98fca8ed9f27b6a7d027dea3bd4213023;hp=385e049bbc7122d931c70a490fd3a21de5effc37;hpb=8d9a7bf31e5700abfb0b054093f0bcd58f0d24cb;p=jalview.git diff --git a/test/jalview/io/FeaturesFileTest.java b/test/jalview/io/FeaturesFileTest.java index 385e049..81d5b05 100644 --- a/test/jalview/io/FeaturesFileTest.java +++ b/test/jalview/io/FeaturesFileTest.java @@ -26,6 +26,7 @@ import static org.testng.AssertJUnit.assertNotNull; 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; @@ -412,4 +413,73 @@ public class FeaturesFileTest 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 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" + + "Pfam domainPfam_3_4\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 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" + + "Pfam domainPfam_3_4\tFER_CAPAA\t-1\t20\t20\tPfam\t0.0\n" + + "ENDGROUP\tuniprot\n"; + assertEquals(expected, exported); + } }