Search in sources :

Example 1 with ScreenshotTaker

use of org.fest.swing.image.ScreenshotTaker in project beast2 by CompEvol.

the class BeautiRateTutorialTest method MEPTutorial.

@Test
public void MEPTutorial() throws Exception {
    long t0 = System.currentTimeMillis();
    ScreenshotTaker screenshotTaker = new ScreenshotTaker();
    beauti.frame.setSize(1024, 640);
    File dir = new File(PREFIX.substring(0, PREFIX.lastIndexOf('/')));
    if (!dir.exists()) {
        dir.mkdir();
    }
    for (File file : dir.listFiles()) {
        file.delete();
    }
    // 0. Load primate-mtDNA.nex
    warning("// 0. Load RSV2.nex");
    importAlignment("examples/nexus", new File("RSV2.nex"));
    beautiFrame.menuItemWithPath("Mode", "Automatic set fix mean substitution rate flag").click();
    // load anolis.nex
    JTabbedPaneFixture f = beautiFrame.tabbedPane();
    f.requireVisible();
    f.requireTitle("Partitions", Index.atIndex(0));
    String[] titles = f.tabTitles();
    assertArrayEquals(titles, "[Partitions, Tip Dates, Site Model, Clock Model, Priors, MCMC]");
    System.err.println(Arrays.toString(titles));
    f = f.selectTab("Partitions");
    JTableFixture t = beautiFrame.table();
    t.selectCell(TableCell.row(0).column(2));
    // 0. Split partition...
    warning("0. Split partition...");
    beautiFrame.button("Split").click();
    JOptionPaneFixture dialog = new JOptionPaneFixture(robot());
    dialog.comboBox().selectItem("1 + 2 + 3 frame 3");
    dialog.okButton().click();
    // check table
    t = beautiFrame.table();
    printTableContents(t);
    checkTableContents(t, "[RSV2_1, RSV2, 129, 209, nucleotide, RSV2_1, RSV2_1, RSV2_1, false]*" + "[RSV2_2, RSV2, 129, 210, nucleotide, RSV2_2, RSV2_2, RSV2_1, false]*" + "[RSV2_3, RSV2, 129, 210, nucleotide, RSV2_3, RSV2_3, RSV2_1, false]");
    printBeautiState(f);
    // assertStateEquals("Tree.t:RSV2_2", "clockRate.c:RSV2_2", "birthRate.t:RSV2_2", "Tree.t:RSV2_3", "clockRate.c:RSV2_3", "birthRate.t:RSV2_3", "Tree.t:RSV2_1", "birthRate.t:RSV2_1");
    // assertOperatorsEqual("StrictClockRateScaler.c:RSV2_2", "YuleBirthRateScaler.t:RSV2_2", "YuleModelTreeScaler.t:RSV2_2", "YuleModelTreeRootScaler.t:RSV2_2", "YuleModelUniformOperator.t:RSV2_2", "YuleModelSubtreeSlide.t:RSV2_2", "YuleModelNarrow.t:RSV2_2", "YuleModelWide.t:RSV2_2", "YuleModelWilsonBalding.t:RSV2_2", "strictClockUpDownOperator.c:RSV2_2", "StrictClockRateScaler.c:RSV2_3", "YuleBirthRateScaler.t:RSV2_3", "YuleModelTreeScaler.t:RSV2_3", "YuleModelTreeRootScaler.t:RSV2_3", "YuleModelUniformOperator.t:RSV2_3", "YuleModelSubtreeSlide.t:RSV2_3", "YuleModelNarrow.t:RSV2_3", "YuleModelWide.t:RSV2_3", "YuleModelWilsonBalding.t:RSV2_3", "strictClockUpDownOperator.c:RSV2_3", "YuleBirthRateScaler.t:RSV2_1", "YuleModelTreeScaler.t:RSV2_1", "YuleModelTreeRootScaler.t:RSV2_1", "YuleModelUniformOperator.t:RSV2_1", "YuleModelSubtreeSlide.t:RSV2_1", "YuleModelNarrow.t:RSV2_1", "YuleModelWide.t:RSV2_1", "YuleModelWilsonBalding.t:RSV2_1");
    // assertPriorsEqual("YuleModel.t:RSV2_1", "YuleModel.t:RSV2_2", "YuleModel.t:RSV2_3", "ClockPrior.c:RSV2_2", "YuleBirthRatePrior.t:RSV2_2", "ClockPrior.c:RSV2_3", "YuleBirthRatePrior.t:RSV2_3", "YuleBirthRatePrior.t:RSV2_1");
    // assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.RSV2_2", "TreeHeight.t:RSV2_2", "clockRate.c:RSV2_2", "YuleModel.t:RSV2_2", "birthRate.t:RSV2_2", "treeLikelihood.RSV2_3", "TreeHeight.t:RSV2_3", "clockRate.c:RSV2_3", "YuleModel.t:RSV2_3", "birthRate.t:RSV2_3", "treeLikelihood.RSV2_1", "TreeHeight.t:RSV2_1", "YuleModel.t:RSV2_1", "birthRate.t:RSV2_1");
    assertStateEquals("Tree.t:RSV2_1", "clockRate.c:RSV2_2", "birthRate.t:RSV2_1", "clockRate.c:RSV2_3");
    assertOperatorsEqual("StrictClockRateScaler.c:RSV2_2", "YuleBirthRateScaler.t:RSV2_1", "strictClockUpDownOperator.c:RSV2_2", "YuleModelTreeScaler.t:RSV2_1", "YuleModelTreeRootScaler.t:RSV2_1", "YuleModelUniformOperator.t:RSV2_1", "YuleModelSubtreeSlide.t:RSV2_1", "YuleModelNarrow.t:RSV2_1", "YuleModelWide.t:RSV2_1", "YuleModelWilsonBalding.t:RSV2_1", "StrictClockRateScaler.c:RSV2_3", "strictClockUpDownOperator.c:RSV2_3");
    assertPriorsEqual("YuleModel.t:RSV2_1", "ClockPrior.c:RSV2_2", "YuleBirthRatePrior.t:RSV2_1", "ClockPrior.c:RSV2_3");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.RSV2_2", "treeLikelihood.RSV2_3", "TreeHeight.t:RSV2_1", "clockRate.c:RSV2_2", "YuleModel.t:RSV2_1", "birthRate.t:RSV2_1", "treeLikelihood.RSV2_1", "clockRate.c:RSV2_3");
    // 1a. Link trees...
    warning("1a. Link trees...");
    f.selectTab("Partitions");
    t = beautiFrame.table();
    t.selectCells(TableCell.row(0).column(2), TableCell.row(1).column(2), TableCell.row(2).column(2));
    JButtonFixture linkTreesButton = beautiFrame.button("Link Trees");
    linkTreesButton.click();
    printBeautiState(f);
    // 1b. ...and call the tree "tree"
    warning("1b. ...and call the tree \"tree\"");
    f.selectTab("Partitions");
    JTableCellFixture cell = beautiFrame.table().cell(TableCell.row(0).column(7));
    Component editor = cell.editor();
    JComboBoxFixture comboBox = new JComboBoxFixture(robot(), (JComboBox<?>) editor);
    cell.startEditing();
    comboBox.selectAllText();
    comboBox.enterText("tree");
    comboBox.pressAndReleaseKeys(KeyEvent.VK_ENTER);
    cell.stopEditing();
    printBeautiState(f);
    assertStateEquals("clockRate.c:RSV2_2", "clockRate.c:RSV2_3", "Tree.t:tree", "birthRate.t:tree");
    assertOperatorsEqual("StrictClockRateScaler.c:RSV2_2", "StrictClockRateScaler.c:RSV2_3", "YuleBirthRateScaler.t:tree", "YuleModelTreeScaler.t:tree", "YuleModelTreeRootScaler.t:tree", "YuleModelUniformOperator.t:tree", "YuleModelSubtreeSlide.t:tree", "YuleModelNarrow.t:tree", "YuleModelWide.t:tree", "YuleModelWilsonBalding.t:tree", "strictClockUpDownOperator.c:RSV2_3", "strictClockUpDownOperator.c:RSV2_2");
    assertPriorsEqual("YuleModel.t:tree", "ClockPrior.c:RSV2_2", "ClockPrior.c:RSV2_3", "YuleBirthRatePrior.t:tree");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.RSV2_2", "clockRate.c:RSV2_2", "treeLikelihood.RSV2_3", "clockRate.c:RSV2_3", "treeLikelihood.RSV2_1", "TreeHeight.t:tree", "YuleModel.t:tree", "birthRate.t:tree");
    // 2a. Link clocks
    warning("2a. Link clocks");
    f.selectTab("Partitions");
    t = beautiFrame.table();
    t.selectCells(TableCell.row(0).column(2), TableCell.row(1).column(2), TableCell.row(2).column(2));
    JButtonFixture linkClocksButton = beautiFrame.button("Link Clock Models");
    linkClocksButton.click();
    // 2b. and call the uncorrelated relaxed molecular clock "clock"
    warning("2b. and call the uncorrelated relaxed molecular clock \"clock\"");
    cell = beautiFrame.table().cell(TableCell.row(0).column(6));
    editor = cell.editor();
    comboBox = new JComboBoxFixture(robot(), (JComboBox<?>) editor);
    cell.startEditing();
    comboBox.selectAllText();
    comboBox.enterText("clock");
    comboBox.pressAndReleaseKeys(KeyEvent.VK_ENTER);
    cell.stopEditing();
    printBeautiState(f);
    assertStateEquals("Tree.t:tree", "birthRate.t:tree");
    assertOperatorsEqual("YuleBirthRateScaler.t:tree", "YuleModelTreeScaler.t:tree", "YuleModelTreeRootScaler.t:tree", "YuleModelUniformOperator.t:tree", "YuleModelSubtreeSlide.t:tree", "YuleModelNarrow.t:tree", "YuleModelWide.t:tree", "YuleModelWilsonBalding.t:tree");
    assertPriorsEqual("YuleModel.t:tree", "YuleBirthRatePrior.t:tree");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.RSV2_2", "treeLikelihood.RSV2_3", "treeLikelihood.RSV2_1", "TreeHeight.t:tree", "YuleModel.t:tree", "birthRate.t:tree");
    // 3a. Link site models
    warning("3a. link site models");
    f.selectTab("Partitions");
    t = beautiFrame.table();
    t.selectCells(TableCell.row(0).column(2), TableCell.row(1).column(2), TableCell.row(2).column(2));
    JButtonFixture linkSiteModelsButton = beautiFrame.button("Link Site Models");
    linkSiteModelsButton.click();
    // 3b. Set the site model to HKY (empirical)
    warning("3b. Set the site model to HKY (empirical)");
    f.selectTab("Site Model");
    beautiFrame.comboBox("substModel").selectItem("HKY");
    JComboBoxFixture freqs = beautiFrame.comboBox("frequencies");
    freqs.selectItem("Empirical");
    beautiFrame.checkBox("mutationRate.isEstimated").check();
    JCheckBoxFixture fixMeanMutationRate = beautiFrame.checkBox("FixMeanMutationRate");
    fixMeanMutationRate.check();
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "Site_Model.png");
    printBeautiState(f);
    // 3c. Unlink site models
    warning("3c. unlink site models");
    f.selectTab("Partitions");
    t = beautiFrame.table();
    t.selectCells(TableCell.row(0).column(2), TableCell.row(1).column(2), TableCell.row(2).column(2));
    JButtonFixture unlinkSiteModelsButton = beautiFrame.button("Unlink Site Models");
    unlinkSiteModelsButton.click();
    printBeautiState(f);
    assertStateEquals("Tree.t:tree", "birthRate.t:tree", "kappa.s:RSV2_1", "mutationRate.s:RSV2_1", "kappa.s:RSV2_2", "mutationRate.s:RSV2_2", "kappa.s:RSV2_3", "mutationRate.s:RSV2_3");
    assertOperatorsEqual("YuleBirthRateScaler.t:tree", "YuleModelTreeScaler.t:tree", "YuleModelTreeRootScaler.t:tree", "YuleModelUniformOperator.t:tree", "YuleModelSubtreeSlide.t:tree", "YuleModelNarrow.t:tree", "YuleModelWide.t:tree", "YuleModelWilsonBalding.t:tree", "KappaScaler.s:RSV2_1", "KappaScaler.s:RSV2_2", "KappaScaler.s:RSV2_3", "FixMeanMutationRatesOperator");
    assertPriorsEqual("YuleModel.t:tree", "YuleBirthRatePrior.t:tree", "KappaPrior.s:RSV2_1", "KappaPrior.s:RSV2_2", "KappaPrior.s:RSV2_3");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.RSV2_2", "treeLikelihood.RSV2_3", "treeLikelihood.RSV2_1", "TreeHeight.t:tree", "YuleModel.t:tree", "birthRate.t:tree", "kappa.s:RSV2_1", "mutationRate.s:RSV2_1", "kappa.s:RSV2_2", "mutationRate.s:RSV2_2", "kappa.s:RSV2_3", "mutationRate.s:RSV2_3");
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "partition.png");
    // 4. set up tip dates
    f = f.selectTab("Tip Dates");
    warning("4. Seting up tip dates");
    beautiFrame.checkBox().click();
    beautiFrame.button("Guess").click();
    JOptionPaneFixture dialog2 = new JOptionPaneFixture(robot());
    dialog2.textBox("SplitChar").deleteText().enterText("s");
    screenshotTaker.saveComponentAsPng(dialog2.component(), PREFIX + "GuessDates.png");
    dialog2.comboBox("delimiterCombo").selectItem("after last");
    dialog2.okButton().click();
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "dates.png");
    printBeautiState(f);
    assertStateEquals("Tree.t:tree", "birthRate.t:tree", "kappa.s:RSV2_1", "mutationRate.s:RSV2_1", "kappa.s:RSV2_2", "mutationRate.s:RSV2_2", "kappa.s:RSV2_3", "mutationRate.s:RSV2_3", "clockRate.c:clock");
    assertOperatorsEqual("YuleBirthRateScaler.t:tree", "YuleModelTreeScaler.t:tree", "YuleModelTreeRootScaler.t:tree", "YuleModelUniformOperator.t:tree", "YuleModelSubtreeSlide.t:tree", "YuleModelNarrow.t:tree", "YuleModelWide.t:tree", "YuleModelWilsonBalding.t:tree", "KappaScaler.s:RSV2_1", "KappaScaler.s:RSV2_2", "KappaScaler.s:RSV2_3", "FixMeanMutationRatesOperator", "StrictClockRateScaler.c:clock", "strictClockUpDownOperator.c:clock");
    assertPriorsEqual("YuleModel.t:tree", "YuleBirthRatePrior.t:tree", "KappaPrior.s:RSV2_1", "KappaPrior.s:RSV2_2", "KappaPrior.s:RSV2_3", "ClockPrior.c:clock");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.RSV2_2", "treeLikelihood.RSV2_3", "treeLikelihood.RSV2_1", "TreeHeight.t:tree", "YuleModel.t:tree", "birthRate.t:tree", "kappa.s:RSV2_1", "mutationRate.s:RSV2_1", "kappa.s:RSV2_2", "mutationRate.s:RSV2_2", "kappa.s:RSV2_3", "mutationRate.s:RSV2_3", "clockRate.c:clock");
    // 5. Change tree prior to Coalescent with constant pop size
    warning("5a. Change tree prior to Coalescent with constant pop size");
    f.selectTab("Priors");
    beautiFrame.comboBox("TreeDistribution").selectItem("Coalescent Constant Population");
    warning("5b. Change clock prior to Log Normal with M = -5, S = 1.25");
    beautiFrame.comboBox("clockRate.c:clock.distr").selectItem("Log Normal");
    beautiFrame.button("ClockPrior.c:clock.editButton").click();
    beautiFrame.textBox("M").selectAll().setText("-5");
    beautiFrame.textBox("S").selectAll().setText("1.25");
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "priors.png");
    printBeautiState(f);
    assertStateEquals("Tree.t:tree", "kappa.s:RSV2_1", "mutationRate.s:RSV2_1", "kappa.s:RSV2_2", "mutationRate.s:RSV2_2", "kappa.s:RSV2_3", "mutationRate.s:RSV2_3", "clockRate.c:clock", "popSize.t:tree");
    assertOperatorsEqual("CoalescentConstantTreeScaler.t:tree", "CoalescentConstantTreeRootScaler.t:tree", "CoalescentConstantUniformOperator.t:tree", "CoalescentConstantSubtreeSlide.t:tree", "CoalescentConstantNarrow.t:tree", "CoalescentConstantWide.t:tree", "CoalescentConstantWilsonBalding.t:tree", "KappaScaler.s:RSV2_1", "KappaScaler.s:RSV2_2", "KappaScaler.s:RSV2_3", "FixMeanMutationRatesOperator", "StrictClockRateScaler.c:clock", "strictClockUpDownOperator.c:clock", "PopSizeScaler.t:tree");
    assertPriorsEqual("CoalescentConstant.t:tree", "ClockPrior.c:clock", "KappaPrior.s:RSV2_1", "KappaPrior.s:RSV2_2", "KappaPrior.s:RSV2_3", "PopSizePrior.t:tree");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.RSV2_2", "treeLikelihood.RSV2_3", "treeLikelihood.RSV2_1", "TreeHeight.t:tree", "kappa.s:RSV2_1", "mutationRate.s:RSV2_1", "kappa.s:RSV2_2", "mutationRate.s:RSV2_2", "kappa.s:RSV2_3", "mutationRate.s:RSV2_3", "clockRate.c:clock", "popSize.t:tree", "CoalescentConstant.t:tree");
    // 6. Run MCMC and look at results in Tracer, TreeAnnotator->FigTree
    warning("6. Setting up MCMC parameters");
    f = f.selectTab("MCMC");
    beautiFrame.textBox("chainLength").selectAll().setText("2000000");
    beautiFrame.button("tracelog.editButton").click();
    beautiFrame.textBox("logEvery").selectAll().setText("400");
    beautiFrame.button("tracelog.editButton").click();
    beautiFrame.button("treelog.t:tree.editButton").click();
    beautiFrame.textBox("logEvery").selectAll().setText("400");
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "mcmc.png");
    beautiFrame.button("treelog.t:tree.editButton").click();
    printBeautiState(f);
    assertStateEquals("Tree.t:tree", "kappa.s:RSV2_1", "mutationRate.s:RSV2_1", "kappa.s:RSV2_2", "mutationRate.s:RSV2_2", "kappa.s:RSV2_3", "mutationRate.s:RSV2_3", "clockRate.c:clock", "popSize.t:tree");
    assertOperatorsEqual("CoalescentConstantTreeScaler.t:tree", "CoalescentConstantTreeRootScaler.t:tree", "CoalescentConstantUniformOperator.t:tree", "CoalescentConstantSubtreeSlide.t:tree", "CoalescentConstantNarrow.t:tree", "CoalescentConstantWide.t:tree", "CoalescentConstantWilsonBalding.t:tree", "KappaScaler.s:RSV2_1", "KappaScaler.s:RSV2_2", "KappaScaler.s:RSV2_3", "FixMeanMutationRatesOperator", "StrictClockRateScaler.c:clock", "strictClockUpDownOperator.c:clock", "PopSizeScaler.t:tree");
    assertPriorsEqual("CoalescentConstant.t:tree", "ClockPrior.c:clock", "KappaPrior.s:RSV2_1", "KappaPrior.s:RSV2_2", "KappaPrior.s:RSV2_3", "PopSizePrior.t:tree");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.RSV2_2", "treeLikelihood.RSV2_3", "treeLikelihood.RSV2_1", "TreeHeight.t:tree", "kappa.s:RSV2_1", "mutationRate.s:RSV2_1", "kappa.s:RSV2_2", "mutationRate.s:RSV2_2", "kappa.s:RSV2_3", "mutationRate.s:RSV2_3", "clockRate.c:clock", "popSize.t:tree", "CoalescentConstant.t:tree");
    // 7. Run MCMC and look at results in Tracer, TreeAnnotator->FigTree
    warning("7. Run MCMC and look at results in Tracer, TreeAnnotator->FigTree");
    makeSureXMLParses();
    long t1 = System.currentTimeMillis();
    System.err.println("total time: " + (t1 - t0) / 1000 + " seconds");
}
Also used : ScreenshotTaker(org.fest.swing.image.ScreenshotTaker) File(java.io.File) Test(org.junit.Test)

