public final class Configuration {
public enum EXT_NODE_DATA_RETURN_ON {
- CONSOLE, WINODW;
+ CONSOLE, WINODW, BUFFER_ONLY;
}
static final String VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA = "validate_against_phyloxml_xsd_schema";
private static final String WEB_LINK_KEY = "web_link";
else if ( s.equals( "window" ) ) {
setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.WINODW );
}
+ else if ( s.equals( "buffer_only" ) ) {
+ setExtNodeDataReturnOn( EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY );
+ }
else {
ForesterUtil.printWarningMessage( Constants.PRG_NAME, "unknown value [" + s
+ "] for [ext_descendents_data_to_return_on]" );
InferenceManager _inference_manager;
final ProcessPool _process_pool;
private String _previous_node_annotation_ref;
+ private String _ext_node_data_buffer = "";
MainFrame() {
_process_pool = ProcessPool.createInstance();
return _configuration;
}
+ /**
+ * This method returns the current external node data which
+ * has been selected by the user by clicking the "Return ..."
+ * menu item. This method is expected to be called from Javascript or
+ * something like it.
+ *
+ * @return current external node data as String
+ */
+ public String getCurrentExternalNodesDataBuffer() {
+ return _ext_node_data_buffer;
+ }
+
public InferenceManager getInferenceManager() {
return _inference_manager;
}
_configuration = configuration;
}
+ void setCurrentExternalNodesDataBuffer( final String s ) {
+ if ( !ForesterUtil.isEmpty( s ) ) {
+ _ext_node_data_buffer = s.trim();
+ }
+ else {
+ _ext_node_data_buffer = "";
+ }
+ }
+
void setInferenceManager( final InferenceManager i ) {
_inference_manager = i;
}
}
}
- private String getPreviousNodeAnnotationReference() {
- return _previous_node_annotation_ref;
- }
-
- private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {
- _previous_node_annotation_ref = previous_node_annotation_ref;
- }
-
private void chooseFont() {
final FontChooser fc = new FontChooser();
fc.setFont( getMainPanel().getTreeFontSet().getLargeFont() );
repaint();
}
+ private String getPreviousNodeAnnotationReference() {
+ return _previous_node_annotation_ref;
+ }
+
private void removeBranchColors() {
if ( getMainPanel().getCurrentPhylogeny() != null ) {
AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
}
}
+ private void setPreviousNodeAnnotationReference( final String previous_node_annotation_ref ) {
+ _previous_node_annotation_ref = previous_node_annotation_ref;
+ }
+
/**
* Display the about box.
*/
_analysis_menu = MainFrame.createMenu( "Analysis", getConfiguration() );
_analysis_menu.add( _gsdi_item = new JMenuItem( "GSDI (Generalized Speciation Duplication Inference)" ) );
_analysis_menu.add( _gsdir_item = new JMenuItem( "GSDIR (re-rooting)" ) );
-
_analysis_menu.addSeparator();
_analysis_menu.add( _root_min_dups_item = new JMenuItem( "Root by Minimizing Duplications | Height (SDI)" ) );
_analysis_menu.add( _root_min_cost_l_item = new JMenuItem( "Root by Minimizing Cost L | Height (SDI)" ) );
}
catch ( final Exception e ) {
JOptionPane.showMessageDialog( this, e.toString(), "Error during GSDI", JOptionPane.ERROR_MESSAGE );
- return;
+ return;
}
gene_tree.setRerootable( false );
_mainpanel.getCurrentTreePanel().setTree( gene_tree );
if ( !isOKforSDI( false, true ) ) {
return;
}
-
final Phylogeny gene_tree = _mainpanel.getCurrentPhylogeny().copy();
gene_tree.setAllNodesToNotCollapse();
gene_tree.recalculateNumberOfExternalDescendants( false );
GSDIR gsdir = null;
try {
- gsdir = new GSDIR( gene_tree, _species_tree.copy(), true, 1 );
+ gsdir = new GSDIR( gene_tree, _species_tree.copy(), true, 1 );
}
catch ( final Exception e ) {
JOptionPane.showMessageDialog( this, e.toString(), "Error during GSDIR", JOptionPane.ERROR_MESSAGE );
result_gene_tree.setRerootable( false );
result_gene_tree.clearHashIdToNodeMap();
result_gene_tree.recalculateNumberOfExternalDescendants( true );
-
-
- _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree" , null );
-
+ _mainpanel.addPhylogenyInNewTab( result_gene_tree, getConfiguration(), "gene tree", null );
//_mainpanel.getCurrentTreePanel().setTree( gene_tree );
-
- // _mainpanel.getCurrentTreePanel().setEdited( true );
+ // _mainpanel.getCurrentTreePanel().setEdited( true );
getControlPanel().setShowEvents( true );
showWhole();
final int selected = _mainpanel.getTabbedPane().getSelectedIndex();
+ "Potential duplications: " + gsdir.getSpeciationOrDuplicationEventsSum() + "\n" + "Speciations: "
+ gsdir.getSpeciationsSum(), "GSDI successfully completed", JOptionPane.INFORMATION_MESSAGE );
}
-
+
void executeFunctionAnalysis() {
if ( ( _mainpanel.getCurrentPhylogeny() == null ) || ( _mainpanel.getCurrentPhylogeny().isEmpty() ) ) {
return;
repaint();
}
+ private String createAnnotationString( final SortedSet<Annotation> ann ) {
+ final StringBuilder sb = new StringBuilder();
+ boolean first = true;
+ for( final Annotation a : ann ) {
+ if ( !first ) {
+ sb.append( "|" );
+ }
+ else {
+ first = false;
+ }
+ sb.append( a.asSimpleText() );
+ }
+ final String ann_str = sb.toString();
+ return ann_str;
+ }
+
final private String createASimpleTextRepresentationOfANode( final PhylogenyNode node ) {
final String tax = PhylogenyMethods.getSpecies( node );
String label = node.getName();
}
}
- private String createAnnotationString( final SortedSet<Annotation> ann ) {
- final StringBuilder sb = new StringBuilder();
- boolean first = true;
- for( final Annotation a : ann ) {
- if ( !first ) {
- sb.append( "|" );
- }
- else {
- first = false;
- }
- sb.append( a.asSimpleText() );
- }
- final String ann_str = sb.toString();
- return ann_str;
- }
-
final private void paintNodeDataUnrootedCirc( final Graphics2D g,
final PhylogenyNode node,
final boolean to_pdf,
+ getOptions().getExtDescNodeDataToReturn() );
}
} // for loop
- if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
+ if ( ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE )
+ || ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.BUFFER_ONLY ) ) {
+ final StringBuilder sb = new StringBuilder();
for( final String d : data ) {
if ( !ForesterUtil.isEmpty( d ) ) {
- System.out.println( d );
+ if ( getConfiguration().getExtNodeDataReturnOn() == EXT_NODE_DATA_RETURN_ON.CONSOLE ) {
+ System.out.println( d );
+ }
+ sb.append( d );
+ sb.append( ForesterUtil.LINE_SEPARATOR );
+ }
+ }
+ if ( sb.length() < 1 ) {
+ if ( getMainPanel().getMainFrame() == null ) {
+ // Must be "E" applet version.
+ ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() )
+ .setCurrentExternalNodesDataBuffer( "" );
+ }
+ else {
+ getMainPanel().getMainFrame().setCurrentExternalNodesDataBuffer( "" );
+ }
+ }
+ else {
+ final String s = sb.toString().trim();
+ if ( getMainPanel().getMainFrame() == null ) {
+ // Must be "E" applet version.
+ ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() )
+ .setCurrentExternalNodesDataBuffer( s );
+ }
+ else {
+ getMainPanel().getMainFrame().setCurrentExternalNodesDataBuffer( s );
}
}
}
for( final String d : data ) {
if ( !ForesterUtil.isEmpty( d ) ) {
sb.append( d );
- sb.append( "\n" );
+ sb.append( ForesterUtil.LINE_SEPARATOR );
}
}
if ( sb.length() < 1 ) {
AptxUtil.showInformationMessage( this,
"No Appropriate Data (" + obtainTitleForExtDescNodeData() + ")",
"Descendants of selected node do not contain selected data" );
+ if ( getMainPanel().getMainFrame() == null ) {
+ // Must be "E" applet version.
+ ( ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet() )
+ .setCurrentExternalNodesDataBuffer( "" );
+ }
+ else {
+ getMainPanel().getMainFrame().setCurrentExternalNodesDataBuffer( "" );
+ }
}
else {
final String title = "External Descendants "
+ ( getOptions().getExtDescNodeDataToReturn() == NODE_DATA.UNKNOWN ? "Data"
: obtainTitleForExtDescNodeData() ) + " (" + data.size() + "/"
+ node.getNumberOfExternalNodes() + ") For Node " + node;
+ final String s = sb.toString().trim();
if ( getMainPanel().getMainFrame() == null ) {
// Must be "E" applet version.
final ArchaeopteryxE ae = ( ArchaeopteryxE ) ( ( MainPanelApplets ) getMainPanel() ).getApplet();
- final String s = sb.toString().trim();
ae.showTextFrame( s, title );
ae.setCurrentExternalNodesDataBuffer( s );
}
else {
- getMainPanel().getMainFrame().showTextFrame( sb.toString(), title );
+ getMainPanel().getMainFrame().showTextFrame( s, title );
+ getMainPanel().getMainFrame().setCurrentExternalNodesDataBuffer( s );
}
}
}
}
final Phylogeny[] gene_trees = factory.create( gene_trees_file, p );
// Removes from species_tree all species not found in gene_tree.
- List<PhylogenyNode> _removed_gene_tree_nodes = PhylogenyMethods
+ final List<PhylogenyNode> _removed_gene_tree_nodes = PhylogenyMethods
.taxonomyBasedDeletionOfExternalNodes( gene_trees[ 0 ], species_tree );
if ( species_tree.isEmpty() ) {
throw new RIOException( "failed to establish species based mapping between gene and species trees" );
private final boolean _most_parsimonious_duplication_model;
private final boolean _strip_gene_tree;
private final boolean _strip_species_tree;
- protected int _speciation_or_duplication_events_sum;
- protected int _speciations_sum;
+ protected int _speciation_or_duplication_events_sum;
+ protected int _speciations_sum;
private final List<PhylogenyNode> _stripped_gene_tree_nodes;
private final List<PhylogenyNode> _stripped_species_tree_nodes;
private final Set<PhylogenyNode> _mapped_species_tree_nodes;
throws SDIException {
this( gene_tree, species_tree, most_parsimonious_duplication_model, false, false );
}
-
+
public GSDI( final Phylogeny gene_tree,
final Phylogeny species_tree,
final boolean most_parsimonious_duplication_model,
final boolean strip_gene_tree,
final boolean strip_species_tree,
- int x ) throws SDIException {
+ final int x ) throws SDIException {
super( gene_tree, species_tree );
_speciation_or_duplication_events_sum = 0;
_speciations_sum = 0;
_stripped_species_tree_nodes = new ArrayList<PhylogenyNode>();
_mapped_species_tree_nodes = new HashSet<PhylogenyNode>();
_scientific_names_mapped_to_reduced_specificity = new TreeSet<String>();
-
}
// s is the node on the species tree g maps to.
_duplications_sum = 0;\r
_speciation_or_duplication_events_sum = 0;\r
_speciations_sum = 0;\r
- \r
_gene_tree.reRoot( root.getId() ); //TODO reRoot( root )\r
PhylogenyMethods.preOrderReId( getSpeciesTree() );\r
//TEST, remove later\r
}\r
}\r
geneTreePostOrderTraversal();\r
- \r
- if ( _duplications_sum < _min_duplications_sum ) {\r
+ if ( _duplications_sum < _min_duplications_sum ) {\r
_min_duplications_sum = _duplications_sum;\r
_min_duplications_sum_gene_trees.clear();\r
_min_duplications_sum_gene_trees.add( getGeneTree().copy() );\r
}\r
- else if ( _duplications_sum == _min_duplications_sum ) {\r
+ else if ( _duplications_sum == _min_duplications_sum ) {\r
_min_duplications_sum_gene_trees.add( getGeneTree().copy() );\r
}\r
System.out.println( getDuplicationsSum() );\r
- _duplications_sum_stats.addValue( _duplications_sum );\r
+ _duplications_sum_stats.addValue( _duplications_sum );\r
}\r
}\r
\r
- \r
- \r
-\r
public int getMinDuplicationsSum() {\r
return _min_duplications_sum;\r
}\r
return _sum;
}
-
@Override
public String getSummaryAsString() {
validate();
return "" + mean + ( ( char ) 177 ) + sd + " [" + getMin() + "..." + getMax() + "]";
}
-
@Override
public double getValue( final int index ) {
validate();