Skip to content

Commit

Permalink
clean up template and input editor
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Aug 11, 2022
1 parent 5fa252f commit fcef60e
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 37 deletions.
20 changes: 10 additions & 10 deletions fxtemplates/SNAPP.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<beast version='2.0'
namespace='snap:beast.base.util:beast.base.math:beast.base.util:beast.base.math:beast.evolution:beast.base.evolution.alignment:snap.likelihood:beast.base.util:beast.base.math:beast.evolution:beast.base.math.distributions:beast.app.beauti'
namespace='snap:beast.base.util:beast.base.math:beast.base.util:beast.base.math:beast.evolution:beast.base.evolution.alignment:snap.likelihood:beast.base.util:beast.base.math:beast.evolution:beast.base.math.distributions:beastfx.app.beauti:beastfx.app.inputeditor:beast.base.inference'
templateinfo='template for SNP and AFLP data which automatically integrates out all lineage trees'>

<map name='connect'>beastfx.app.inputeditor.BeautiConnector</map>
<map name='subtemplate'>beastfx.app.inputeditor.BeautiSubTemplate</map>


<beauticonfig spec='BeautiConfig'
<beauticonfig spec='beastfx.app.inputeditor.BeautiConfig'
inputLabelMap='snap.MCMC.operator=Operators,
snap.MCMC.logger=Loggers,
beast.base.evolution.sitemodel.SiteModel.substModel=,
Expand Down Expand Up @@ -121,10 +121,10 @@
/>


<alignmentProvider id="Add Alignment" spec='BeautiAlignmentProvider' template='@SNAPPPartitionTemplate'/>
<alignmentProvider id="Add Alignment" spec='beastfx.app.inputeditor.BeautiAlignmentProvider' template='@SNAPPPartitionTemplate'/>