Example 2 with ScreenshotTaker

use of org.fest.swing.image.ScreenshotTaker in project beast2 by CompEvol.

the class BeautiSimpleTest method simpleTest.

@Test
public void simpleTest() throws Exception {
    importAlignment("examples/nexus", new File("anolis.nex"));
    // load anolis.nex
    JTabbedPaneFixture f = beautiFrame.tabbedPane();
    f.requireVisible();
    f.requireTitle("Partitions", Index.atIndex(0));
    String[] titles = f.tabTitles();
    assertArrayEquals(titles, "[Partitions, Tip Dates, Site Model, Clock Model, Priors, MCMC]");
    System.err.println(Arrays.toString(titles));
    f = f.selectTab("Partitions");
    JTableFixture t = beautiFrame.table();
    String[][] tc = t.contents();
    System.err.println(Arrays.toString(tc[0]));
    assertArrayEquals(tc[0], "[anolis, anolis, 29, 1456, nucleotide, anolis, anolis, anolis, false]");
    assertThat(f).isNotNull();
    assertStateEquals("Tree.t:anolis", "birthRate.t:anolis");
    assertOperatorsEqual("YuleBirthRateScaler.t:anolis", "YuleModelTreeScaler.t:anolis", "YuleModelTreeRootScaler.t:anolis", "YuleModelUniformOperator.t:anolis", "YuleModelSubtreeSlide.t:anolis", "YuleModelNarrow.t:anolis", "YuleModelWide.t:anolis", "YuleModelWilsonBalding.t:anolis");
    assertPriorsEqual("YuleModel.t:anolis", "YuleBirthRatePrior.t:anolis");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.anolis", "TreeHeight.t:anolis", "YuleModel.t:anolis", "birthRate.t:anolis");
    ScreenshotTaker screenshotTaker = new ScreenshotTaker();
    (new File("/tmp/simpleTest1.png")).delete();
    (new File("/tmp/simpleTest2.png")).delete();
    (new File("/tmp/simpleTest3.png")).delete();
    (new File("/tmp/simpleTest4.png")).delete();
    screenshotTaker.saveComponentAsPng(beauti.frame, "/tmp/simpleTest1.png");
    // Set the site model to HKY (estimated)
    f.selectTab("Site Model");
    JComboBoxFixture substModel = beautiFrame.comboBox("substModel");
    substModel.selectItem("HKY");
    printBeautiState(f);
    assertStateEquals("Tree.t:anolis", "birthRate.t:anolis", "kappa.s:anolis", "freqParameter.s:anolis");
    assertOperatorsEqual("YuleBirthRateScaler.t:anolis", "YuleModelTreeScaler.t:anolis", "YuleModelTreeRootScaler.t:anolis", "YuleModelUniformOperator.t:anolis", "YuleModelSubtreeSlide.t:anolis", "YuleModelNarrow.t:anolis", "YuleModelWide.t:anolis", "YuleModelWilsonBalding.t:anolis", "KappaScaler.s:anolis", "FrequenciesExchanger.s:anolis");
    assertPriorsEqual("YuleModel.t:anolis", "YuleBirthRatePrior.t:anolis", "KappaPrior.s:anolis");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.anolis", "TreeHeight.t:anolis", "YuleModel.t:anolis", "birthRate.t:anolis", "kappa.s:anolis", "freqParameter.s:anolis");
    // Set the site model to HKY (G4) (estimated)
    f.selectTab("Site Model");
    JTextComponentFixture categoryCount = beautiFrame.textBox("gammaCategoryCount");
    categoryCount.setText("4");
    printBeautiState(f);
    // assertStateEquals("Tree.t:anolis", "birthRate.t:anolis", "kappa.s:anolis", "freqParameter.s:anolis");
    // assertOperatorsEqual("YuleBirthRateScaler.t:anolis", "YuleModelTreeScaler.t:anolis", "YuleModelTreeRootScaler.t:anolis", "YuleModelUniformOperator.t:anolis", "YuleModelSubtreeSlide.t:anolis", "YuleModelNarrow.t:anolis", "YuleModelWide.t:anolis", "YuleModelWilsonBalding.t:anolis", "KappaScaler.s:anolis", "FrequenciesExchanger.s:anolis");
    // assertPriorsEqual("YuleModel.t:anolis", "YuleBirthRatePrior.t:anolis", "KappaPrior.s:anolis");
    // assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.anolis", "TreeHeight.t:anolis", "YuleModel.t:anolis", "birthRate.t:anolis", "kappa.s:anolis", "freqParameter.s:anolis");
    // 
    // f.selectTab("Site Model");
    // JCheckBoxFixture shapeIsEstimated = beautiFrame.checkBox("shape.isEstimated");
    // shapeIsEstimated.check();
    // printBeautiState(f);
    assertStateEquals("Tree.t:anolis", "birthRate.t:anolis", "kappa.s:anolis", "gammaShape.s:anolis", "freqParameter.s:anolis");
    assertOperatorsEqual("YuleBirthRateScaler.t:anolis", "YuleModelTreeScaler.t:anolis", "YuleModelTreeRootScaler.t:anolis", "YuleModelUniformOperator.t:anolis", "YuleModelSubtreeSlide.t:anolis", "YuleModelNarrow.t:anolis", "YuleModelWide.t:anolis", "YuleModelWilsonBalding.t:anolis", "KappaScaler.s:anolis", "gammaShapeScaler.s:anolis", "FrequenciesExchanger.s:anolis");
    assertPriorsEqual("YuleModel.t:anolis", "YuleBirthRatePrior.t:anolis", "KappaPrior.s:anolis", "GammaShapePrior.s:anolis");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.anolis", "TreeHeight.t:anolis", "YuleModel.t:anolis", "birthRate.t:anolis", "kappa.s:anolis", "gammaShape.s:anolis", "freqParameter.s:anolis");
    screenshotTaker.saveComponentAsPng(beauti.frame, "/tmp/simpleTest2.png");
    // rename tree from 'anolis' to 'tree'
    f.selectTab("Partitions");
    JTableCellFixture cell = beautiFrame.table().cell(TableCell.row(0).column(7));
    Component editor = cell.editor();
    JComboBoxFixture comboBox = new JComboBoxFixture(robot(), (JComboBox<?>) editor);
    cell.startEditing();
    comboBox.selectAllText();
    comboBox.enterText("tree");
    comboBox.pressAndReleaseKeys(KeyEvent.VK_ENTER);
    cell.stopEditing();
    printBeautiState(f);
    assertStateEquals("Tree.t:tree", "birthRate.t:tree", "kappa.s:anolis", "gammaShape.s:anolis", "freqParameter.s:anolis");
    assertOperatorsEqual("YuleBirthRateScaler.t:tree", "YuleModelTreeScaler.t:tree", "YuleModelTreeRootScaler.t:tree", "YuleModelUniformOperator.t:tree", "YuleModelSubtreeSlide.t:tree", "YuleModelNarrow.t:tree", "YuleModelWide.t:tree", "YuleModelWilsonBalding.t:tree", "KappaScaler.s:anolis", "gammaShapeScaler.s:anolis", "FrequenciesExchanger.s:anolis");
    assertPriorsEqual("YuleModel.t:tree", "YuleBirthRatePrior.t:tree", "GammaShapePrior.s:anolis", "KappaPrior.s:anolis");
    assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.anolis", "TreeHeight.t:tree", "YuleModel.t:tree", "birthRate.t:tree", "kappa.s:anolis", "gammaShape.s:anolis", "freqParameter.s:anolis");
    screenshotTaker.saveComponentAsPng(beauti.frame, "/tmp/simpleTest3.png");
    // Create a Normal calibration prior and monophyletic constraint on Human-Chimp split of 6 +/- 0.5.
    f.selectTab("Priors");
    screenshotTaker.saveComponentAsPng(beauti.frame, "/tmp/simpleTest4.png");
    makeSureXMLParses();
}
Also used : JTableCellFixture(org.fest.swing.fixture.JTableCellFixture) JTableFixture(org.fest.swing.fixture.JTableFixture) JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) ScreenshotTaker(org.fest.swing.image.ScreenshotTaker) Component(java.awt.Component) File(java.io.File) JTextComponentFixture(org.fest.swing.fixture.JTextComponentFixture) JTabbedPaneFixture(org.fest.swing.fixture.JTabbedPaneFixture) Test(org.junit.Test)

