import static org.testng.AssertJUnit.assertNull;
import static org.testng.AssertJUnit.assertTrue;
+import jalview.api.FeatureColourI;
import jalview.api.FeatureRenderer;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceFeature;
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
-import jalview.schemes.AnnotationColourGradient;
-import jalview.schemes.GraduatedColor;
+import jalview.gui.JvOptionPane;
import java.awt.Color;
import java.io.File;
import java.io.IOException;
import java.util.Map;
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
public class FeaturesFileTest
{
+ @BeforeClass(alwaysRun = true)
+ public void setUpJvOptionPane()
+ {
+ JvOptionPane.setInteractiveMode(false);
+ JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+ }
+
private static String simpleGffFile = "examples/testdata/simpleGff3.gff";
@Test(groups = { "Functional" })
File f = new File("examples/uniref50.fa");
AlignmentI al = readAlignmentFile(f);
AlignFrame af = new AlignFrame(al, 500, 500);
- Map<String, Object> colours = af.getFeatureRenderer()
+ Map<String, FeatureColourI> colours = af.getFeatureRenderer()
.getFeatureColours();
FeaturesFile featuresFile = new FeaturesFile(
- "examples/exampleFeatures.txt", FormatAdapter.FILE);
+ "examples/exampleFeatures.txt", DataSourceType.FILE);
assertTrue("Test " + "Features file test"
+ "\nFailed to parse features file.",
featuresFile.parse(al.getDataset(), colours, true));
*/
colours = af.getFeatureRenderer().getFeatureColours();
assertEquals("26 feature group colours not found", 26, colours.size());
- assertEquals(colours.get("Cath"), new Color(0x93b1d1));
- assertEquals(colours.get("ASX-MOTIF"), new Color(0x6addbb));
+ assertEquals(colours.get("Cath").getColour(), new Color(0x93b1d1));
+ assertEquals(colours.get("ASX-MOTIF").getColour(), new Color(0x6addbb));
/*
* verify (some) features on sequences
File f = new File("examples/uniref50.fa");
AlignmentI al = readAlignmentFile(f);
AlignFrame af = new AlignFrame(al, 500, 500);
- Map<String, Object> colours = af.getFeatureRenderer()
+ Map<String, FeatureColourI> colours = af.getFeatureRenderer()
.getFeatureColours();
// GFF2 uses space as name/value separator in column 9
- String gffData = "METAL\tcc9900\n" + "GFF\n"
+ String gffData = "METAL\tcc9900\n"
+ + "GFF\n"
+ "FER_CAPAA\tuniprot\tMETAL\t44\t45\t4.0\t.\t.\tNote Iron-sulfur; Note 2Fe-2S\n"
+ "FER1_SOLLC\tuniprot\tPfam\t55\t130\t2.0\t.\t.";
FeaturesFile featuresFile = new FeaturesFile(gffData,
- FormatAdapter.PASTE);
+ DataSourceType.PASTE);
assertTrue("Failed to parse features file",
featuresFile.parse(al.getDataset(), colours, true));
// verify colours read or synthesized
colours = af.getFeatureRenderer().getFeatureColours();
assertEquals("1 feature group colours not found", 1, colours.size());
- assertEquals(colours.get("METAL"), new Color(0xcc9900));
+ assertEquals(colours.get("METAL").getColour(), new Color(0xcc9900));
// verify feature on FER_CAPAA
SequenceFeature[] sfs = al.getSequenceAt(0).getDatasetSequence()
String ff = f.getPath();
FormatAdapter rf = new FormatAdapter();
- AlignmentI al = rf.readFile(ff, FormatAdapter.FILE,
- new IdentifyFile().identify(ff, FormatAdapter.FILE));
+ AlignmentI al = rf.readFile(ff, DataSourceType.FILE,
+ new IdentifyFile().identify(ff, DataSourceType.FILE));
al.setDataset(null); // creates dataset sequences
assertNotNull("Couldn't read supplied alignment data.", al);
}
/**
- * Test various ways of describing a feature colour scheme
- *
- * @throws Exception
- */
- @Test(groups = { "Functional" })
- public void testParseGraduatedColourScheme() throws Exception
- {
- FeaturesFile ff = new FeaturesFile();
-
- // colour by label:
- GraduatedColor gc = ff.parseGraduatedColourScheme(
- "BETA-TURN-IR\t9a6a94", "label");
- assertTrue(gc.isColourByLabel());
- assertEquals(Color.white, gc.getMinColor());
- assertEquals(Color.black, gc.getMaxColor());
- assertTrue(gc.isAutoScale());
-
- // using colour name, rgb, etc:
- String spec = "blue|255,0,255|absolute|20.0|95.0|below|66.0";
- gc = ff.parseGraduatedColourScheme("BETA-TURN-IR\t" + spec, spec);
- assertFalse(gc.isColourByLabel());
- assertEquals(Color.blue, gc.getMinColor());
- assertEquals(new Color(255, 0, 255), gc.getMaxColor());
- assertFalse(gc.isAutoScale());
- assertFalse(gc.getTolow());
- assertEquals(20.0f, gc.getMin(), 0.001f);
- assertEquals(95.0f, gc.getMax(), 0.001f);
- assertEquals(AnnotationColourGradient.BELOW_THRESHOLD,
- gc.getThreshType());
- assertEquals(66.0f, gc.getThresh(), 0.001f);
-
- // inverse gradient high to low:
- spec = "blue|255,0,255|95.0|20.0|below|66.0";
- gc = ff.parseGraduatedColourScheme("BETA-TURN-IR\t" + spec, spec);
- assertTrue(gc.isAutoScale());
- assertTrue(gc.getTolow());
- }
-
- /**
* Test parsing a features file with GFF formatted content only
*
* @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()
+ Map<String, FeatureColourI> colours = af.getFeatureRenderer()
.getFeatureColours();
// GFF3 uses '=' separator for name/value pairs in colum 9
String gffData = "##gff-version 3\n"
+ "Note=Iron-sulfur (2Fe-2S);Note=another note;evidence=ECO:0000255|PROSITE-ProRule:PRU00465\n"
+ "FER1_SOLLC\tuniprot\tPfam\t55\t130\t3.0\t.\t.\tID=$23";
FeaturesFile featuresFile = new FeaturesFile(gffData,
- FormatAdapter.PASTE);
+ DataSourceType.PASTE);
assertTrue("Failed to parse features file",
featuresFile.parse(al.getDataset(), colours, true));
File f = new File("examples/uniref50.fa");
AlignmentI al = readAlignmentFile(f);
AlignFrame af = new AlignFrame(al, 500, 500);
- Map<String, Object> colours = af.getFeatureRenderer()
+ Map<String, FeatureColourI> colours = af.getFeatureRenderer()
.getFeatureColours();
/*
String featureData = "Iron-sulfur (2Fe-2S)\tFER_CAPAA\t-1\t39\t39\tMETAL\n"
+ "Iron-phosphorus (2Fe-P)\tID_NOT_SPECIFIED\t2\t86\t87\tMETALLIC\n";
FeaturesFile featuresFile = new FeaturesFile(featureData,
- FormatAdapter.PASTE);
+ DataSourceType.PASTE);
assertTrue("Failed to parse features file",
featuresFile.parse(al.getDataset(), colours, true));
{
assertEquals("no sequences extracted from GFF3 file", 2,
dataset.getHeight());
-
+
SequenceI seq1 = dataset.findName("seq1");
SequenceI seq2 = dataset.findName("seq2");
assertNotNull(seq1);
"Expected at least one CDNA/Protein mapping for seq1",
dataset.getCodonFrame(seq1) != null
&& dataset.getCodonFrame(seq1).size() > 0);
-
+
}
@Test(groups = { "Functional" })
public void readGff3File() throws IOException
{
FeaturesFile gffreader = new FeaturesFile(true, simpleGffFile,
- FormatAdapter.FILE);
+ DataSourceType.FILE);
Alignment dataset = new Alignment(gffreader.getSeqsAsArray());
gffreader.addProperties(dataset);
checkDatasetfromSimpleGff3(dataset);
{
AlignmentI dataset = new Alignment(new SequenceI[] {});
FeaturesFile ffile = new FeaturesFile(simpleGffFile,
- FormatAdapter.FILE);
+ DataSourceType.FILE);
boolean parseResult = ffile.parse(dataset, null, false, false);
assertTrue("return result should be true", parseResult);
public void simpleGff3FileLoader() throws IOException
{
AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
- simpleGffFile, FormatAdapter.FILE);
+ simpleGffFile, DataSourceType.FILE);
assertTrue(
"Didn't read the alignment into an alignframe from Gff3 File",
af != null);
{
AlignmentI dataset = new Alignment(new SequenceI[] {});
FeaturesFile ffile = new FeaturesFile(simpleGffFile,
- FormatAdapter.FILE);
+ DataSourceType.FILE);
boolean parseResult = ffile.parse(dataset, null, false, true);
assertTrue("return result (relaxedID matching) should be true",
File f = new File("examples/uniref50.fa");
AlignmentI al = readAlignmentFile(f);
AlignFrame af = new AlignFrame(al, 500, 500);
- Map<String, Object> colours = af.getFeatureRenderer()
+ Map<String, FeatureColourI> colours = af.getFeatureRenderer()
.getFeatureColours();
String features = "METAL\tcc9900\n"
+ "GAMMA-TURN\tred|0,255,255|20.0|95.0|below|66.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\n"
+ "ENDGROUP\tuniprot\n";
FeaturesFile featuresFile = new FeaturesFile(features,
- FormatAdapter.PASTE);
+ DataSourceType.PASTE);
featuresFile.parse(al.getDataset(), colours, false);
/*
* first with no features displayed
*/
FeatureRenderer fr = af.alignPanel.getFeatureRenderer();
- Map<String, Object> visible = fr
- .getDisplayedFeatureCols();
+ Map<String, FeatureColourI> visible = fr.getDisplayedFeatureCols();
String exported = featuresFile.printJalviewFormat(
al.getSequencesArray(), visible);
String expected = "No Features Visible";