<partitiontemplate id='SNAPPPartitionTemplate' spec='BeautiSubTemplate' class='beast.base.evolution.likelihood.TreeLikelihood' mainid='mcmc'>
<partitiontemplate id='SNAPPPartitionTemplate' spec='beastfx.app.inputeditor.BeautiSubTemplate' class='beast.base.evolution.likelihood.TreeLikelihood' mainid='mcmc'>
<![CDATA[
<data spec='snap.Data' id='snap.$(n)' dataType='integerdata'>
Expand All @@ -150,7 +150,7 @@
<snaptreelikelihood spec='snap.likelihood.SnAPTreeLikelihood' name='distribution' id='treeLikelihood.$(n)' initFromTree='false' pattern='coalescenceRate' non-polymorphic='true'>
<siteModel spec='sitemodel.SiteModel' id="MutationSiteModel.$(n)">
<siteModel spec='beast.base.evolution.sitemodel.SiteModel' id="MutationSiteModel.$(n)">
<parameter name='mutationRate' id='mutationRate' value='1.0' estimate='false'/>
<parameter name='proportionInvariant' id='proportionInvariant' value='0.0' estimate='false'/>
<parameter name='shape' value='2.0' id='shape' estimate='false'/>
Expand Down Expand Up @@ -193,7 +193,7 @@
<log id='TreeHeightLogger' spec='beast.base.evolution.tree.TreeHeightLogger' tree='@Tree.$(n)'/>
<logger spec='Logger' logEvery='1000' fileName='snap.trees' mode='tree' id='treelog'>
<log id='TreeWithMetaDataLogger.$(n)' spec='beast.base.evolution.tree.TreeWithMetaDataLogger' tree='@Tree.$(n)'>
<log id='TreeWithMetaDataLogger.$(n)' spec='beast.base.evolution.TreeWithMetaDataLogger' tree='@Tree.$(n)'>
<metadata spec='snap.RateToTheta' id='theta' coalescenceRate='@coalescenceRate'/>
</log>
</logger>
Expand Down Expand Up @@ -263,7 +263,7 @@
<!-- Tree initialisation -->
<!-- Random tree -->

<subtemplate id='RandomTree' spec='BeautiSubTemplate' class='beast.base.evolution.tree.coalescent.RandomTree' mainid='RandomTree.$(n)'>
<subtemplate id='RandomTree' spec='beastfx.app.inputeditor.BeautiSubTemplate' class='beast.base.evolution.tree.coalescent.RandomTree' mainid='RandomTree.$(n)'>
<![CDATA[
<tree spec='beast.base.evolution.tree.coalescent.RandomTree' id='RandomTree.$(n)' estimate='false' trait='@datetrait.$(n)'>
<taxa spec='Alignment' idref='data'/>
Expand All @@ -276,14 +276,14 @@

<!-- Cluster tree (for UPGMA) -->

<subtemplate id='UPGMATree' spec='BeautiSubTemplate' class='beast.base.evolution.tree.ClusterTree' mainid='UPGMATree.$(n)'>
<subtemplate id='UPGMATree' spec='beastfx.app.inputeditor.BeautiSubTemplate' class='beast.base.evolution.tree.ClusterTree' mainid='UPGMATree.$(n)'>
<![CDATA[
<tree spec='beast.base.evolution.tree.ClusterTree' id='UPGMATree.$(n)' clusterType='upgma' estimate='false' trait='@datetrait.$(n)' taxa='@$(n)'/>
]]>
</subtemplate>

<!-- Newick tree -->
<subtemplate id='NewickTree' spec='BeautiSubTemplate' class='beast.base.evolution.tree.ClusterTree' mainid='NewickTree.$(n)'>
<subtemplate id='NewickTree' spec='beastfx.app.inputeditor.BeautiSubTemplate' class='beast.base.evolution.tree.ClusterTree' mainid='NewickTree.$(n)'>
<![CDATA[
<tree spec='beast.base.evolution.tree.TreeParser' id='NewickTree.$(n)' estimate='false' trait='@datetrait.$(n)' taxa='@$(n)' newick=""/>
]]>
Expand Down Expand Up @@ -416,7 +416,7 @@
<logger id='screenlog' logEvery="1000">
<!--model idref='posterior'/-->
<log idref="posterior"/>
<ESS spec='ESS' name='log' arg="@posterior"/>
<ESS spec='beast.base.inference.util.ESS' name='log' arg="@posterior"/>
<log idref="likelihood"/>
<log idref="prior"/>
</logger>
Expand Down
76 changes: 49 additions & 27 deletions src/snap/app/inputeditor/DataInputEditor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@





import java.util.*;
import java.util.regex.PatternSyntaxException;


import beastfx.app.inputeditor.BeautiDoc;
import beastfx.app.inputeditor.GuessPatternDialog;
import beastfx.app.inputeditor.InputEditor;
import beastfx.app.inputeditor.TaxonSetInputEditor.TaxonMap;
import beastfx.app.util.FXUtils;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
Expand All @@ -22,6 +24,7 @@
import javafx.scene.control.Tooltip;
import javafx.scene.control.TableColumn.CellEditEvent;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
Expand All @@ -39,7 +42,6 @@ public DataInputEditor(BeautiDoc doc) {
super(doc);
}

private static final long serialVersionUID = 1L;
List<TaxonSet> m_taxonset;
List<Taxon> m_lineageset;
Map<String,String> m_taxonMap;
Expand Down Expand Up @@ -102,11 +104,11 @@ private Pane getContent(List<TaxonSet> taxonset) {
}
}

taxonMapping = FXCollections.observableArrayList();
// set up table.
// special features: background shading of rows
// custom editor allowing only Date column to be edited.
taxonSetToModel();


// set up table.
// special features: background shading of rows
Expand All @@ -123,35 +125,50 @@ private Pane getContent(List<TaxonSet> taxonset) {
new PropertyValueFactory<TaxonMap,String>("Taxon")
);
m_table.getColumns().add(col1);
col1.getSortNode().setOnMouseClicked(e -> {
// The index of the column whose header was clicked
int vColIndex = 0;
if (vColIndex != m_sortByColumn) {
m_sortByColumn = vColIndex;
m_bIsAscending = true;
} else {
m_bIsAscending = !m_bIsAscending;
}
taxonSetToModel();
});
// col1.getSortNode().setOnMouseClicked(e -> {
// // The index of the column whose header was clicked
// int vColIndex = 0;
// if (vColIndex != m_sortByColumn) {
// m_sortByColumn = vColIndex;
// m_bIsAscending = true;
// } else {
// m_bIsAscending = !m_bIsAscending;
// }
// taxonSetToModel();
// });

TableColumn<TaxonMap, String> col2 = new TableColumn<>("Species/Population");
col2.setPrefWidth(500);
col2.setEditable(true);
col2.setCellValueFactory(
new PropertyValueFactory<TaxonMap,String>("Taxon2")
);
col2.getSortNode().setOnMouseClicked(e -> {
// The index of the column whose header was clicked
int vColIndex = 1;
if (vColIndex != m_sortByColumn) {
m_sortByColumn = vColIndex;
m_bIsAscending = true;
} else {
m_bIsAscending = !m_bIsAscending;
}
taxonSetToModel();
});
col2.setCellFactory(TextFieldTableCell.forTableColumn());
col2.setOnEditCommit(
new EventHandler<CellEditEvent<TaxonMap, String>>() {
@Override
public void handle(CellEditEvent<TaxonMap, String> event) {
String newValue = event.getNewValue();
TaxonMap location = event.getRowValue();
location.taxon2 = newValue;
modelToTaxonset();
m_table.refresh();
validateInput();
}
}
);

// col2.getSortNode().setOnMouseClicked(e -> {
// // The index of the column whose header was clicked
// int vColIndex = 1;
// if (vColIndex != m_sortByColumn) {
// m_sortByColumn = vColIndex;
// m_bIsAscending = true;
// } else {
// m_bIsAscending = !m_bIsAscending;
// }
// taxonSetToModel();
// });
m_table.getColumns().add(col2);
m_table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

Expand Down Expand Up @@ -415,7 +432,10 @@ private void taxonSetToModel() {
i++;
}
}

if (taxonMapping == null) {
return;
}

// clear table model
taxonMapping.clear();

Expand All @@ -442,7 +462,9 @@ private void taxonSetToModel() {
// }
// }
// });
m_table.refresh();
if (m_table != null) {
m_table.refresh();
}
}


Expand Down

0 comments on commit fcef60e

Please sign in to comment.