Example 3 with ScreenshotTaker

use of org.fest.swing.image.ScreenshotTaker in project beast2 by CompEvol.

the class BeautiRateTutorialTest method MEPBSPTutorial.

@Test
public void MEPBSPTutorial() throws InterruptedException {
    if (true) {
        return;
    }
    try {
        long t0 = System.currentTimeMillis();
        ScreenshotTaker screenshotTaker = new ScreenshotTaker();
        beauti.frame.setSize(1024, 640);
        // 1. reaload XML file
        warning("1. reload rsv.xml");
        String dir = "" + org.fest.util.Files.temporaryFolder();
        String file = XML_FILE;
        if (!Utils.isMac()) {
            beautiFrame.menuItemWithPath("File", "Load").click();
            JFileChooserFixture fileChooser = findFileChooser().using(robot());
            fileChooser.setCurrentDirectory(new File(dir));
            fileChooser.selectFile(new File(file)).approve();
        } else {
            _file = new File(dir + "/" + file);
            execute(new GuiTask() {

                @Override
                protected void executeInEDT() {
                    doc.newAnalysis();
                    doc.setFileName(_file.getAbsolutePath());
                    try {
                        doc.loadXML(new File(doc.getFileName()));
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            });
        }
        JTabbedPaneFixture f = beautiFrame.tabbedPane();
        printBeautiState(f);
        // 2. change tree prior to BSP
        warning("2. change tree prior to BSP");
        f.selectTab("Priors");
        beautiFrame.comboBox("TreeDistribution").selectItem("Coalescent Bayesian Skyline");
        screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "priors2.png");
        printBeautiState(f);
        // 3. change tree prior to BSP
        warning("3. change group and population size parameters");
        beautiFrame.menuItemWithPath("View", "Show Initialization panel").click();
        beautiFrame.button("isPopSizes.t:tree.editButton").click();
        beautiFrame.textBox("dimension").selectAll().setText("3");
        beautiFrame.button("isPopSizes.t:tree.editButton").click();
        beautiFrame.button("isGroupSizes.t:tree.editButton").click();
        beautiFrame.textBox("dimension").selectAll().setText("3");
        screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "init.png");
        printBeautiState(f);
        // 4. set chain-length to 10M, log every 10K
        warning("4. set chain-length to 10M, log every 10K");
        f = f.selectTab("MCMC");
        beautiFrame.textBox("chainLength").selectAll().setText("10000000");
        beautiFrame.button("tracelog.editButton").click();
        beautiFrame.textBox("logEvery").selectAll().setText("10000");
        beautiFrame.button("tracelog.editButton").click();
        beautiFrame.button("treelog.t:tree.editButton").click();
        beautiFrame.textBox("logEvery").selectAll().setText("10000");
        beautiFrame.button("treelog.t:tree.editButton").click();
        printBeautiState(f);
        // 5. save XML file
        warning("5. save XML file");
        File fout = new File(org.fest.util.Files.temporaryFolder() + "/" + XML_FILE);
        if (fout.exists()) {
            fout.delete();
        }
        saveFile("" + org.fest.util.Files.temporaryFolder(), XML_FILE);
        // 4. Run MCMC and look at results in Tracer, TreeAnnotator->FigTree
        makeSureXMLParses();
        long t1 = System.currentTimeMillis();
        System.err.println("total time: " + (t1 - t0) / 1000 + " seconds");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : GuiTask(org.fest.swing.edt.GuiTask) ScreenshotTaker(org.fest.swing.image.ScreenshotTaker) File(java.io.File) Test(org.junit.Test)

Example 4 with ScreenshotTaker

use of org.fest.swing.image.ScreenshotTaker in project beast2 by CompEvol.

the class BeautiStarBeastTest method simpleStarBeastTest.

@Test
public void simpleStarBeastTest() throws Exception {
    ScreenshotTaker screenshotTaker = new ScreenshotTaker();
    beauti.frame.setSize(1024, 640);
    String BASE_DIR = PREFIX.substring(0, PREFIX.lastIndexOf('/'));
    for (File file : new File(BASE_DIR).listFiles()) {
        if (file.getAbsolutePath().contains(PREFIX) && file.getName().endsWith(".png")) {
            file.delete();
        }
    }
    // create screen-shot showing template menu item
    warning("Select StarBeast template");
    beautiFrame.menuItemWithPath("File", "Template").click();
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "selectTemplate.png");
    JMenuItemFixture templateMenu = beautiFrame.menuItemWithPath("File", "Template", "StarBeast");
    templateMenu.click();
    // remove menu from screen
    beautiFrame.menuItemWithPath("File").click();
    JTabbedPaneFixture f = beautiFrame.tabbedPane();
    f = f.selectTab("Priors");
    // 1. Load gopher data 26.nex, 29.nex, 47.nex
    warning("1. Load gopher data 26.nex, 29.nex, 47.nex");
    importAlignment("examples/nexus", new File("26.nex"), new File("29.nex"), new File("47.nex"));
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "DataPartitions.png");
    printBeautiState(f);
    // 2. Define Taxon sets
    warning("2. Define taxon sets");
    f.selectTab("Taxon sets");
    beautiFrame.button("Guess").click();
    JOptionPaneFixture dialog = new JOptionPaneFixture(robot());
    // DialogFixture dialog = WindowFinder.findDialog("GuessTaxonSets").using(robot());
    dialog.radioButton("split on character").click();
    dialog.comboBox("splitCombo").selectItem("2");
    dialog.textBox("SplitChar2").deleteText().enterText("_");
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "Guess_Taxonsets.png");
    // JButton okButton = dialog.robot.finder().find(JButtonMatcher.withText("OK"));
    // new JButtonFixture(dialog.robot, okButton).click();
    dialog.okButton().click();
    printBeautiState(f);
    // 3. Set site model to HKY + empirical frequencies
    warning("3. Set site model to HKY + empirical frequencies");
    f.selectTab("Site Model");
    for (int i = 0; i < 3; i++) {
        beautiFrame.list().selectItem(i);
        beautiFrame.comboBox("substModel").selectItem("HKY");
        JComboBoxFixture freqs = beautiFrame.comboBox("frequencies");
        freqs.selectItem("Empirical");
    // beautiFrame.checkBox("mutationRate.isEstimated").check();
    }
    // JCheckBoxFixture fixMeanMutationRate = beautiFrame.checkBox("FixMeanMutationRate");
    // fixMeanMutationRate.check();
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "Site_Model.png");
    printBeautiState(f);
    // 4. Inspect clock models
    warning("4. Inspect clock models");
    f.selectTab("Clock Model");
    beautiFrame.list().selectItem(0);
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "ClockModel1.png");
    beautiFrame.list().selectItem(1);
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "ClockModel2.png");
    beautiFrame.list().selectItem(2);
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "ClockModel3.png");
    // 5. Inspect multispecies coalescent
    warning("5. Inspect multispecies coalescent");
    f.selectTab("Multi Species Coalescent");
    beautiFrame.button("treePrior.t:26.editButton").click();
    beautiFrame.button("treePrior.t:29.editButton").click();
    beautiFrame.button("treePrior.t:47.editButton").click();
    beautiFrame.comboBox().selectItem("linear_with_constant_root");
    beautiFrame.button("treePrior.t:26.editButton").click();
    beautiFrame.button("treePrior.t:29.editButton").click();
    beautiFrame.button("treePrior.t:47.editButton").click();
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "MSP.png");
    // 6. Set up MCMC parameters
    warning("6. Set up MCMC parameters");
    f = f.selectTab("MCMC");
    beautiFrame.textBox("chainLength").selectAll().setText("5000000");
    beautiFrame.button("speciesTreeLogger.editButton").click();
    beautiFrame.textBox("logEvery").selectAll().setText("1000");
    beautiFrame.button("speciesTreeLogger.editButton").click();
    beautiFrame.button("screenlog.editButton").click();
    beautiFrame.textBox("logEvery").selectAll().setText("10000");
    beautiFrame.button("speciesTreeLogger.editButton").click();
    screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "MCMC.png");
    makeSureXMLParses();
}
Also used : JComboBoxFixture(org.fest.swing.fixture.JComboBoxFixture) ScreenshotTaker(org.fest.swing.image.ScreenshotTaker) JMenuItemFixture(org.fest.swing.fixture.JMenuItemFixture) File(java.io.File) JTabbedPaneFixture(org.fest.swing.fixture.JTabbedPaneFixture) JOptionPaneFixture(org.fest.swing.fixture.JOptionPaneFixture) Test(org.junit.Test)

