import jalview.api.ViewStyleI;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.HiddenMarkovModel;
import jalview.datamodel.HiddenSequences;
+import jalview.datamodel.Mapping;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.PDBEntry.Type;
import jalview.datamodel.SequenceCollectionI;
import jalview.datamodel.features.FeatureMatcherSet;
import jalview.datamodel.features.FeatureMatcherSetI;
import jalview.gui.AlignFrame;
-import jalview.gui.AlignViewport;
import jalview.gui.AlignmentPanel;
import jalview.gui.Desktop;
import jalview.gui.FeatureRenderer;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
+import junit.extensions.PA;
+
@Test(singleThreaded = true)
public class Jalview2xmlTests extends Jalview2xmlBase
{
DataSourceType.FILE);
assertNotNull(af, "Didn't read input file " + inFile);
af.loadJalviewDataFile(inAnnot, DataSourceType.FILE, null, null);
- assertSame(af.getViewport().getGlobalColourScheme().getClass(),
+ AlignViewportI viewport = af.getViewport();
+ assertSame(viewport.getGlobalColourScheme().getClass(),
TCoffeeColourScheme.class, "Didn't set T-coffee colourscheme");
assertNotNull(
- ColourSchemeProperty.getColourScheme(
- af.getViewport().getAlignment(),
- af.getViewport().getGlobalColourScheme()
+ ColourSchemeProperty.getColourScheme(viewport,
+ viewport.getAlignment(),
+ viewport.getGlobalColourScheme()
.getSchemeName()),
"Recognise T-Coffee score from string");
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
"examples/uniref50.fa", DataSourceType.FILE);
- AlignViewport av = af.getViewport();
+ AlignViewportI av = af.getViewport();
AlignmentI al = av.getAlignment();
/*
* Colour alignment by Buried Index, Above 10% PID, By Conservation 20%
*/
+ av.setColourAppliesToAllGroups(false);
af.changeColour_actionPerformed(JalviewColourScheme.Buried.toString());
assertTrue(av.getGlobalColourScheme() instanceof BuriedColourScheme);
af.abovePIDThreshold_actionPerformed(true);
* @throws IOException
*/
@Test(groups = { "Functional" })
- public void testSaveLoadFeatureColoursAndFilters() throws IOException
+ public void testStoreAndRecoverFeatureColoursAndFilters()
+ throws IOException
{
AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
">Seq1\nACDEFGHIKLM", DataSourceType.PASTE);
fr.setColour("type2", byLabel);
// type3: by score above threshold
- FeatureColourI byScore = new FeatureColour(Color.BLACK, Color.BLUE, 1,
- 10);
+ FeatureColourI byScore = new FeatureColour(null, Color.BLACK,
+ Color.BLUE, null, 1, 10);
byScore.setAboveThreshold(true);
byScore.setThreshold(2f);
fr.setColour("type3", byScore);
fr.setColour("type4", byAF);
// type5: by attribute CSQ:PolyPhen below threshold
- FeatureColourI byPolyPhen = new FeatureColour(Color.BLACK, Color.BLUE,
- 1, 10);
+ FeatureColourI byPolyPhen = new FeatureColour(null, Color.BLACK,
+ Color.BLUE, null, 1, 10);
byPolyPhen.setBelowThreshold(true);
byPolyPhen.setThreshold(3f);
byPolyPhen.setAttributeName("CSQ", "PolyPhen");
}
/**
+ * Load an HMM profile to an alignment, and confirm it is correctly restored
+ * when reloaded from project
+ *
+ * @throws IOException
+ */
+ @Test(groups = { "Functional" })
+ public void testStoreAndRecoverHmmProfile() throws IOException
+ {
+ Desktop.instance.closeAll_actionPerformed(null);
+ AlignFrame af = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/uniref50.fa", DataSourceType.FILE);
+
+ AlignViewportI av = af.getViewport();
+ AlignmentI al = av.getAlignment();
+
+ /*
+ * mimic drag and drop of hmm file on to alignment
+ */
+ AlignFrame af2 = new FileLoader().LoadFileWaitTillLoaded(
+ "examples/uniref50.hmm", DataSourceType.FILE);
+ al.insertSequenceAt(0,
+ af2.getViewport().getAlignment().getSequenceAt(0));
+
+ /*
+ * check it loaded in
+ */
+ SequenceI hmmSeq = al.getSequenceAt(0);
+ assertTrue(hmmSeq.hasHMMProfile());
+ HiddenMarkovModel hmm = hmmSeq.getHMM();
+ assertSame(hmm.getConsensusSequence(), hmmSeq);
+
+ /*
+ * save project, close windows, reload project, verify
+ */
+ File tfile = File.createTempFile("testStoreAndRecoverHmmProfile",
+ ".jvp");
+ tfile.deleteOnExit();
+ new Jalview2XML(false).saveState(tfile);
+ Desktop.instance.closeAll_actionPerformed(null);
+ af = new FileLoader().LoadFileWaitTillLoaded(tfile.getAbsolutePath(),
+ DataSourceType.FILE);
+ Assert.assertNotNull(af, "Failed to reload project");
+
+ hmmSeq = al.getSequenceAt(0);
+ assertTrue(hmmSeq.hasHMMProfile());
+ assertSame(hmm.getConsensusSequence(), hmmSeq);
+ Mapping mapToHmmConsensus = (Mapping) PA.getValue(hmm,
+ "mapToHmmConsensus");
+ assertNotNull(mapToHmmConsensus);
+ assertSame(mapToHmmConsensus.getTo(), hmmSeq.getDatasetSequence());
+ }
+
+ /**
* pre 2.11 - jalview 2.10 erroneously created new dataset entries for each
* view (JAL-3171) this test ensures we can import and merge those views
*/