final boolean phyloxml_validate_against_xsd,
final boolean replace_underscores,
final boolean internal_numbers_are_confidences,
- final TAXONOMY_EXTRACTION taxonomy_extraction )
- throws FileNotFoundException, IOException {
+ final TAXONOMY_EXTRACTION taxonomy_extraction,
+ final boolean midpoint_reroot ) throws FileNotFoundException,
+ IOException {
final PhylogenyFactory factory = ParserBasedPhylogenyFactory.getInstance();
final PhylogenyParser parser;
boolean nhx_or_nexus = false;
PhylogenyMethods.transferInternalNodeNamesToConfidence( phy );
}
}
+ if ( midpoint_reroot ) {
+ for( final Phylogeny phy : phys ) {
+ PhylogenyMethods.midpointRoot( phy );
+ }
+ }
return phys;
}
import javax.swing.JApplet;
import javax.swing.UIManager;
-import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
import org.forester.phylogeny.Phylogeny;
import org.forester.util.ForesterUtil;
setTreeUrlStr( getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ) );
setSpeciesTreeUrlStr( getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_SPECIES_TREE_TO_LOAD ) );
if ( !ForesterUtil.isEmpty( getTreeUrlStr() ) ) {
- AptxUtil.printAppletMessage( NAME, "URL of tree(s) to load: \"" + getTreeUrlStr() + "\"" );
+ AptxUtil.printAppletMessage( NAME, "URL of tree(s) to load: " + getTreeUrlStr() );
}
else {
ForesterUtil.printErrorMessage( NAME, "no URL for tree(s) to load!" );
repaint();
}
if ( !ForesterUtil.isEmpty( getSpeciesTreeUrlStr() ) ) {
- AptxUtil.printAppletMessage( NAME, "URL of species tree to load: \"" + getSpeciesTreeUrlStr() + "\"" );
+ AptxUtil.printAppletMessage( NAME, "URL of species tree to load: " + getSpeciesTreeUrlStr() );
}
setBackground( background_color );
setForeground( font_color );
UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
}
setVisible( false );
- _mainframe_applet = new MainFrameApplet( this, configuration );
+ _mainframe_applet = new MainFrameApplet( this, configuration, getSpeciesTreeUrlStr() );
final URL tree_url = new URL( getTreeUrlStr() );
final Phylogeny[] phys = AptxUtil.readPhylogeniesFromUrl( tree_url, configuration
.isValidatePhyloXmlAgainstSchema(), configuration.isReplaceUnderscoresInNhParsing(), configuration
- .isInternalNumberAreConfidenceForNhParsing(), configuration.getTaxonomyExtraction() );
+ .isInternalNumberAreConfidenceForNhParsing(), configuration.getTaxonomyExtraction(), configuration
+ .isMidpointReroot() );
+ AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "loaded " + phys.length + " phylogenies from: "
+ + tree_url );
AptxUtil.addPhylogeniesToTabs( phys,
new File( tree_url.getFile() ).getName(),
getTreeUrlStr(),
getMainFrameApplet().getConfiguration(),
getMainFrameApplet().getMainPanel() );
- if ( !ForesterUtil.isEmpty( getSpeciesTreeUrlStr() ) ) {
- final URL species_tree_url = new URL( getSpeciesTreeUrlStr() );
- final Phylogeny[] species_trees = AptxUtil
- .readPhylogeniesFromUrl( species_tree_url,
- configuration.isValidatePhyloXmlAgainstSchema(),
- configuration.isReplaceUnderscoresInNhParsing(),
- false,
- TAXONOMY_EXTRACTION.NO );
- if ( ( species_trees != null ) && ( species_trees.length > 0 ) ) {
- AptxUtil.printAppletMessage( NAME, "successfully read species tree" );
- if ( species_trees[ 0 ].isEmpty() ) {
- ForesterUtil.printErrorMessage( NAME, "species tree is empty" );
- }
- else if ( !species_trees[ 0 ].isRooted() ) {
- ForesterUtil.printErrorMessage( NAME, "species tree is not rooted" );
- }
- else {
- getMainFrameApplet().setSpeciesTree( species_trees[ 0 ] );
- }
- }
- else {
- ForesterUtil.printErrorMessage( NAME, "failed to read species tree from " + getSpeciesTreeUrlStr() );
- }
- }
getMainFrameApplet().getMainPanel().getControlPanel().showWholeAll();
getMainFrameApplet().getMainPanel().getControlPanel().showWhole();
setVisible( true );
getConfiguration().isValidatePhyloXmlAgainstSchema(),
getConfiguration().isReplaceUnderscoresInNhParsing(),
getConfiguration().isInternalNumberAreConfidenceForNhParsing(),
- getConfiguration().getTaxonomyExtraction() );
+ getConfiguration().getTaxonomyExtraction(),
+ getConfiguration().isMidpointReroot() );
}
catch ( final Exception e ) {
ForesterUtil.printErrorMessage( NAME, e.toString() );
configuration.isValidatePhyloXmlAgainstSchema(),
configuration.isReplaceUnderscoresInNhParsing(),
false,
- TAXONOMY_EXTRACTION.NO );
+ TAXONOMY_EXTRACTION.NO,
+ false );
}
catch ( final IOException e ) {
ForesterUtil.printErrorMessage( NAME, "could not read species tree from [" + species_tree_url_str
}
else {
setSpeciesTree( species_trees[ 0 ] );
+ AptxUtil.printAppletMessage( NAME, "species tree OK" );
}
}
}
}
else {
AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
+ if ( getSpeciesTree() != null ) {
+ AptxUtil.printAppletMessage( NAME,
+ "Warning: gsdi (gene duplication inference) only available tabbed display" );
+ }
AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
}
validate();
private EXT_NODE_DATA_RETURN_ON _ext_node_data_return_on = EXT_NODE_DATA_RETURN_ON.WINODW;
private int _frame_x_size;
private int _frame_y_size;
+ private boolean _midpoint_root = false;
private static String DEFAULT_FONT_FAMILY = "";
static {
for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) {
else if ( name.equals( "color_subtree" ) ) {
index = Configuration.color_subtree;
}
- else if ( name.equals( "go_to_swiss_prot" ) ) {
- ForesterUtil.printWarningMessage( Constants.PRG_NAME, "configuration key [go_to_swiss_prot] is deprecated" );
- return DEPRECATED;
- }
return index;
}
else if ( key.equals( "taxonomy_colorize_node_shapes" ) ) {
setTaxonomyColorizeNodeShapes( parseBoolean( ( String ) st.nextElement() ) );
}
+ else if ( key.equals( "midpoint_reroot" ) ) {
+ setMidpointReroot( parseBoolean( ( String ) st.nextElement() ) );
+ }
else if ( key.equals( "ext_descendents_data_to_return" ) ) {
final String s = ( ( String ) st.nextElement() ).trim();
if ( s.equalsIgnoreCase( "node_name" ) ) {
static enum TRIPLET {
TRUE, FALSE, UNKNOWN
}
+
+ public boolean isMidpointReroot() {
+ return _midpoint_root;
+ }
+
+ public void setMidpointReroot( final boolean midpoint_root ) {
+ _midpoint_root = midpoint_root;
+ }
}
public final static boolean __SYNTH_LF = false; // TODO remove me
public final static boolean ALLOW_DDBJ_BLAST = false;
public final static String PRG_NAME = "Archaeopteryx";
- final static String VERSION = "0.9806 A1ST";
- final static String PRG_DATE = "130308";
+ final static String VERSION = "0.9807 A1ST";
+ final static String PRG_DATE = "130311";
final static String DEFAULT_CONFIGURATION_FILE_NAME = "_aptx_configuration_file";
final static String[] DEFAULT_FONT_CHOICES = { "Verdana", "Tahoma",
"Arial", "Helvetica", "Dialog", "Lucida Sans", "SansSerif", "Sans-serif", "Sans" };
Configuration _configuration;
JMenuItem _remove_branch_color_item;
Options _options;
- Phylogeny _species_tree;
+ private Phylogeny _species_tree;
InferenceManager _inference_manager;
final ProcessPool _process_pool;
private String _previous_node_annotation_ref;
gene_tree.setAllNodesToNotCollapse();
gene_tree.recalculateNumberOfExternalDescendants( false );
GSDI gsdi = null;
- final Phylogeny species_tree = _species_tree.copy();
+ final Phylogeny species_tree = getSpeciesTree().copy();
try {
gsdi = new GSDI( gene_tree, species_tree, false, true, true );
}
gene_tree.setAllNodesToNotCollapse();
gene_tree.recalculateNumberOfExternalDescendants( false );
GSDIR gsdir = null;
- final Phylogeny species_tree = _species_tree.copy();
+ final Phylogeny species_tree = getSpeciesTree().copy();
try {
gsdir = new GSDIR( gene_tree, species_tree, true, true );
}
return _jmenubar;
}
+ final Phylogeny getSpeciesTree() {
+ return _species_tree;
+ }
+
void help() {
final StringBuilder sb = new StringBuilder();
sb.append( "Display options\n" );
if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
return false;
}
- else if ( ( _species_tree == null ) || _species_tree.isEmpty() ) {
+ else if ( ( getSpeciesTree() == null ) || getSpeciesTree().isEmpty() ) {
JOptionPane.showMessageDialog( this,
"No species tree loaded",
"Cannot execute GSDI",
JOptionPane.ERROR_MESSAGE );
return false;
}
- else if ( species_tree_has_to_binary && !_species_tree.isCompletelyBinary() ) {
+ else if ( species_tree_has_to_binary && !getSpeciesTree().isCompletelyBinary() ) {
JOptionPane.showMessageDialog( this,
"Species tree is not completely binary",
"Cannot execute GSDI",
}
}
+ final void setSpeciesTree( final Phylogeny species_tree ) {
+ _species_tree = species_tree;
+ }
+
void setTypeMenuToAllUnselected() {
_convex_type_cbmi.setSelected( false );
_curved_type_cbmi.setSelected( false );
import java.awt.event.ComponentEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.ButtonGroup;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
+import org.forester.io.parsers.nhx.NHXParser.TAXONOMY_EXTRACTION;
import org.forester.phylogeny.Phylogeny;
import org.forester.util.ForesterUtil;
private final ArchaeopteryxA _applet;
private ButtonGroup _radio_group_1;
- MainFrameApplet( final ArchaeopteryxA parent_applet, final Configuration configuration ) {
+ MainFrameApplet( final ArchaeopteryxA parent_applet,
+ final Configuration configuration,
+ final String species_tree_url_str ) {
setTitle( ArchaeopteryxA.NAME );
_applet = parent_applet;
setConfiguration( configuration );
setOptions( Options.createInstance( configuration ) );
- //_textframes = null; //~~~~
- URL url = null;
- Phylogeny[] phys = null;
- // Get URL to tree file
- if ( _applet.getTreeUrlStr() != null ) {
- try {
- url = new URL( _applet.getTreeUrlStr() );
- }
- catch ( final Exception e ) {
- ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, e.toString() );
- e.printStackTrace();
- JOptionPane.showMessageDialog( this,
- ArchaeopteryxA.NAME + ": Could not create URL from: \""
- + _applet.getTreeUrlStr() + "\"\nError: " + e,
- "Failed to create URL",
- JOptionPane.ERROR_MESSAGE );
- close();
- }
- }
- // Load the tree from URL
- if ( url != null ) {
+ _mainpanel = new MainPanelApplets( _configuration, this );
+ if ( !ForesterUtil.isEmpty( species_tree_url_str ) ) {
try {
- phys = AptxUtil.readPhylogeniesFromUrl( url,
- configuration.isValidatePhyloXmlAgainstSchema(),
- configuration.isReplaceUnderscoresInNhParsing(),
- configuration.isInternalNumberAreConfidenceForNhParsing(),
- configuration.getTaxonomyExtraction() );
+ readSpeciesTree( configuration, species_tree_url_str );
}
catch ( final Exception e ) {
+ ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "failed to read species tree from "
+ + species_tree_url_str );
ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, e.toString() );
- e.printStackTrace();
- JOptionPane.showMessageDialog( this, ArchaeopteryxA.NAME + ": Failed to read phylogenies: "
- + "\nError: " + e, "Failed to read phylogenies", JOptionPane.ERROR_MESSAGE );
- close();
}
}
- if ( ( phys == null ) || ( phys.length < 1 ) ) {
- ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "phylogenies from [" + url + "] are null or empty" );
- JOptionPane.showMessageDialog( this, ArchaeopteryxA.NAME + ": phylogenies from [" + url
- + "] are null or empty", "Failed to read phylogenies", JOptionPane.ERROR_MESSAGE );
- }
- else {
- AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "loaded " + phys.length + " phylogenies from: " + url );
- }
- _mainpanel = new MainPanelApplets( _configuration, this );
// build the menu bar
_jmenubar = new JMenuBar();
if ( !_configuration.isUseNativeUI() ) {
_jmenubar.setBackground( _configuration.getGuiMenuBackgroundColor() );
}
- if ( _species_tree != null ) {
+ if ( getSpeciesTree() != null ) {
buildAnalysisMenu();
}
buildToolsMenu();
System.gc();
}
+ private void readSpeciesTree( final Configuration configuration, final String species_tree_url_str )
+ throws MalformedURLException, FileNotFoundException, IOException {
+ final URL species_tree_url = new URL( species_tree_url_str );
+ final Phylogeny[] species_trees = AptxUtil.readPhylogeniesFromUrl( species_tree_url,
+ configuration
+ .isValidatePhyloXmlAgainstSchema(),
+ configuration
+ .isReplaceUnderscoresInNhParsing(),
+ false,
+ TAXONOMY_EXTRACTION.NO,
+ false );
+ if ( ( species_trees != null ) && ( species_trees.length > 0 ) ) {
+ AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "successfully read species tree" );
+ if ( species_trees[ 0 ].isEmpty() ) {
+ ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "species tree is empty" );
+ }
+ else if ( !species_trees[ 0 ].isRooted() ) {
+ ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "species tree is not rooted" );
+ }
+ else {
+ setSpeciesTree( species_trees[ 0 ] );
+ AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "species tree OK" );
+ }
+ }
+ else {
+ ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, "failed to read species tree from "
+ + species_tree_url_str );
+ }
+ }
+
@Override
public MainPanel getMainPanel() {
return _mainpanel;
void readPhylogeniesFromURL() {
throw new NoSuchMethodError( "not implemented" );
}
-
- void setSpeciesTree( final Phylogeny species_tree ) {
- _species_tree = species_tree;
- }
}
}
}
if ( !exception && ( t != null ) ) {
- _species_tree = t;
+ setSpeciesTree( t );
JOptionPane.showMessageDialog( this,
"Species tree successfully loaded",
"Species tree loaded",