Example 5 with ScreenshotTaker

use of org.fest.swing.image.ScreenshotTaker in project beast2 by CompEvol.

the class BeautiDivergenceDatingTest method DivergenceDatingTutorialWithEmpiricalFreqs.

@Test
public void DivergenceDatingTutorialWithEmpiricalFreqs() throws Exception {
    try {
        long t0 = System.currentTimeMillis();
        ScreenshotTaker screenshotTaker = new ScreenshotTaker();
        beauti.frame.setSize(1200, 800);
        String BASE_DIR = PREFIX.substring(0, PREFIX.lastIndexOf('/'));
        for (File file : new File(BASE_DIR).listFiles()) {
            if (file.getAbsolutePath().contains(PREFIX) && file.getName().endsWith(".png")) {
                file.delete();
            }
        }
        // 0. Load primate-mtDNA.nex
        warning("// 0. Load primate-mtDNA.nex");
        importAlignment("examples/nexus", new File("primate-mtDNA.nex"));
        screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "DataPartitions.png");
        beautiFrame.menuItemWithPath("Mode", "Automatic set fix mean substitution rate flag").click();
        JTabbedPaneFixture f = beautiFrame.tabbedPane();
        f.requireVisible();
        f.requireTitle("Partitions", Index.atIndex(0));
        String[] titles = f.tabTitles();
        assertArrayEquals(titles, "[Partitions, Tip Dates, Site Model, Clock Model, Priors, MCMC]");
        System.err.println(Arrays.toString(titles));
        f = f.selectTab("Partitions");
        // inspect alignment
        JTableFixture t = beautiFrame.table();
        t.selectCell(TableCell.row(0).column(2)).doubleClick();
        DialogFixture dlg = WindowFinder.findDialog("AlignmentViewer").using(robot());
        dlg.target.setSize(768, 300);
        dlg.checkBox("UseColor").check();
        screenshotTaker.saveComponentAsPng(dlg.target, PREFIX + "Alignment.png");
        dlg.close();
        // check table
        printTableContents(t);
        checkTableContents(f, "[coding, primate-mtDNA, 12, 693, nucleotide, coding, coding, coding, false]*" + "[noncoding, primate-mtDNA, 12, 205, nucleotide, noncoding, noncoding, noncoding, false]*" + "[1stpos, primate-mtDNA, 12, 231, nucleotide, 1stpos, 1stpos, 1stpos, false]*" + "[2ndpos, primate-mtDNA, 12, 231, nucleotide, 2ndpos, 2ndpos, 2ndpos, false]*" + "[3rdpos, primate-mtDNA, 12, 231, nucleotide, 3rdpos, 3rdpos, 3rdpos, false]");
        assertThat(f).isNotNull();
        printBeautiState(f);
        assertStateEquals("Tree.t:noncoding", "clockRate.c:noncoding", "birthRate.t:noncoding", "Tree.t:2ndpos", "clockRate.c:2ndpos", "birthRate.t:2ndpos", "Tree.t:1stpos", "clockRate.c:1stpos", "birthRate.t:1stpos", "Tree.t:coding", "birthRate.t:coding", "Tree.t:3rdpos", "clockRate.c:3rdpos", "birthRate.t:3rdpos");
        assertOperatorsEqual("StrictClockRateScaler.c:noncoding", "YuleBirthRateScaler.t:noncoding", "YuleModelTreeScaler.t:noncoding", "YuleModelTreeRootScaler.t:noncoding", "YuleModelUniformOperator.t:noncoding", "YuleModelSubtreeSlide.t:noncoding", "YuleModelNarrow.t:noncoding", "YuleModelWide.t:noncoding", "YuleModelWilsonBalding.t:noncoding", "StrictClockRateScaler.c:2ndpos", "YuleBirthRateScaler.t:2ndpos", "YuleModelTreeScaler.t:2ndpos", "YuleModelTreeRootScaler.t:2ndpos", "YuleModelUniformOperator.t:2ndpos", "YuleModelSubtreeSlide.t:2ndpos", "YuleModelNarrow.t:2ndpos", "YuleModelWide.t:2ndpos", "YuleModelWilsonBalding.t:2ndpos", "StrictClockRateScaler.c:1stpos", "YuleBirthRateScaler.t:1stpos", "YuleModelTreeScaler.t:1stpos", "YuleModelTreeRootScaler.t:1stpos", "YuleModelUniformOperator.t:1stpos", "YuleModelSubtreeSlide.t:1stpos", "YuleModelNarrow.t:1stpos", "YuleModelWide.t:1stpos", "YuleModelWilsonBalding.t:1stpos", "YuleBirthRateScaler.t:coding", "YuleModelTreeScaler.t:coding", "YuleModelTreeRootScaler.t:coding", "YuleModelUniformOperator.t:coding", "YuleModelSubtreeSlide.t:coding", "YuleModelNarrow.t:coding", "YuleModelWide.t:coding", "YuleModelWilsonBalding.t:coding", "StrictClockRateScaler.c:3rdpos", "YuleBirthRateScaler.t:3rdpos", "YuleModelTreeScaler.t:3rdpos", "YuleModelTreeRootScaler.t:3rdpos", "YuleModelUniformOperator.t:3rdpos", "YuleModelSubtreeSlide.t:3rdpos", "YuleModelNarrow.t:3rdpos", "YuleModelWide.t:3rdpos", "YuleModelWilsonBalding.t:3rdpos", "strictClockUpDownOperator.c:3rdpos", "strictClockUpDownOperator.c:1stpos", "strictClockUpDownOperator.c:2ndpos", "strictClockUpDownOperator.c:noncoding");
        assertPriorsEqual("YuleModel.t:coding", "YuleModel.t:noncoding", "YuleModel.t:1stpos", "YuleModel.t:2ndpos", "YuleModel.t:3rdpos", "ClockPrior.c:noncoding", "YuleBirthRatePrior.t:noncoding", "ClockPrior.c:2ndpos", "YuleBirthRatePrior.t:2ndpos", "ClockPrior.c:1stpos", "YuleBirthRatePrior.t:1stpos", "YuleBirthRatePrior.t:coding", "ClockPrior.c:3rdpos", "YuleBirthRatePrior.t:3rdpos");
        // 1. Delete "coding" partition as it covers the same sites as the 1stpos, 2ndpos and 3rdpos partitions.
        warning("1. Delete \"coding\" partition as it covers the same sites as the 1stpos, 2ndpos and 3rdpos partitions.");
        f.selectTab("Partitions");
        t = beautiFrame.table();
        t.selectCell(TableCell.row(0).column(2));
        JButtonFixture deleteButton = beautiFrame.button("-");
        deleteButton.click();
        printBeautiState(f);
        checkTableContents(f, "[noncoding, primate-mtDNA, 12, 205, nucleotide, noncoding, noncoding, noncoding, false]*" + "[1stpos, primate-mtDNA, 12, 231, nucleotide, 1stpos, 1stpos, 1stpos, false]*" + "[2ndpos, primate-mtDNA, 12, 231, nucleotide, 2ndpos, 2ndpos, 2ndpos, false]*" + "[3rdpos, primate-mtDNA, 12, 231, nucleotide, 3rdpos, 3rdpos, 3rdpos, false]");
        assertStateEquals("Tree.t:noncoding", "birthRate.t:noncoding", "Tree.t:3rdpos", "clockRate.c:3rdpos", "birthRate.t:3rdpos", "Tree.t:1stpos", "clockRate.c:1stpos", "birthRate.t:1stpos", "Tree.t:2ndpos", "clockRate.c:2ndpos", "birthRate.t:2ndpos");
        assertOperatorsEqual("YuleBirthRateScaler.t:noncoding", "YuleModelTreeScaler.t:noncoding", "YuleModelTreeRootScaler.t:noncoding", "YuleModelUniformOperator.t:noncoding", "YuleModelSubtreeSlide.t:noncoding", "YuleModelNarrow.t:noncoding", "YuleModelWide.t:noncoding", "YuleModelWilsonBalding.t:noncoding", "StrictClockRateScaler.c:3rdpos", "YuleBirthRateScaler.t:3rdpos", "YuleModelTreeScaler.t:3rdpos", "YuleModelTreeRootScaler.t:3rdpos", "YuleModelUniformOperator.t:3rdpos", "YuleModelSubtreeSlide.t:3rdpos", "YuleModelNarrow.t:3rdpos", "YuleModelWide.t:3rdpos", "YuleModelWilsonBalding.t:3rdpos", "StrictClockRateScaler.c:1stpos", "YuleBirthRateScaler.t:1stpos", "YuleModelTreeScaler.t:1stpos", "YuleModelTreeRootScaler.t:1stpos", "YuleModelUniformOperator.t:1stpos", "YuleModelSubtreeSlide.t:1stpos", "YuleModelNarrow.t:1stpos", "YuleModelWide.t:1stpos", "YuleModelWilsonBalding.t:1stpos", "StrictClockRateScaler.c:2ndpos", "YuleBirthRateScaler.t:2ndpos", "YuleModelTreeScaler.t:2ndpos", "YuleModelTreeRootScaler.t:2ndpos", "YuleModelUniformOperator.t:2ndpos", "YuleModelSubtreeSlide.t:2ndpos", "YuleModelNarrow.t:2ndpos", "YuleModelWide.t:2ndpos", "YuleModelWilsonBalding.t:2ndpos", "strictClockUpDownOperator.c:3rdpos", "strictClockUpDownOperator.c:2ndpos", "strictClockUpDownOperator.c:1stpos");
        assertPriorsEqual("YuleModel.t:1stpos", "YuleModel.t:2ndpos", "YuleModel.t:3rdpos", "YuleModel.t:noncoding", "YuleBirthRatePrior.t:1stpos", "YuleBirthRatePrior.t:2ndpos", "YuleBirthRatePrior.t:3rdpos", "YuleBirthRatePrior.t:noncoding", "ClockPrior.c:1stpos", "ClockPrior.c:2ndpos", "ClockPrior.c:3rdpos");
        // 2a. Link trees...
        warning("2a. Link trees...");
        f.selectTab("Partitions");
        t = beautiFrame.table();
        t.selectCells(TableCell.row(0).column(2), TableCell.row(1).column(2), TableCell.row(2).column(2), TableCell.row(3).column(2));
        JButtonFixture linkTreesButton = beautiFrame.button("Link Trees");
        linkTreesButton.click();
        printBeautiState(f);
        assertStateEquals("Tree.t:noncoding", "birthRate.t:noncoding", "clockRate.c:2ndpos", "clockRate.c:3rdpos", "clockRate.c:1stpos");
        assertOperatorsEqual("YuleBirthRateScaler.t:noncoding", "YuleModelTreeScaler.t:noncoding", "YuleModelTreeRootScaler.t:noncoding", "YuleModelUniformOperator.t:noncoding", "YuleModelSubtreeSlide.t:noncoding", "YuleModelNarrow.t:noncoding", "YuleModelWide.t:noncoding", "YuleModelWilsonBalding.t:noncoding", "StrictClockRateScaler.c:2ndpos", "StrictClockRateScaler.c:3rdpos", "StrictClockRateScaler.c:1stpos", "strictClockUpDownOperator.c:2ndpos", "strictClockUpDownOperator.c:1stpos", "strictClockUpDownOperator.c:3rdpos");
        assertPriorsEqual("YuleModel.t:noncoding", "YuleBirthRatePrior.t:noncoding", "ClockPrior.c:1stpos", "ClockPrior.c:2ndpos", "ClockPrior.c:3rdpos");
        // 2b. ...and call the tree "tree"
        warning("2b. ...and call the tree \"tree\"");
        f.selectTab("Partitions");
        JTableCellFixture cell = beautiFrame.table().cell(TableCell.row(0).column(7));
        Component editor = cell.editor();
        JComboBoxFixture comboBox = new JComboBoxFixture(robot(), (JComboBox<?>) editor);
        cell.startEditing();
        comboBox.selectAllText();
        comboBox.enterText("tree");
        comboBox.pressAndReleaseKeys(KeyEvent.VK_ENTER);
        cell.stopEditing();
        checkTableContents(f, "[noncoding, primate-mtDNA, 12, 205, nucleotide, noncoding, noncoding, tree, false]*" + "[1stpos, primate-mtDNA, 12, 231, nucleotide, 1stpos, 1stpos, tree, false]*" + "[2ndpos, primate-mtDNA, 12, 231, nucleotide, 2ndpos, 2ndpos, tree, false]*" + "[3rdpos, primate-mtDNA, 12, 231, nucleotide, 3rdpos, 3rdpos, tree, false]");
        printBeautiState(f);
        assertStateEquals("clockRate.c:2ndpos", "Tree.t:tree", "birthRate.t:tree", "clockRate.c:1stpos", "clockRate.c:3rdpos");
        assertOperatorsEqual("StrictClockRateScaler.c:2ndpos", "YuleBirthRateScaler.t:tree", "YuleModelTreeScaler.t:tree", "YuleModelTreeRootScaler.t:tree", "YuleModelUniformOperator.t:tree", "YuleModelSubtreeSlide.t:tree", "YuleModelNarrow.t:tree", "YuleModelWide.t:tree", "YuleModelWilsonBalding.t:tree", "StrictClockRateScaler.c:1stpos", "StrictClockRateScaler.c:3rdpos", "strictClockUpDownOperator.c:3rdpos", "strictClockUpDownOperator.c:2ndpos", "strictClockUpDownOperator.c:1stpos");
        assertPriorsEqual("YuleModel.t:tree", "YuleBirthRatePrior.t:tree", "ClockPrior.c:1stpos", "ClockPrior.c:2ndpos", "ClockPrior.c:3rdpos");
        // 3a. Link clocks
        warning("3a. Link clocks");
        f.selectTab("Partitions");
        t = beautiFrame.table();
        t.selectCells(TableCell.row(0).column(2), TableCell.row(1).column(2), TableCell.row(2).column(2), TableCell.row(3).column(2));
        JButtonFixture linkClocksButton = beautiFrame.button("Link Clock Models");
        linkClocksButton.click();
        // 3b. and call the uncorrelated relaxed molecular clock "clock"
        warning("3b. and call the uncorrelated relaxed molecular clock \"clock\"");
        cell = beautiFrame.table().cell(TableCell.row(0).column(6));
        editor = cell.editor();
        comboBox = new JComboBoxFixture(robot(), (JComboBox<?>) editor);
        cell.startEditing();
        comboBox.selectAllText();
        comboBox.enterText("clock");
        comboBox.pressAndReleaseKeys(KeyEvent.VK_ENTER);
        cell.stopEditing();
        printBeautiState(f);
        checkTableContents(f, "[noncoding, primate-mtDNA, 12, 205, nucleotide, noncoding, clock, tree, false]*" + "[1stpos, primate-mtDNA, 12, 231, nucleotide, 1stpos, clock, tree, false]*" + "[2ndpos, primate-mtDNA, 12, 231, nucleotide, 2ndpos, clock, tree, false]*" + "[3rdpos, primate-mtDNA, 12, 231, nucleotide, 3rdpos, clock, tree, false]");
        assertStateEquals("Tree.t:tree", "birthRate.t:tree");
        assertOperatorsEqual("YuleBirthRateScaler.t:tree", "YuleModelTreeScaler.t:tree", "YuleModelTreeRootScaler.t:tree", "YuleModelUniformOperator.t:tree", "YuleModelSubtreeSlide.t:tree", "YuleModelNarrow.t:tree", "YuleModelWide.t:tree", "YuleModelWilsonBalding.t:tree");
        assertPriorsEqual("YuleModel.t:tree", "YuleBirthRatePrior.t:tree");
        screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "DataPartitions_final.png");
        // 4. Link site models temporarily in order to set the same model for all of them.
        warning("4. Link site models temporarily in order to set the same model for all of them.");
        f.selectTab("Partitions");
        t = beautiFrame.table();
        t.selectCells(TableCell.row(0).column(2), TableCell.row(1).column(2), TableCell.row(2).column(2), TableCell.row(3).column(2));
        JButtonFixture linkSiteModelsButton = beautiFrame.button("Link Site Models");
        linkSiteModelsButton.click();
        printBeautiState(f);
        checkTableContents(f, "[noncoding, primate-mtDNA, 12, 205, nucleotide, noncoding, clock, tree, false]*" + "[1stpos, primate-mtDNA, 12, 231, nucleotide, noncoding, clock, tree, false]*" + "[2ndpos, primate-mtDNA, 12, 231, nucleotide, noncoding, clock, tree, false]*" + "[3rdpos, primate-mtDNA, 12, 231, nucleotide, noncoding, clock, tree, false]");
        assertStateEquals("Tree.t:tree", "birthRate.t:tree");
        assertOperatorsEqual("YuleBirthRateScaler.t:tree", "YuleModelTreeScaler.t:tree", "YuleModelTreeRootScaler.t:tree", "YuleModelUniformOperator.t:tree", "YuleModelSubtreeSlide.t:tree", "YuleModelNarrow.t:tree", "YuleModelWide.t:tree", "YuleModelWilsonBalding.t:tree");
        assertPriorsEqual("YuleModel.t:tree", "YuleBirthRatePrior.t:tree");
        // 5. Set the site model to HKY+G4 (estimated)
        warning("5. Set the site model to HKY+G4 (estimated)");
        f.selectTab("Site Model");
        JComboBoxFixture substModel = beautiFrame.comboBox("substModel");
        substModel.selectItem("HKY");
        JComboBoxFixture freqs = beautiFrame.comboBox("frequencies");
        freqs.selectItem("Empirical");
        JTextComponentFixture categoryCount = beautiFrame.textBox("gammaCategoryCount");
        categoryCount.setText("4");
        JCheckBoxFixture shapeIsEstimated = beautiFrame.checkBox("shape.isEstimated");
        shapeIsEstimated.check();
        beautiFrame.checkBox("mutationRate.isEstimated").check();
        beautiFrame.checkBox("FixMeanMutationRate").check();
        screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "Model.png");
        printBeautiState(f);
        checkTableContents(f, "[noncoding, primate-mtDNA, 12, 205, nucleotide, noncoding, clock, tree, false]*" + "[1stpos, primate-mtDNA, 12, 231, nucleotide, noncoding, clock, tree, false]*" + "[2ndpos, primate-mtDNA, 12, 231, nucleotide, noncoding, clock, tree, false]*" + "[3rdpos, primate-mtDNA, 12, 231, nucleotide, noncoding, clock, tree, false]");
        assertStateEquals("Tree.t:tree", "birthRate.t:tree", "kappa.s:noncoding", "gammaShape.s:noncoding", "mutationRate.s:noncoding");
        assertOperatorsEqual("YuleBirthRateScaler.t:tree", "YuleModelTreeScaler.t:tree", "YuleModelTreeRootScaler.t:tree", "YuleModelUniformOperator.t:tree", "YuleModelSubtreeSlide.t:tree", "YuleModelNarrow.t:tree", "YuleModelWide.t:tree", "YuleModelWilsonBalding.t:tree", "KappaScaler.s:noncoding", "gammaShapeScaler.s:noncoding", "FixMeanMutationRatesOperator");
        assertPriorsEqual("YuleModel.t:tree", "YuleBirthRatePrior.t:tree", "KappaPrior.s:noncoding", "GammaShapePrior.s:noncoding");
        assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.1stpos", "treeLikelihood.2ndpos", "treeLikelihood.3rdpos", "treeLikelihood.noncoding", "TreeHeight.t:tree", "YuleModel.t:tree", "birthRate.t:tree", "kappa.s:noncoding", "gammaShape.s:noncoding", "mutationRate.s:noncoding");
        // 6 Unlink the site models,
        warning("6 Unlink the site models,");
        f.selectTab("Partitions");
        t = beautiFrame.table();
        t.selectCells(TableCell.row(0).column(2), TableCell.row(1).column(2), TableCell.row(2).column(2), TableCell.row(3).column(2));
        beautiFrame.button("Unlink Site Models").click();
        printBeautiState(f);
        checkTableContents(f, "[noncoding, primate-mtDNA, 12, 205, nucleotide, noncoding, clock, tree, false]*" + "[1stpos, primate-mtDNA, 12, 231, nucleotide, 1stpos, clock, tree, false]*" + "[2ndpos, primate-mtDNA, 12, 231, nucleotide, 2ndpos, clock, tree, false]*" + "[3rdpos, primate-mtDNA, 12, 231, nucleotide, 3rdpos, clock, tree, false]");
        assertStateEquals("Tree.t:tree", "birthRate.t:tree", "kappa.s:noncoding", "gammaShape.s:noncoding", "mutationRate.s:noncoding", "kappa.s:1stpos", "gammaShape.s:1stpos", "mutationRate.s:1stpos", "kappa.s:2ndpos", "gammaShape.s:2ndpos", "mutationRate.s:2ndpos", "kappa.s:3rdpos", "gammaShape.s:3rdpos", "mutationRate.s:3rdpos");
        assertOperatorsEqual("YuleBirthRateScaler.t:tree", "YuleModelTreeScaler.t:tree", "YuleModelTreeRootScaler.t:tree", "YuleModelUniformOperator.t:tree", "YuleModelSubtreeSlide.t:tree", "YuleModelNarrow.t:tree", "YuleModelWide.t:tree", "YuleModelWilsonBalding.t:tree", "KappaScaler.s:noncoding", "gammaShapeScaler.s:noncoding", "FixMeanMutationRatesOperator", "gammaShapeScaler.s:1stpos", "KappaScaler.s:1stpos", "gammaShapeScaler.s:2ndpos", "KappaScaler.s:2ndpos", "gammaShapeScaler.s:3rdpos", "KappaScaler.s:3rdpos");
        assertPriorsEqual("YuleModel.t:tree", "YuleBirthRatePrior.t:tree", "KappaPrior.s:noncoding", "GammaShapePrior.s:noncoding", "GammaShapePrior.s:1stpos", "KappaPrior.s:1stpos", "GammaShapePrior.s:2ndpos", "KappaPrior.s:2ndpos", "GammaShapePrior.s:3rdpos", "KappaPrior.s:3rdpos");
        assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.1stpos", "treeLikelihood.2ndpos", "treeLikelihood.3rdpos", "treeLikelihood.noncoding", "TreeHeight.t:tree", "YuleModel.t:tree", "birthRate.t:tree", "kappa.s:noncoding", "gammaShape.s:noncoding", "mutationRate.s:noncoding", "kappa.s:1stpos", "gammaShape.s:1stpos", "mutationRate.s:1stpos", "kappa.s:2ndpos", "gammaShape.s:2ndpos", "mutationRate.s:2ndpos", "kappa.s:3rdpos", "gammaShape.s:3rdpos", "mutationRate.s:3rdpos");
        // 7a. Create a Normal calibration prior
        warning("7a. Create a Normal calibration prior");
        f.selectTab("Priors");
        beautiFrame.comboBox("TreeDistribution").selectItem("Calibrated Yule Model");
        screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "Prior1.png");
        Component c = beautiFrame.robot.finder().findByName("addItem");
        JButtonFixture addButton = new JButtonFixture(robot(), (JButton) c);
        addButton.click();
        JOptionPaneFixture dialog = new JOptionPaneFixture(robot());
        dialog.textBox("idEntry").setText("Human-Chimp");
        dialog.list("listOfTaxonCandidates").selectItems("Homo_sapiens", "Pan");
        dialog.button(">>").click();
        dialog.okButton().click();
        printBeautiState(f);
        assertStateEquals("Tree.t:tree", "kappa.s:noncoding", "gammaShape.s:noncoding", "mutationRate.s:noncoding", "kappa.s:1stpos", "gammaShape.s:1stpos", "mutationRate.s:1stpos", "kappa.s:2ndpos", "gammaShape.s:2ndpos", "mutationRate.s:2ndpos", "kappa.s:3rdpos", "gammaShape.s:3rdpos", "mutationRate.s:3rdpos", "birthRateY.t:tree");
        assertOperatorsEqual("CalibratedYuleModelTreeScaler.t:tree", "CalibratedYuleModelTreeRootScaler.t:tree", "CalibratedYuleModelUniformOperator.t:tree", "CalibratedYuleModelSubtreeSlide.t:tree", "CalibratedYuleModelNarrow.t:tree", "CalibratedYuleModelWide.t:tree", "CalibratedYuleModelWilsonBalding.t:tree", "KappaScaler.s:noncoding", "gammaShapeScaler.s:noncoding", "FixMeanMutationRatesOperator", "gammaShapeScaler.s:1stpos", "KappaScaler.s:1stpos", "gammaShapeScaler.s:2ndpos", "KappaScaler.s:2ndpos", "gammaShapeScaler.s:3rdpos", "KappaScaler.s:3rdpos", "CalibratedYuleBirthRateScaler.t:tree");
        assertPriorsEqual("CalibratedYuleModel.t:tree", "CalibratedYuleBirthRatePrior.t:tree", "GammaShapePrior.s:1stpos", "GammaShapePrior.s:2ndpos", "GammaShapePrior.s:3rdpos", "GammaShapePrior.s:noncoding", "KappaPrior.s:1stpos", "KappaPrior.s:2ndpos", "KappaPrior.s:3rdpos", "KappaPrior.s:noncoding", "Human-Chimp.prior");
        assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.1stpos", "treeLikelihood.2ndpos", "treeLikelihood.3rdpos", "treeLikelihood.noncoding", "TreeHeight.t:tree", "kappa.s:noncoding", "gammaShape.s:noncoding", "mutationRate.s:noncoding", "kappa.s:1stpos", "gammaShape.s:1stpos", "mutationRate.s:1stpos", "kappa.s:2ndpos", "gammaShape.s:2ndpos", "mutationRate.s:2ndpos", "kappa.s:3rdpos", "gammaShape.s:3rdpos", "mutationRate.s:3rdpos", "CalibratedYuleModel.t:tree", "birthRateY.t:tree", "Human-Chimp.prior");
        // 7b. and monophyletic constraint on Human-Chimp split of 6 +/- 0.5.
        warning("7b. and monophyletic constraint on Human-Chimp split of 6 +/- 0.5.");
        f.selectTab("Priors");
        beautiFrame.checkBox("Human-Chimp.prior.isMonophyletic").click();
        beautiFrame.comboBox("Human-Chimp.prior.distr").selectItem("Normal");
        beautiFrame.button("Human-Chimp.prior.editButton").click();
        beautiFrame.textBox("mean").selectAll().setText("6");
        beautiFrame.textBox("sigma").selectAll().setText("0.5");
        // beautiFrame.scrollBar().scrollToMaximum();
        screenshotTaker.saveComponentAsPng(beauti.frame, PREFIX + "TaxonSets.png");
        printBeautiState(f);
        assertStateEquals("Tree.t:tree", "kappa.s:noncoding", "gammaShape.s:noncoding", "mutationRate.s:noncoding", "kappa.s:1stpos", "gammaShape.s:1stpos", "mutationRate.s:1stpos", "kappa.s:2ndpos", "gammaShape.s:2ndpos", "mutationRate.s:2ndpos", "kappa.s:3rdpos", "gammaShape.s:3rdpos", "mutationRate.s:3rdpos", "birthRateY.t:tree", "clockRate.c:clock");
        assertOperatorsEqual("CalibratedYuleModelTreeScaler.t:tree", "CalibratedYuleModelTreeRootScaler.t:tree", "CalibratedYuleModelUniformOperator.t:tree", "CalibratedYuleModelSubtreeSlide.t:tree", "CalibratedYuleModelNarrow.t:tree", "CalibratedYuleModelWide.t:tree", "CalibratedYuleModelWilsonBalding.t:tree", "KappaScaler.s:noncoding", "gammaShapeScaler.s:noncoding", "FixMeanMutationRatesOperator", "gammaShapeScaler.s:1stpos", "KappaScaler.s:1stpos", "gammaShapeScaler.s:2ndpos", "KappaScaler.s:2ndpos", "gammaShapeScaler.s:3rdpos", "KappaScaler.s:3rdpos", "CalibratedYuleBirthRateScaler.t:tree", "StrictClockRateScaler.c:clock", "strictClockUpDownOperator.c:clock");
        assertPriorsEqual("CalibratedYuleModel.t:tree", "CalibratedYuleBirthRatePrior.t:tree", "GammaShapePrior.s:1stpos", "GammaShapePrior.s:2ndpos", "GammaShapePrior.s:3rdpos", "GammaShapePrior.s:noncoding", "KappaPrior.s:1stpos", "KappaPrior.s:2ndpos", "KappaPrior.s:3rdpos", "KappaPrior.s:noncoding", "Human-Chimp.prior", "ClockPrior.c:clock");
        assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.1stpos", "treeLikelihood.2ndpos", "treeLikelihood.3rdpos", "treeLikelihood.noncoding", "TreeHeight.t:tree", "kappa.s:noncoding", "gammaShape.s:noncoding", "mutationRate.s:noncoding", "kappa.s:1stpos", "gammaShape.s:1stpos", "mutationRate.s:1stpos", "kappa.s:2ndpos", "gammaShape.s:2ndpos", "mutationRate.s:2ndpos", "kappa.s:3rdpos", "gammaShape.s:3rdpos", "mutationRate.s:3rdpos", "CalibratedYuleModel.t:tree", "birthRateY.t:tree", "Human-Chimp.prior", "clockRate.c:clock");
        // 7c. set gamma priors on birth rate and clock rate
        warning("7c. set gamma priors on birth rate and clock rate");
        beautiFrame.comboBox("birthRateY.t:tree.distr").selectItem("Gamma");
        beautiFrame.button("CalibratedYuleBirthRatePrior.t:tree.editButton").click();
        beautiFrame.textBox("alpha").selectAll().setText("0.001");
        beautiFrame.textBox("beta").selectAll().setText("1000");
        beautiFrame.button("CalibratedYuleBirthRatePrior.t:tree.editButton").click();
        beautiFrame.comboBox("clockRate.c:clock.distr").selectItem("Gamma");
        beautiFrame.button("ClockPrior.c:clock.editButton").click();
        beautiFrame.textBox("alpha").selectAll().setText("0.001");
        beautiFrame.textBox("beta").selectAll().setText("1000");
        printBeautiState(f);
        assertStateEquals("Tree.t:tree", "kappa.s:noncoding", "gammaShape.s:noncoding", "mutationRate.s:noncoding", "kappa.s:1stpos", "gammaShape.s:1stpos", "mutationRate.s:1stpos", "kappa.s:2ndpos", "gammaShape.s:2ndpos", "mutationRate.s:2ndpos", "kappa.s:3rdpos", "gammaShape.s:3rdpos", "mutationRate.s:3rdpos", "birthRateY.t:tree", "clockRate.c:clock");
        assertOperatorsEqual("CalibratedYuleModelTreeScaler.t:tree", "CalibratedYuleModelTreeRootScaler.t:tree", "CalibratedYuleModelUniformOperator.t:tree", "CalibratedYuleModelSubtreeSlide.t:tree", "CalibratedYuleModelNarrow.t:tree", "CalibratedYuleModelWide.t:tree", "CalibratedYuleModelWilsonBalding.t:tree", "KappaScaler.s:noncoding", "gammaShapeScaler.s:noncoding", "FixMeanMutationRatesOperator", "gammaShapeScaler.s:1stpos", "KappaScaler.s:1stpos", "gammaShapeScaler.s:2ndpos", "KappaScaler.s:2ndpos", "gammaShapeScaler.s:3rdpos", "KappaScaler.s:3rdpos", "CalibratedYuleBirthRateScaler.t:tree", "StrictClockRateScaler.c:clock", "strictClockUpDownOperator.c:clock");
        assertPriorsEqual("CalibratedYuleModel.t:tree", "CalibratedYuleBirthRatePrior.t:tree", "ClockPrior.c:clock", "GammaShapePrior.s:1stpos", "GammaShapePrior.s:2ndpos", "GammaShapePrior.s:3rdpos", "GammaShapePrior.s:noncoding", "KappaPrior.s:1stpos", "KappaPrior.s:2ndpos", "KappaPrior.s:3rdpos", "KappaPrior.s:noncoding", "Human-Chimp.prior");
        assertTraceLogEqual("posterior", "likelihood", "prior", "treeLikelihood.1stpos", "treeLikelihood.2ndpos", "treeLikelihood.3rdpos", "treeLikelihood.noncoding", "TreeHeight.t:tree", "kappa.s:noncoding", "gammaShape.s:noncoding", "mutationRate.s:noncoding", "kappa.s:1stpos", "gammaShape.s:1stpos", "mutationRate.s:1stpos", "kappa.s:2ndpos", "gammaShape.s:2ndpos", "mutationRate.s:2ndpos", "kappa.s:3rdpos", "gammaShape.s:3rdpos", "mutationRate.s:3rdpos", "CalibratedYuleModel.t:tree", "birthRateY.t:tree", "Human-Chimp.prior", "clockRate.c:clock");
        // 8. Run MCMC and look at results in Tracer, TreeAnnotator->FigTree
        warning("8. Run MCMC and look at results in Tracer, TreeAnnotator->FigTree");
        File fout = new File(org.fest.util.Files.temporaryFolder() + "/primates.xml");
        if (fout.exists()) {
            fout.delete();
        }
        makeSureXMLParses();
        long t1 = System.currentTimeMillis();
        System.err.println("total time: " + (t1 - t0) / 1000 + " seconds");
    } catch (Exception e) {
        e.printStackTrace();
        throw e;
    }
}
Also used : ScreenshotTaker(org.fest.swing.image.ScreenshotTaker) File(java.io.File) Test(org.junit.Test)

Aggregations

File (java.io.File)5 ScreenshotTaker (org.fest.swing.image.ScreenshotTaker)5 Test (org.junit.Test)5 JComboBoxFixture (org.fest.swing.fixture.JComboBoxFixture)2 JTabbedPaneFixture (org.fest.swing.fixture.JTabbedPaneFixture)2 Component (java.awt.Component)1 GuiTask (org.fest.swing.edt.GuiTask)1 JMenuItemFixture (org.fest.swing.fixture.JMenuItemFixture)1 JOptionPaneFixture (org.fest.swing.fixture.JOptionPaneFixture)1 JTableCellFixture (org.fest.swing.fixture.JTableCellFixture)1 JTableFixture (org.fest.swing.fixture.JTableFixture)1 JTextComponentFixture (org.fest.swing.fixture.JTextComponentFixture)1