import org.forester.util.ForesterUtil;
import org.forester.ws.uniprot.UniProtTaxonomy;
-public final class Util {
+public final class AptxUtil {
private final static String[] AVAILABLE_FONT_FAMILIES_SORTED = GraphicsEnvironment.getLocalGraphicsEnvironment()
.getAvailableFontFamilyNames();
return false;
}
+ public static void writePhylogenyToGraphicsFileNonInteractive( final File intree,
+ final File outfile,
+ final int width,
+ final int height,
+ final GraphicsExportType type,
+ final Configuration config ) throws IOException {
+ final PhylogenyParser parser = ParserUtils.createParserDependingOnFileType( intree, true );
+ Phylogeny[] phys = null;
+ phys = PhylogenyMethods.readPhylogenies( parser, intree );
+ final MainFrameApplication mf = MainFrameApplication.createInstance( phys, config );
+ AptxUtil.writePhylogenyToGraphicsFileNonInteractive( outfile, width, height, mf.getMainPanel()
+ .getCurrentTreePanel(), mf.getMainPanel().getControlPanel(), type, mf.getOptions() );
+ mf.end();
+ }
+
/**
* Returns true if at least one branch has a length larger than zero.
*
}
}
}
- first = Util.normalizeCharForRGB( first );
- second = Util.normalizeCharForRGB( second );
- third = Util.normalizeCharForRGB( third );
+ first = AptxUtil.normalizeCharForRGB( first );
+ second = AptxUtil.normalizeCharForRGB( second );
+ third = AptxUtil.normalizeCharForRGB( third );
if ( ( first > 235 ) && ( second > 235 ) && ( third > 235 ) ) {
first = 0;
}
if ( !n.isExternal() && !n.isCollapse() && ( n.getNumberOfDescendants() > 1 ) ) {
final Set<Taxonomy> taxs = PhylogenyMethods.obtainDistinctTaxonomies( n );
if ( ( taxs != null ) && ( taxs.size() == 1 ) ) {
- Util.collapseSubtree( n, true );
+ AptxUtil.collapseSubtree( n, true );
if ( !n.getNodeData().isHasTaxonomy() ) {
n.getNodeData().setTaxonomy( ( Taxonomy ) n.getAllExternalDescendants().get( 0 ).getNodeData()
.getTaxonomy().copy() );
final ControlPanel atv_control,
final Configuration configuration ) {
if ( ( t != null ) && !t.isEmpty() ) {
- if ( !Util.isHasAtLeastOneBranchLengthLargerThanZero( t ) ) {
+ if ( !AptxUtil.isHasAtLeastOneBranchLengthLargerThanZero( t ) ) {
atv_control.setDrawPhylogram( false );
atv_control.setDrawPhylogramEnabled( false );
}
if ( configuration.doGuessCheckOption( Configuration.display_as_phylogram ) ) {
if ( atv_control.getDisplayAsPhylogramCb() != null ) {
- if ( Util.isHasAtLeastOneBranchLengthLargerThanZero( t ) ) {
+ if ( AptxUtil.isHasAtLeastOneBranchLengthLargerThanZero( t ) ) {
atv_control.setDrawPhylogram( true );
atv_control.setDrawPhylogramEnabled( true );
}
}
if ( configuration.doGuessCheckOption( Configuration.write_confidence_values ) ) {
if ( atv_control.getWriteConfidenceCb() != null ) {
- if ( Util.isHasAtLeastOneBranchWithSupportValues( t ) ) {
+ if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( t ) ) {
atv_control.setCheckbox( Configuration.write_confidence_values, true );
}
else {
}
if ( configuration.doGuessCheckOption( Configuration.write_events ) ) {
if ( atv_control.getShowEventsCb() != null ) {
- if ( Util.isHasAtLeastNodeWithEvent( t ) ) {
+ if ( AptxUtil.isHasAtLeastNodeWithEvent( t ) ) {
atv_control.setCheckbox( Configuration.write_events, true );
}
else {
final static void openWebsite( final String url, final boolean is_applet, final JApplet applet ) throws IOException {
try {
- Util.launchWebBrowser( new URI( url ), is_applet, applet, Constants.PRG_NAME );
+ AptxUtil.launchWebBrowser( new URI( url ), is_applet, applet, Constants.PRG_NAME );
}
catch ( final Exception e ) {
throw new IOException( e );
return msg;
}
+ public final static void writePhylogenyToGraphicsFileNonInteractive( final File outfile,
+ final int width,
+ final int height,
+ final TreePanel tree_panel,
+ final ControlPanel ac,
+ final GraphicsExportType type,
+ final Options options ) throws IOException {
+ tree_panel.setParametersForPainting( width, height, true );
+ tree_panel.resetPreferredSize();
+ tree_panel.repaint();
+ final RenderingHints rendering_hints = new RenderingHints( RenderingHints.KEY_RENDERING,
+ RenderingHints.VALUE_RENDER_QUALITY );
+ rendering_hints.put( RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY );
+ if ( options.isAntialiasPrint() ) {
+ rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON );
+ rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
+ }
+ else {
+ rendering_hints.put( RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF );
+ rendering_hints.put( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF );
+ }
+ final Phylogeny phylogeny = tree_panel.getPhylogeny();
+ if ( ( phylogeny == null ) || phylogeny.isEmpty() ) {
+ return;
+ }
+ if ( outfile.isDirectory() ) {
+ throw new IOException( "\"" + outfile + "\" is a directory" );
+ }
+ //Rectangle visible = null;
+ final BufferedImage buffered_img = new BufferedImage( width, height, BufferedImage.TYPE_INT_RGB );
+ final Graphics2D g2d = buffered_img.createGraphics();
+ g2d.setRenderingHints( rendering_hints );
+ final int x = 0;
+ final int y = 0;
+ //if ( options.isGraphicsExportVisibleOnly() ) {
+ // g2d = ( Graphics2D ) g2d.create( -visible.x, -visible.y, visible.width, visible.height );
+ // g2d.setClip( null );
+ // x = visible.x;
+ // y = visible.y;
+ //}
+ tree_panel.paintPhylogeny( g2d, false, true, width, height, x, y );
+ if ( type == GraphicsExportType.TIFF ) {
+ writeToTiff( outfile, buffered_img );
+ }
+ else {
+ ImageIO.write( buffered_img, type.toString(), outfile );
+ }
+ g2d.dispose();
+ }
+
final static String writePhylogenyToGraphicsByteArrayOutputStream( final ByteArrayOutputStream baos,
int width,
int height,
// }
// br.close();
// }
- static enum GraphicsExportType {
+ public static enum GraphicsExportType {
GIF( "gif" ), JPG( "jpg" ), PDF( "pdf" ), PNG( "png" ), TIFF( "tif" ), BMP( "bmp" );
private final String _suffix;
try {
int filename_index = 0;
if ( args.length == 0 ) {
- conf = new Configuration( null, false, false );
+ conf = new Configuration( null, false, false, true );
}
else if ( args.length > 0 ) {
// check for a config file
if ( args[ 0 ].startsWith( "-open" ) ) {
filename_index += 1;
}
- conf = new Configuration( config_filename, false, false );
+ conf = new Configuration( config_filename, false, false, true );
if ( args.length > filename_index ) {
f = new File( args[ filename_index ] );
final String err = ForesterUtil.isReadableFile( f );
MainFrameApplication.createInstance( phylogenies, conf, title );
}
catch ( final Exception ex ) {
- Util.unexpectedException( ex );
+ AptxUtil.unexpectedException( ex );
}
catch ( final Error err ) {
- Util.unexpectedError( err );
+ AptxUtil.unexpectedError( err );
}
}
}
\ No newline at end of file
@Override
public void destroy() {
- Util.printAppletMessage( NAME, "going to be destroyed" );
+ AptxUtil.printAppletMessage( NAME, "going to be destroyed" );
if ( getMainFrameApplet() != null ) {
getMainFrameApplet().close();
}
boolean has_exception = false;
setName( NAME );
setUrlString( getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD ) );
- Util.printAppletMessage( NAME, "URL of phylogenies to load: \"" + getUrlString() + "\"" );
+ AptxUtil.printAppletMessage( NAME, "URL of phylogenies to load: \"" + getUrlString() + "\"" );
setBackground( background_color );
setForeground( font_color );
setFont( font );
repaint();
}
final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
- Util.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
- final Configuration configuration = new Configuration( config_filename, true, true );
+ AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
+ final Configuration configuration = new Configuration( config_filename, true, true, true );
try {
if ( configuration.isUseNativeUI() ) {
UIManager.setLookAndFeel( UIManager.getSystemLookAndFeelClassName() );
_mainframe_applet = new MainFrameApplet( this, configuration );
URL url = null;
url = new URL( getUrlString() );
- final Phylogeny[] phys = Util.readPhylogeniesFromUrl( url, configuration.isValidatePhyloXmlAgainstSchema() );
- Util.addPhylogeniesToTabs( phys, new File( url.getFile() ).getName(), getUrlString(), getMainFrameApplet()
- .getConfiguration(), getMainFrameApplet().getMainPanel() );
+ final Phylogeny[] phys = AptxUtil.readPhylogeniesFromUrl( url,
+ configuration.isValidatePhyloXmlAgainstSchema() );
+ AptxUtil.addPhylogeniesToTabs( phys,
+ new File( url.getFile() ).getName(),
+ getUrlString(),
+ getMainFrameApplet().getConfiguration(),
+ getMainFrameApplet().getMainPanel() );
getMainFrameApplet().getMainPanel().getControlPanel().showWholeAll();
getMainFrameApplet().getMainPanel().getControlPanel().showWhole();
setVisible( true );
if ( !has_exception ) {
setMessage1( NAME + " is now ready!" );
repaint();
- Util.printAppletMessage( NAME, "successfully initialized" );
+ AptxUtil.printAppletMessage( NAME, "successfully initialized" );
}
KeyboardFocusManager.getCurrentKeyboardFocusManager().clearGlobalFocusOwner();
getMainFrameApplet().requestFocus();
getMainFrameApplet().requestFocus();
getMainFrameApplet().requestFocusInWindow();
getMainFrameApplet().requestFocus();
- Util.printAppletMessage( NAME, "started" );
+ AptxUtil.printAppletMessage( NAME, "started" );
}
}
import javax.swing.event.ChangeListener;
import org.apache.commons.codec.binary.Base64;
+import org.forester.archaeopteryx.AptxUtil.GraphicsExportType;
import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
-import org.forester.archaeopteryx.Util.GraphicsExportType;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.data.SequenceRelation;
import org.forester.util.ForesterConstants;
}
else if ( o == _website_item ) {
try {
- Util.openWebsite( Constants.APTX_WEB_SITE, true, this );
+ AptxUtil.openWebsite( Constants.APTX_WEB_SITE, true, this );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
}
else if ( o == _phyloxml_website_item ) {
try {
- Util.openWebsite( Constants.PHYLOXML_WEB_SITE, true, this );
+ AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, true, this );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
}
else if ( o == _aptx_ref_item ) {
try {
- Util.openWebsite( Constants.APTX_REFERENCE_URL, true, this );
+ AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, true, this );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
}
else if ( o == _phyloxml_ref_item ) {
try {
- Util.openWebsite( Constants.PHYLOXML_REFERENCE_URL, true, this );
+ AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, true, this );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
public String getCurrentPhylogenyGraphicsAsBase64EncodedString( final String format ) {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
- Util.writePhylogenyToGraphicsByteArrayOutputStream( baos,
- _main_panel.getWidth(),
- _main_panel.getHeight(),
- getCurrentTreePanel(),
- getCurrentTreePanel().getControlPanel(),
- GraphicsExportType.valueOf( format ),
- getOptions() );
+ AptxUtil.writePhylogenyToGraphicsByteArrayOutputStream( baos,
+ _main_panel.getWidth(),
+ _main_panel.getHeight(),
+ getCurrentTreePanel(),
+ getCurrentTreePanel().getControlPanel(),
+ GraphicsExportType.valueOf( format ),
+ getOptions() );
}
catch ( final IOException ioe ) {
ForesterUtil.printErrorMessage( NAME, ioe.toString() );
@Override
public void destroy() {
- Util.printAppletMessage( NAME, "going to be destroyed " );
+ AptxUtil.printAppletMessage( NAME, "going to be destroyed " );
removeTextFrame();
if ( getMainPanel() != null ) {
getMainPanel().terminate();
@Override
public void init() {
final String config_filename = getParameter( Constants.APPLET_PARAM_NAME_FOR_CONFIG_FILE_URL );
- Util.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
- final Configuration configuration = new Configuration( config_filename, true, true );
+ AptxUtil.printAppletMessage( NAME, "URL for configuration file is: " + config_filename );
+ final Configuration configuration = new Configuration( config_filename, true, true, true );
setConfiguration( configuration );
setOptions( Options.createInstance( configuration ) );
setupUI();
URL phys_url = null;
Phylogeny[] phys = null;
final String phys_url_string = getParameter( Constants.APPLET_PARAM_NAME_FOR_URL_OF_TREE_TO_LOAD );
- Util.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string );
+ AptxUtil.printAppletMessage( NAME, "URL for phylogenies is " + phys_url_string );
// Get URL to tree file
if ( phys_url_string != null ) {
try {
// Load the tree from URL
if ( phys_url != null ) {
try {
- phys = Util.readPhylogeniesFromUrl( phys_url, getConfiguration().isValidatePhyloXmlAgainstSchema() );
+ phys = AptxUtil.readPhylogeniesFromUrl( phys_url, getConfiguration().isValidatePhyloXmlAgainstSchema() );
}
catch ( final Exception e ) {
ForesterUtil.printErrorMessage( NAME, e.toString() );
return;
}
else {
- Util.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
+ AptxUtil.printAppletMessage( NAME, "loaded " + phys.length + " phylogenies from: " + phys_url );
}
setVisible( false );
setMainPanel( new MainPanelApplets( getConfiguration(), this ) );
}
} );
if ( getConfiguration().isUseTabbedDisplay() ) {
- Util.printAppletMessage( NAME, "using tabbed display" );
- Util.addPhylogeniesToTabs( phys,
- new File( phys_url.getFile() ).getName(),
- phys_url.toString(),
- getConfiguration(),
- getMainPanel() );
+ AptxUtil.printAppletMessage( NAME, "using tabbed display" );
+ AptxUtil.addPhylogeniesToTabs( phys,
+ new File( phys_url.getFile() ).getName(),
+ phys_url.toString(),
+ getConfiguration(),
+ getMainPanel() );
}
else {
- Util.printAppletMessage( NAME, "not using tabbed display" );
- Util.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
+ AptxUtil.printAppletMessage( NAME, "not using tabbed display" );
+ AptxUtil.addPhylogenyToPanel( phys, getConfiguration(), getMainPanel() );
}
validate();
setName( NAME );
getMainPanel().getControlPanel().showWholeAll();
getMainPanel().getControlPanel().showWhole();
System.gc();
- Util.printAppletMessage( NAME, "successfully initialized" );
+ AptxUtil.printAppletMessage( NAME, "successfully initialized" );
/* GUILHEM_BEG */
getCurrentTreePanel().getControlPanel().getSequenceRelationTypeBox().removeAllItems();
for( final SequenceRelation.SEQUENCE_RELATION_TYPE type : getMainPanel().getCurrentPhylogeny()
private void removeBranchColors() {
if ( getMainPanel().getCurrentPhylogeny() != null ) {
- Util.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
+ AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
}
}
}
}
catch ( final UnsupportedLookAndFeelException e ) {
- Util.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
+ AptxUtil.dieWithSystemError( "UnsupportedLookAndFeelException: " + e.toString() );
}
catch ( final ClassNotFoundException e ) {
- Util.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
+ AptxUtil.dieWithSystemError( "ClassNotFoundException: " + e.toString() );
}
catch ( final InstantiationException e ) {
- Util.dieWithSystemError( "InstantiationException: " + e.toString() );
+ AptxUtil.dieWithSystemError( "InstantiationException: " + e.toString() );
}
catch ( final IllegalAccessException e ) {
- Util.dieWithSystemError( "IllegalAccessException: " + e.toString() );
+ AptxUtil.dieWithSystemError( "IllegalAccessException: " + e.toString() );
}
catch ( final Exception e ) {
- Util.dieWithSystemError( e.toString() );
+ AptxUtil.dieWithSystemError( e.toString() );
}
}
requestFocus();
requestFocusInWindow();
requestFocus();
- Util.printAppletMessage( NAME, "started" );
+ AptxUtil.printAppletMessage( NAME, "started" );
}
void switchColors() {
public final class Configuration {
- public enum UI {
- NATIVE, CROSSPLATFORM, NIMBUS, UNKNOWN
- }
static final String VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA = "validate_against_phyloxml_xsd_schema";
private static final String WEB_LINK_KEY = "web_link";
private static final String DISPLAY_COLOR_KEY = "display_color";
final static String display_options[][] = {
{ "Phylogram", "display", "?" }, { "Node Name", "display", "yes" }, { "Taxonomy Code", "display", "yes" },
{ "Annotation", "nodisplay", "no" }, { "Confidence Value", "display", "?" }, { "Event", "display", "?" },
- { "Taxonomy Colorize", "display", "yes" }, { "Colorize Branches", "display", "no" },
+ { "Taxonomy Colorize", "display", "no" }, { "Colorize Branches", "display", "no" },
{ "Use Branch-Widths", "display", "no" }, { "Show Custom Nodes", "display", "yes" },
{ "Domains", "nodisplay", "no" }, { "Binary Characters", "nodisplay", "no" },
{ "Binary Char Counts", "nodisplay", "no" }, { "Prot/Gene Name", "display", "yes" },
private static String DEFAULT_FONT_FAMILY = "";
static {
for( final String font_name : Constants.DEFAULT_FONT_CHOICES ) {
- if ( Arrays.binarySearch( Util.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
+ if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font_name ) >= 0 ) {
DEFAULT_FONT_FAMILY = font_name;
break;
}
}
}
- public Configuration( final String cf, final boolean is_url, final boolean is_applet ) {
+ public Configuration() {
+ this( null, false, false, false );
+ }
+
+ public Configuration( final String cf, final boolean is_url, final boolean is_applet, final boolean verbose ) {
if ( ForesterUtil.isEmpty( cf ) ) {
config_filename = default_config_filename;
}
bf.close();
}
catch ( final Exception e ) {
- ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
- + config_filename + "]: " + e );
+ if ( verbose ) {
+ ForesterUtil.printWarningMessage( Constants.PRG_NAME, "failed to read configuration from ["
+ + config_filename + "]: " + e );
+ }
}
}
else {
- ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
- + config_filename + "]" );
+ if ( verbose ) {
+ ForesterUtil.printWarningMessage( Constants.PRG_NAME, "cannot find or open configuration file ["
+ + config_filename + "]" );
+ }
}
}
}
}
}
- Color getGuiBackgroundColor() {
- return _gui_background_color;
- }
-
- Color getGuiCheckboxTextColor() {
- return _gui_checkbox_text_color;
- }
-
- Color getGuiCheckboxAndButtonActiveColor() {
- return _gui_checkbox_and_button_active_color;
- }
-
- Color getGuiButtonTextColor() {
- return _gui_button_text_color;
- }
-
- Color getGuiButtonBackgroundColor() {
- return _gui_button_background_color;
- }
-
- Color getGuiMenuBackgroundColor() {
- return _gui_menu_background_color;
- }
-
- Color getGuiMenuTextColor() {
- return _gui_menu_text_color;
- }
-
- Color getGuiButtonBorderColor() {
- return _gui_button_border_color;
- }
-
boolean displaySequenceRelations() {
return _display_sequence_relations;
}
return clickto_options[ which ][ 0 ];
}
+ public int getDefaultBootstrapSamples() {
+ return _default_bootstrap_samples;
+ }
+
int getDefaultDisplayClicktoOption() {
return default_clickto;
}
+ public NodeFill getDefaultNodeFill() {
+ return _default_node_fill;
+ }
+
+ public NodeShape getDefaultNodeShape() {
+ return _default_node_shape;
+ }
+
+ public short getDefaultNodeShapeSize() {
+ return _default_node_shape_size;
+ }
+
SortedMap<String, Color> getDisplayColors() {
return _display_colors;
}
return _domain_colors;
}
+ public Color getDomainStructureBaseColor() {
+ return _domain_structure_base_color;
+ }
+
+ public Color getDomainStructureFontColor() {
+ return _domain_structure_font_color;
+ }
+
int getGraphicsExportX() {
return _graphics_export_x;
}
return _graphics_export_y;
}
- public int getDefaultBootstrapSamples() {
- return _default_bootstrap_samples;
+ Color getGuiBackgroundColor() {
+ return _gui_background_color;
+ }
+
+ Color getGuiButtonBackgroundColor() {
+ return _gui_button_background_color;
+ }
+
+ Color getGuiButtonBorderColor() {
+ return _gui_button_border_color;
+ }
+
+ Color getGuiButtonTextColor() {
+ return _gui_button_text_color;
+ }
+
+ Color getGuiCheckboxAndButtonActiveColor() {
+ return _gui_checkbox_and_button_active_color;
+ }
+
+ Color getGuiCheckboxTextColor() {
+ return _gui_checkbox_text_color;
+ }
+
+ Color getGuiMenuBackgroundColor() {
+ return _gui_menu_background_color;
+ }
+
+ Color getGuiMenuTextColor() {
+ return _gui_menu_text_color;
}
double getMinConfidenceValue() {
return _weblinks;
}
+ public boolean isAbbreviateScientificTaxonNames() {
+ return _abbreviate_scientific_names;
+ }
+
boolean isAntialiasScreen() {
return _antialias_screen;
}
return _background_color_gradient;
}
+ public boolean isColorLabelsSameAsParentBranch() {
+ return _color_labels_same_as_parent_branch;
+ }
+
/**
* Convenience method.
*
return _show_branch_length_values;
}
+ public boolean isShowDefaultNodeShapes() {
+ return _show_default_node_shapes;
+ }
+
+ public boolean isShowDomainLabels() {
+ return _show_domain_labels;
+ }
+
boolean isShowOverview() {
return _show_overview;
}
return _show_scale;
}
+ public boolean isTaxonomyColorizeNodeShapes() {
+ return _taxonomy_colorize_node_shapes;
+ }
+
final boolean isUseNativeUI() {
- if ( ( _ui == UI.UNKNOWN ) && Util.isMac() && Util.isJava15() ) {
+ if ( ( _ui == UI.UNKNOWN ) && AptxUtil.isMac() && AptxUtil.isJava15() ) {
_ui = UI.NATIVE;
}
return _ui == UI.NATIVE;
final String[] fonts = font_str.split( ",+" );
for( String font : fonts ) {
font = font.replace( '_', ' ' ).trim();
- if ( Arrays.binarySearch( Util.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
+ if ( Arrays.binarySearch( AptxUtil.getAvailableFontFamiliesSorted(), font ) >= 0 ) {
setBaseFontFamilyName( font );
break;
}
}
}
+ public void putDisplayColors( final String key, final Color color ) {
+ getDisplayColors().put( key, color );
+ }
+
/**
* read each line of config file, process non-comment lines
* @throws IOException
} while ( line != null );
}
+ public void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
+ _abbreviate_scientific_names = abbreviate_scientific_names;
+ }
+
private void setAntialiasScreen( final boolean antialias_screen ) {
_antialias_screen = antialias_screen;
}
_background_color_gradient = background_color_gradient;
}
- private void setBaseFontFamilyName( final String base_font_family_name ) {
+ public void setBaseFontFamilyName( final String base_font_family_name ) {
_base_font_family_name = base_font_family_name;
}
- private void setBaseFontSize( final int base_font_size ) {
+ public void setBaseFontSize( final int base_font_size ) {
_base_font_size = base_font_size;
}
- private void setShowDomainLabels( final boolean show_domain_labels ) {
- _show_domain_labels = show_domain_labels;
+ private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
+ _cladogram_type = cladogram_type;
}
- private void setAbbreviateScientificTaxonNames( final boolean abbreviate_scientific_names ) {
- _abbreviate_scientific_names = abbreviate_scientific_names;
+ public void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
+ _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
}
- private void setColorLabelsSameAsParentBranch( final boolean color_labels_same_as_parent_branch ) {
- _color_labels_same_as_parent_branch = color_labels_same_as_parent_branch;
+ private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
+ _default_bootstrap_samples = default_bootstrap_samples;
}
- private void setCladogramType( final CLADOGRAM_TYPE cladogram_type ) {
- _cladogram_type = cladogram_type;
+ public void setDefaultNodeFill( final NodeFill default_node_fill ) {
+ _default_node_fill = default_node_fill;
+ }
+
+ public void setDefaultNodeShape( final NodeShape default_node_shape ) {
+ _default_node_shape = default_node_shape;
}
- void setDisplayColors( final SortedMap<String, Color> display_colors ) {
+ public void setDefaultNodeShapeSize( final short default_node_shape_size ) {
+ _default_node_shape_size = default_node_shape_size;
+ }
+
+ public void setDisplayColors( final SortedMap<String, Color> display_colors ) {
_display_colors = display_colors;
}
- private void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
+ public void setDisplaySequenceRelations( final boolean display_sequence_relations ) {
_display_sequence_relations = display_sequence_relations;
}
_editable = editable;
}
- private void setExtractPfamTaxonomyCodesInNhParsing( final boolean nh_parsing_extract_pfam_taxonomy_codes ) {
+ public void setExtractPfamTaxonomyCodesInNhParsing( final boolean nh_parsing_extract_pfam_taxonomy_codes ) {
_nh_parsing_extract_pfam_taxonomy_codes = nh_parsing_extract_pfam_taxonomy_codes;
}
_graphics_export_y = graphics_export_y;
}
- private void setDefaultBootstrapSamples( final int default_bootstrap_samples ) {
- _default_bootstrap_samples = default_bootstrap_samples;
- }
-
private void setInternalNumberAreConfidenceForNhParsing( final boolean internal_number_are_confidence_for_nh_parsing ) {
_internal_number_are_confidence_for_nh_parsing = internal_number_are_confidence_for_nh_parsing;
}
"configuration key [function_color] is deprecated" );
}
else if ( key.equals( DISPLAY_COLOR_KEY ) ) {
- getDisplayColors().put( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
+ putDisplayColors( ( String ) st.nextElement(), Color.decode( ( String ) st.nextElement() ) );
}
else if ( key.equals( WEB_LINK_KEY ) ) {
if ( st.countTokens() == 3 ) {
}
}
- private void setMinConfidenceValue( final double min_confidence_value ) {
+ public void setMinConfidenceValue( final double min_confidence_value ) {
_min_confidence_value = min_confidence_value;
}
- void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
+ public void setNodeLabelDirection( final NODE_LABEL_DIRECTION node_label_direction ) {
_node_label_direction = node_label_direction;
}
- private void setNumberOfDigitsAfterCommaForBranchLengthValue( final short _number_of_digits_after_comma_for_branch_length_values ) {
+ public void setNumberOfDigitsAfterCommaForBranchLengthValue( final short _number_of_digits_after_comma_for_branch_length_values ) {
this._number_of_digits_after_comma_for_branch_length_values = _number_of_digits_after_comma_for_branch_length_values;
}
- private void setNumberOfDigitsAfterCommaForConfidenceValues( final short _number_of_digits_after_comma_for_confidence_values ) {
+ public void setNumberOfDigitsAfterCommaForConfidenceValues( final short _number_of_digits_after_comma_for_confidence_values ) {
this._number_of_digits_after_comma_for_confidence_values = _number_of_digits_after_comma_for_confidence_values;
}
_ov_placement = ov_placement;
}
- void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
+ public void setPhylogenyGraphicsType( final PHYLOGENY_GRAPHICS_TYPE phylogeny_graphics_type ) {
_phylogeny_graphics_type = phylogeny_graphics_type;
}
- private void setPrintLineWidth( final float print_line_width ) {
+ public void setPrintLineWidth( final float print_line_width ) {
_print_line_width = print_line_width;
}
- private void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
+ public void setReplaceUnderscoresInNhParsing( final boolean nh_parsing_replace_underscores ) {
_nh_parsing_replace_underscores = nh_parsing_replace_underscores;
}
- private void setShowBranchLengthValues( final boolean show_branch_length_values ) {
+ public void setShowBranchLengthValues( final boolean show_branch_length_values ) {
_show_branch_length_values = show_branch_length_values;
}
+ public void setShowDefaultNodeShapes( final boolean show_default_node_shapes ) {
+ _show_default_node_shapes = show_default_node_shapes;
+ }
+
+ public void setShowDomainLabels( final boolean show_domain_labels ) {
+ _show_domain_labels = show_domain_labels;
+ }
+
private void setShowOverview( final boolean show_overview ) {
_show_overview = show_overview;
}
- private void setShowScale( final boolean show_scale ) {
+ public void setShowScale( final boolean show_scale ) {
_show_scale = show_scale;
}
+ public void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
+ _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
+ }
+
private void setValidatePhyloXmlAgainstSchema( final boolean validate_against_phyloxml_xsd_schema ) {
_validate_against_phyloxml_xsd_schema = validate_against_phyloxml_xsd_schema;
}
TRUE, FALSE, UNKNOWN
}
- public Color getDomainStructureFontColor() {
- return _domain_structure_font_color;
- }
-
- public Color getDomainStructureBaseColor() {
- return _domain_structure_base_color;
- }
-
- public boolean isColorLabelsSameAsParentBranch() {
- return _color_labels_same_as_parent_branch;
- }
-
- public boolean isShowDomainLabels() {
- return _show_domain_labels;
- }
-
- public boolean isAbbreviateScientificTaxonNames() {
- return _abbreviate_scientific_names;
- }
-
- public NodeShape getDefaultNodeShape() {
- return _default_node_shape;
- }
-
- private void setDefaultNodeShape( final NodeShape default_node_shape ) {
- _default_node_shape = default_node_shape;
- }
-
- private void setDefaultNodeFill( final NodeFill default_node_fill ) {
- _default_node_fill = default_node_fill;
- }
-
- public NodeFill getDefaultNodeFill() {
- return _default_node_fill;
- }
-
- private void setDefaultNodeShapeSize( final short default_node_shape_size ) {
- _default_node_shape_size = default_node_shape_size;
- }
-
- public short getDefaultNodeShapeSize() {
- return _default_node_shape_size;
- }
-
- private void setTaxonomyColorizeNodeShapes( final boolean taxonomy_colorize_node_shapes ) {
- _taxonomy_colorize_node_shapes = taxonomy_colorize_node_shapes;
- }
-
- public boolean isTaxonomyColorizeNodeShapes() {
- return _taxonomy_colorize_node_shapes;
- }
-
- public boolean isShowDefaultNodeShapes() {
- return _show_default_node_shapes;
- }
-
- private void setShowDefaultNodeShapes( final boolean show_default_node_shapes ) {
- _show_default_node_shapes = show_default_node_shapes;
+ public enum UI {
+ NATIVE, CROSSPLATFORM, NIMBUS, UNKNOWN
}
}
tp.requestFocus();
}
catch ( final Exception ex ) {
- Util.unexpectedException( ex );
+ AptxUtil.unexpectedException( ex );
}
catch ( final Error err ) {
- Util.unexpectedError( err );
+ AptxUtil.unexpectedError( err );
}
}
_zoom_in_y.setToolTipText( "To zoom in vertically [Shift+Up]" );
_zoom_out_x.setToolTipText( "To zoom out horizontally [Shift+Left]" );
_zoom_out_y.setToolTipText( "To zoom out vertically [Shift+Down]" );
- if ( getConfiguration().isUseNativeUI() && Util.isMac() ) {
+ if ( getConfiguration().isUseNativeUI() && AptxUtil.isMac() ) {
_zoom_out_x.setPreferredSize( new Dimension( 55, 10 ) );
_zoom_in_x.setPreferredSize( new Dimension( 55, 10 ) );
}
private String _type;
private int _style;
private int _size;
- private final JList _font_list = new JList( Util.getAvailableFontFamiliesSorted() );
+ private final JList _font_list = new JList( AptxUtil.getAvailableFontFamiliesSorted() );
private final JList _style_list = new JList( STYLE );
private final JList _size_list = new JList( SIZE );
private final JTextField _fonts_tf = new JTextField();
}
else if ( o == _website_item ) {
try {
- Util.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
+ AptxUtil.openWebsite( Constants.APTX_WEB_SITE, is_applet, applet );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
}
else if ( o == _phyloxml_website_item ) {
try {
- Util.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
+ AptxUtil.openWebsite( Constants.PHYLOXML_WEB_SITE, is_applet, applet );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
}
else if ( o == _aptx_ref_item ) {
try {
- Util.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
+ AptxUtil.openWebsite( Constants.APTX_REFERENCE_URL, is_applet, applet );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
}
else if ( o == _phyloxml_ref_item ) {
try {
- Util.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
+ AptxUtil.openWebsite( Constants.PHYLOXML_REFERENCE_URL, is_applet, applet );
}
catch ( final IOException e1 ) {
ForesterUtil.printErrorMessage( Constants.PRG_NAME, e1.toString() );
void colorRank() {
if ( _mainpanel.getCurrentTreePanel() != null ) {
- final String[] ranks = Util.getAllPossibleRanks();
+ final String[] ranks = AptxUtil.getAllPossibleRanks();
final String rank = ( String ) JOptionPane
.showInputDialog( this,
"What rank should the colorization be based on",
return _jmenubar;
}
- Options getOptions() {
+ public Options getOptions() {
return _options;
}
private void removeBranchColors() {
if ( getMainPanel().getCurrentPhylogeny() != null ) {
- Util.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
+ AptxUtil.removeBranchColors( getMainPanel().getCurrentPhylogeny() );
}
}
if ( ( _mainpanel.getCurrentPhylogeny() == null ) || _mainpanel.getCurrentPhylogeny().isEmpty() ) {
return;
}
- _textframe = TextFrame.instantiate( Util.crateBasicInformation( _mainpanel.getCurrentPhylogeny() ) );
+ _textframe = TextFrame.instantiate( AptxUtil.crateBasicInformation( _mainpanel.getCurrentPhylogeny() ) );
}
void viewAsNexus() {
if ( ( current_tree_panel == null ) || ( current_tree_panel.getPhylogeny() == null ) ) {
mi.setEnabled( true );
}
- else if ( Util.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
+ else if ( AptxUtil.isHasAtLeastOneBranchWithSupportValues( current_tree_panel.getPhylogeny() ) ) {
mi.setEnabled( true );
}
else {
// Load the tree from URL
if ( url != null ) {
try {
- phys = Util.readPhylogeniesFromUrl( url, getConfiguration().isValidatePhyloXmlAgainstSchema() );
+ phys = AptxUtil.readPhylogeniesFromUrl( url, getConfiguration().isValidatePhyloXmlAgainstSchema() );
}
catch ( final Exception e ) {
ForesterUtil.printErrorMessage( ArchaeopteryxA.NAME, e.toString() );
+ "] are null or empty", "Failed to read phylogenies", JOptionPane.ERROR_MESSAGE );
}
else {
- Util.printAppletMessage( ArchaeopteryxA.NAME, "loaded " + phys.length + " phylogenies from: " + url );
+ AptxUtil.printAppletMessage( ArchaeopteryxA.NAME, "loaded " + phys.length + " phylogenies from: " + url );
}
_mainpanel = new MainPanelApplets( _configuration, this );
// build the menu bar
import javax.swing.filechooser.FileFilter;
import javax.swing.plaf.synth.SynthLookAndFeel;
+import org.forester.archaeopteryx.AptxUtil.GraphicsExportType;
import org.forester.archaeopteryx.Options.CLADOGRAM_TYPE;
import org.forester.archaeopteryx.Options.NODE_LABEL_DIRECTION;
import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
-import org.forester.archaeopteryx.Util.GraphicsExportType;
import org.forester.archaeopteryx.tools.AncestralTaxonomyInferrer;
import org.forester.archaeopteryx.tools.GoAnnotation;
import org.forester.archaeopteryx.tools.PhyloInferenceDialog;
//UIManager.setLookAndFeel( "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" );
}
catch ( final UnsupportedLookAndFeelException e ) {
- Util.dieWithSystemError( "unsupported look and feel: " + e.toString() );
+ AptxUtil.dieWithSystemError( "unsupported look and feel: " + e.toString() );
}
catch ( final ClassNotFoundException e ) {
- Util.dieWithSystemError( "class not found exception: " + e.toString() );
+ AptxUtil.dieWithSystemError( "class not found exception: " + e.toString() );
}
catch ( final InstantiationException e ) {
- Util.dieWithSystemError( "instantiation exception: " + e.toString() );
+ AptxUtil.dieWithSystemError( "instantiation exception: " + e.toString() );
}
catch ( final IllegalAccessException e ) {
- Util.dieWithSystemError( "illegal access exception: " + e.toString() );
+ AptxUtil.dieWithSystemError( "illegal access exception: " + e.toString() );
}
catch ( final Exception e ) {
- Util.dieWithSystemError( e.toString() );
+ AptxUtil.dieWithSystemError( e.toString() );
}
// hide until everything is ready
setVisible( false );
// addKeyListener( this );
setVisible( true );
if ( ( phys != null ) && ( phys.length > 0 ) ) {
- Util.addPhylogeniesToTabs( phys, title, null, _configuration, _mainpanel );
+ AptxUtil.addPhylogeniesToTabs( phys, title, null, _configuration, _mainpanel );
validate();
getMainPanel().getControlPanel().showWholeAll();
getMainPanel().getControlPanel().showWhole();
System.gc();
}
+ private MainFrameApplication( final Phylogeny[] phys, final Configuration config ) {
+ _configuration = config;
+ if ( _configuration == null ) {
+ throw new IllegalArgumentException( "configuration is null" );
+ }
+ setVisible( false );
+ setOptions( Options.createInstance( _configuration ) );
+ _mainpanel = new MainPanel( _configuration, this );
+ _open_filechooser = null;
+ _open_filechooser_for_species_tree = null;
+ _save_filechooser = null;
+ _writetopdf_filechooser = null;
+ _writetographics_filechooser = null;
+ _msa_filechooser = null;
+ _seqs_filechooser = null;
+ _values_filechooser = null;
+ _jmenubar = new JMenuBar();
+ buildFileMenu();
+ buildTypeMenu();
+ _contentpane = getContentPane();
+ _contentpane.setLayout( new BorderLayout() );
+ _contentpane.add( _mainpanel, BorderLayout.CENTER );
+ // App is this big
+ setSize( MainFrameApplication.FRAME_X_SIZE, MainFrameApplication.FRAME_Y_SIZE );
+ // The window listener
+ setDefaultCloseOperation( WindowConstants.DO_NOTHING_ON_CLOSE );
+ addWindowListener( new WindowAdapter() {
+
+ @Override
+ public void windowClosing( final WindowEvent e ) {
+ exit();
+ }
+ } );
+ // setVisible( true );
+ if ( ( phys != null ) && ( phys.length > 0 ) ) {
+ AptxUtil.addPhylogeniesToTabs( phys, "", null, _configuration, _mainpanel );
+ validate();
+ getMainPanel().getControlPanel().showWholeAll();
+ getMainPanel().getControlPanel().showWhole();
+ }
+ //activateSaveAllIfNeeded();
+ // ...and its children
+ _contentpane.repaint();
+ }
+
private MainFrameApplication( final Phylogeny[] phys, final String config_file, final String title ) {
// Reads the config file (false, false => not url, not applet):
- this( phys, new Configuration( config_file, false, false ), title );
+ this( phys, new Configuration( config_file, false, false, true ), title );
}
@Override
_contentpane.repaint();
}
catch ( final Exception ex ) {
- Util.unexpectedException( ex );
+ AptxUtil.unexpectedException( ex );
}
catch ( final Error err ) {
- Util.unexpectedError( err );
+ AptxUtil.unexpectedError( err );
}
}
_save_all_item.setEnabled( false );
_file_jmenu.addSeparator();
_file_jmenu.add( _write_to_pdf_item = new JMenuItem( "Export to PDF file ..." ) );
- if ( Util.canWriteFormat( "tif" ) || Util.canWriteFormat( "tiff" ) || Util.canWriteFormat( "TIF" ) ) {
+ if ( AptxUtil.canWriteFormat( "tif" ) || AptxUtil.canWriteFormat( "tiff" ) || AptxUtil.canWriteFormat( "TIF" ) ) {
_file_jmenu.add( _write_to_tif_item = new JMenuItem( "Export to TIFF file..." ) );
}
_file_jmenu.add( _write_to_png_item = new JMenuItem( "Export to PNG file..." ) );
_file_jmenu.add( _write_to_jpg_item = new JMenuItem( "Export to JPG file..." ) );
- if ( Util.canWriteFormat( "gif" ) ) {
+ if ( AptxUtil.canWriteFormat( "gif" ) ) {
_file_jmenu.add( _write_to_gif_item = new JMenuItem( "Export to GIF file..." ) );
}
- if ( Util.canWriteFormat( "bmp" ) ) {
+ if ( AptxUtil.canWriteFormat( "bmp" ) ) {
_file_jmenu.add( _write_to_bmp_item = new JMenuItem( "Export to BMP file..." ) );
}
_file_jmenu.addSeparator();
System.exit( 0 );
}
+ public void end() {
+ _mainpanel.terminate();
+ _contentpane.removeAll();
+ setVisible( false );
+ dispose();
+ }
+
private void extractTaxCodeFromNodeNames() {
if ( getCurrentTreePanel() != null ) {
final Phylogeny phy = getCurrentTreePanel().getPhylogeny();
phy.setRoot( node );
phy.setRooted( true );
phys[ 0 ] = phy;
- Util.addPhylogeniesToTabs( phys, "", "", getConfiguration(), getMainPanel() );
+ AptxUtil.addPhylogeniesToTabs( phys, "", "", getConfiguration(), getMainPanel() );
_mainpanel.getControlPanel().showWhole();
_mainpanel.getCurrentTreePanel().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
_mainpanel.getOptions().setPhylogenyGraphicsType( PHYLOGENY_GRAPHICS_TYPE.RECTANGULAR );
}
}
}
- Util.addPhylogeniesToTabs( phys,
- file.getName(),
- file.getAbsolutePath(),
- getConfiguration(),
- getMainPanel() );
+ AptxUtil.addPhylogeniesToTabs( phys,
+ file.getName(),
+ file.getAbsolutePath(),
+ getConfiguration(),
+ getMainPanel() );
_mainpanel.getControlPanel().showWhole();
if ( nhx_or_nexus && one_desc ) {
JOptionPane
PhylogenyMethods.transferInternalNodeNamesToConfidence( phy );
}
}
- Util.addPhylogeniesToTabs( phys,
- new File( url.getFile() ).getName(),
- new File( url.getFile() ).toString(),
- getConfiguration(),
- getMainPanel() );
+ AptxUtil.addPhylogeniesToTabs( phys,
+ new File( url.getFile() ).getName(),
+ new File( url.getFile() ).toString(),
+ getConfiguration(),
+ getMainPanel() );
_mainpanel.getControlPanel().showWhole();
}
}
return exception;
}
- private void writePhylogenyToGraphicsFile( final String file_name, final GraphicsExportType type ) {
+ void writePhylogenyToGraphicsFile( final String file_name, final GraphicsExportType type ) {
_mainpanel.getCurrentTreePanel().setParametersForPainting( _mainpanel.getCurrentTreePanel().getWidth(),
_mainpanel.getCurrentTreePanel().getHeight(),
true );
String file_written_to = "";
boolean error = false;
try {
- file_written_to = Util.writePhylogenyToGraphicsFile( file_name,
- _mainpanel.getCurrentTreePanel().getWidth(),
- _mainpanel.getCurrentTreePanel().getHeight(),
- _mainpanel.getCurrentTreePanel(),
- _mainpanel.getControlPanel(),
- type,
- getOptions() );
+ file_written_to = AptxUtil.writePhylogenyToGraphicsFile( file_name,
+ _mainpanel.getCurrentTreePanel().getWidth(),
+ _mainpanel.getCurrentTreePanel().getHeight(),
+ _mainpanel.getCurrentTreePanel(),
+ _mainpanel.getControlPanel(),
+ type,
+ getOptions() );
}
catch ( final IOException e ) {
error = true;
return new MainFrameApplication( phys, config, title );
}
+ public static MainFrameApplication createInstance( final Phylogeny[] phys, final Configuration config ) {
+ return new MainFrameApplication( phys, config );
+ }
+
static MainFrame createInstance( final Phylogeny[] phys, final String config_file_name, final String title ) {
return new MainFrameApplication( phys, config_file_name, title );
}
return _configuration;
}
- ControlPanel getControlPanel() {
+ public ControlPanel getControlPanel() {
return _control_panel;
}
}
private List<Point> obtainPoints() {
- Util.ensurePresenceOfDistribution( getMyNode() );
+ AptxUtil.ensurePresenceOfDistribution( getMyNode() );
Distribution d = getMyNode().getNodeData().getDistribution();
if ( d.getPoints() == null ) {
d = new Distribution( d.getDesc(), new ArrayList<Point>(), d.getPolygons() );
}
break;
case TAXONOMY_CODE:
- Util.ensurePresenceOfTaxonomy( getMyNode() );
+ AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
try {
getMyNode().getNodeData().getTaxonomy().setTaxonomyCode( value );
}
}
break;
case TAXONOMY_SCIENTIFIC_NAME:
- Util.ensurePresenceOfTaxonomy( getMyNode() );
+ AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
getMyNode().getNodeData().getTaxonomy().setScientificName( value );
break;
case TAXONOMY_COMMON_NAME:
- Util.ensurePresenceOfTaxonomy( getMyNode() );
+ AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
getMyNode().getNodeData().getTaxonomy().setCommonName( value );
break;
case TAXONOMY_RANK:
- Util.ensurePresenceOfTaxonomy( getMyNode() );
+ AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
try {
getMyNode().getNodeData().getTaxonomy().setRank( value.toLowerCase() );
}
}
break;
case TAXONOMY_AUTHORITY:
- Util.ensurePresenceOfTaxonomy( getMyNode() );
+ AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
getMyNode().getNodeData().getTaxonomy().setAuthority( value );
break;
case TAXONOMY_URI: {
}
}
if ( uri != null ) {
- Util.ensurePresenceOfTaxonomy( getMyNode() );
+ AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
}
addUri( mtn, uri, number, getMyNode().getNodeData().getTaxonomy() );
break;
}
else if ( getMyNode().getNodeData().getTaxonomy().getSynonyms().size() == number ) {
if ( !ForesterUtil.isEmpty( value ) ) {
- Util.ensurePresenceOfTaxonomy( getMyNode() );
+ AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
getMyNode().getNodeData().getTaxonomy().getSynonyms().add( value );
}
}
}
break;
case TAXONOMY_ID_VALUE:
- Util.ensurePresenceOfTaxonomy( getMyNode() );
+ AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
if ( getMyNode().getNodeData().getTaxonomy().getIdentifier() == null ) {
getMyNode().getNodeData().getTaxonomy().setIdentifier( new Identifier( value ) );
}
}
break;
case TAXONOMY_ID_PROVIDER:
- Util.ensurePresenceOfTaxonomy( getMyNode() );
+ AptxUtil.ensurePresenceOfTaxonomy( getMyNode() );
if ( getMyNode().getNodeData().getTaxonomy().getIdentifier() == null ) {
getMyNode().getNodeData().getTaxonomy().setIdentifier( new Identifier( "", value ) );
}
}
break;
case SEQ_LOCATION:
- Util.ensurePresenceOfSequence( getMyNode() );
+ AptxUtil.ensurePresenceOfSequence( getMyNode() );
getMyNode().getNodeData().getSequence().setLocation( value );
break;
case SEQ_MOL_SEQ:
- Util.ensurePresenceOfSequence( getMyNode() );
+ AptxUtil.ensurePresenceOfSequence( getMyNode() );
getMyNode().getNodeData().getSequence().setMolecularSequence( value );
break;
case SEQ_NAME:
- Util.ensurePresenceOfSequence( getMyNode() );
+ AptxUtil.ensurePresenceOfSequence( getMyNode() );
getMyNode().getNodeData().getSequence().setName( value );
break;
case SEQ_SYMBOL:
- Util.ensurePresenceOfSequence( getMyNode() );
+ AptxUtil.ensurePresenceOfSequence( getMyNode() );
try {
getMyNode().getNodeData().getSequence().setSymbol( value );
}
}
break;
case SEQ_TYPE:
- Util.ensurePresenceOfSequence( getMyNode() );
+ AptxUtil.ensurePresenceOfSequence( getMyNode() );
try {
getMyNode().getNodeData().getSequence().setType( value.toLowerCase() );
}
}
break;
case SEQ_ACC_SOURCE:
- Util.ensurePresenceOfSequence( getMyNode() );
+ AptxUtil.ensurePresenceOfSequence( getMyNode() );
if ( getMyNode().getNodeData().getSequence().getAccession() == null ) {
getMyNode().getNodeData().getSequence().setAccession( new Accession( "", value ) );
}
}
break;
case SEQ_ACC_VALUE:
- Util.ensurePresenceOfSequence( getMyNode() );
+ AptxUtil.ensurePresenceOfSequence( getMyNode() );
if ( getMyNode().getNodeData().getSequence().getAccession() == null ) {
getMyNode().getNodeData().getSequence().setAccession( new Accession( value, "" ) );
}
}
}
if ( uri != null ) {
- Util.ensurePresenceOfSequence( getMyNode() );
+ AptxUtil.ensurePresenceOfSequence( getMyNode() );
}
addUri( mtn, uri, number, getMyNode().getNodeData().getSequence() );
break;
getMyNode().getNodeData().getEvent().setGeneLosses( parsePositiveInt( mtn, value ) );
break;
case DATE_DESCRIPTION:
- Util.ensurePresenceOfDate( getMyNode() );
+ AptxUtil.ensurePresenceOfDate( getMyNode() );
getMyNode().getNodeData().getDate().setDesc( value );
break;
case DATE_MAX:
- Util.ensurePresenceOfDate( getMyNode() );
+ AptxUtil.ensurePresenceOfDate( getMyNode() );
getMyNode().getNodeData().getDate().setMax( parseBigDecimal( mtn, value ) );
break;
case DATE_MIN:
- Util.ensurePresenceOfDate( getMyNode() );
+ AptxUtil.ensurePresenceOfDate( getMyNode() );
getMyNode().getNodeData().getDate().setMin( parseBigDecimal( mtn, value ) );
break;
case DATE_UNIT:
- Util.ensurePresenceOfDate( getMyNode() );
+ AptxUtil.ensurePresenceOfDate( getMyNode() );
getMyNode().getNodeData().getDate().setUnit( value );
break;
case DATE_VALUE:
- Util.ensurePresenceOfDate( getMyNode() );
+ AptxUtil.ensurePresenceOfDate( getMyNode() );
getMyNode().getNodeData().getDate().setValue( parseBigDecimal( mtn, value ) );
break;
case DIST_ALT: {
break;
}
case DIST_DESC: {
- Util.ensurePresenceOfDistribution( getMyNode() );
+ AptxUtil.ensurePresenceOfDistribution( getMyNode() );
final Distribution d = getMyNode().getNodeData().getDistribution();
getMyNode().getNodeData().setDistribution( new Distribution( value, d.getPoints(), d.getPolygons() ) );
break;
_editable = true;
_background_color_gradient = false;
_show_default_node_shapes = false;
- if ( Util.isUsOrCanada() ) {
+ if ( AptxUtil.isUsOrCanada() ) {
_print_size_x = Constants.US_LETTER_SIZE_X;
_print_size_y = Constants.US_LETTER_SIZE_Y;
}
return instance;
}
- static enum CLADOGRAM_TYPE {
+ public static enum CLADOGRAM_TYPE {
NON_LINED_UP, EXT_NODE_SUM_DEP, TOTAL_NODE_SUM_DEP;
}
- static enum NODE_LABEL_DIRECTION {
+ public static enum NODE_LABEL_DIRECTION {
HORIZONTAL, RADIAL;
}
}
}
- static enum PHYLOGENY_GRAPHICS_TYPE {
+ public static enum PHYLOGENY_GRAPHICS_TYPE {
RECTANGULAR, TRIANGULAR, EURO_STYLE, ROUNDED, CONVEX, CURVED, UNROOTED, CIRCULAR;
}
}
document.open();
final DefaultFontMapper mapper = new DefaultFontMapper();
FontFactory.registerDirectories();
- if ( Util.isWindows() ) {
+ if ( AptxUtil.isWindows() ) {
mapper.insertDirectory( "C:\\WINDOWS\\Fonts\\" );
}
- else if ( Util.isMac() ) {
+ else if ( AptxUtil.isMac() ) {
mapper.insertDirectory( "/Library/Fonts/" );
mapper.insertDirectory( "/System/Library/Fonts/" );
}
tree_panel.paintPhylogeny( g2, true, false, width, height, 0, 0 );
}
catch ( final Exception e ) {
- Util.unexpectedException( e );
+ AptxUtil.unexpectedException( e );
}
finally {
try {
/*
* Maintains the color schemes and a set of colors for drawing a tree.
*/
-final class TreeColorSet {
-
- static final String[] SCHEME_NAMES = { "Default", "Black", "Black & White", "Silver", "The Matrix",
- "White & Blue", "Cyan", "Clockwork", "Blue", "Blue & White", "Neon" };
- static final String[] COLOR_FIELDS = { "Background", "Background Gradient Bottom", "Sequence", "Taxonomy",
- "Confidence", "Branch Length", "Branch", "Node Box", "Collapsed", "Matching Nodes", "Duplication",
- "Speciation", "Duplication or Specation", "Domains", "Binary Domain Combinations", "Annotation", "Overview" };
+public final class TreeColorSet {
+
+ public static final String OVERVIEW = "Overview";
+ public static final String ANNOTATION = "Annotation";
+ public static final String BINARY_DOMAIN_COMBINATIONS = "Binary Domain Combinations";
+ public static final String DOMAINS = "Domains";
+ public static final String DUPLICATION_OR_SPECATION = "Duplication or Specation";
+ public static final String SPECIATION = "Speciation";
+ public static final String DUPLICATION = "Duplication";
+ public static final String MATCHING_NODES = "Matching Nodes";
+ public static final String COLLAPSED = "Collapsed";
+ public static final String NODE_BOX = "Node Box";
+ public static final String BRANCH = "Branch";
+ public static final String BRANCH_LENGTH = "Branch Length";
+ public static final String CONFIDENCE = "Confidence";
+ public static final String TAXONOMY = "Taxonomy";
+ public static final String SEQUENCE = "Sequence";
+ public static final String BACKGROUND_GRADIENT_BOTTOM = "Background Gradient Bottom";
+ public static final String BACKGROUND = "Background";
+ static final String[] SCHEME_NAMES = { "Default", "Black", "Black & White", "Silver",
+ "The Matrix", "White & Blue", "Cyan", "Clockwork", "Blue", "Blue & White", "Neon" };
+ static final String[] COLOR_FIELDS = { BACKGROUND, BACKGROUND_GRADIENT_BOTTOM, SEQUENCE,
+ TAXONOMY, CONFIDENCE, BRANCH_LENGTH, BRANCH, NODE_BOX, COLLAPSED, MATCHING_NODES, DUPLICATION, SPECIATION,
+ DUPLICATION_OR_SPECATION, DOMAINS, BINARY_DOMAIN_COMBINATIONS, ANNOTATION, OVERVIEW };
// All the color sets; better be the same # of sets as there are names!
- private final Color[][] _color_schemes = { { new Color( 0, 0, 0 ), // background_color
+ private final Color[][] _color_schemes = { { new Color( 0, 0, 0 ), // background_color
new Color( 0, 100, 100 ), // background_color_gradient_bottom
new Color( 220, 220, 220 ), // sequence __ Default (same as Black)
new Color( 180, 180, 180 ), // taxonomy
new Color( 123, 104, 238 ), // domains_color
new Color( 65, 105, 255 ), // binary_domain_combinations_color
new Color( 173, 255, 47 ) // annotation
- , new Color( 130, 130, 130 ) // overview
+ , new Color( 130, 130, 130 ) // overview
}, { new Color( 0, 0, 0 ), // background_color
new Color( 0, 255, 255 ), // background_color_gradient_bottom
new Color( 220, 220, 220 ), // sequence __ Black
new Color( 27, 255, 0 ), // binary_domain_combinations_color
new Color( 27, 255, 0 ) // annotation
, new Color( 77, 77, 255 ) // ov
- } };
+ } };
// Color schemes:
- private int _color_scheme;
+ private int _color_scheme;
// The drawing colors
- private Color seq_color;
- private Color taxonomy_color;
- private Color bootstrap_color;
- private Color branch_length_color;
- private Color branch_color;
- private Color box_color;
- private Color background_color;
- private Color background_color_gradient_bottom;
- private Color dup_box_color;
- private Color spec_box_color;
- private Color collapse_fill_color;
- private Color found_color;
- private Color duplication_or_specation_color;
- private Color domains_color;
- private Color binary_domain_combinations_color;
- private Color annotation_color;
- private Color ov_color;
+ private Color seq_color;
+ private Color taxonomy_color;
+ private Color bootstrap_color;
+ private Color branch_length_color;
+ private Color branch_color;
+ private Color box_color;
+ private Color background_color;
+ private Color background_color_gradient_bottom;
+ private Color dup_box_color;
+ private Color spec_box_color;
+ private Color collapse_fill_color;
+ private Color found_color;
+ private Color duplication_or_specation_color;
+ private Color domains_color;
+ private Color binary_domain_combinations_color;
+ private Color annotation_color;
+ private Color ov_color;
private TreeColorSet() {
// Hidden constructor.
_main_panel = tjp;
_configuration = configuration;
_phylogeny = t;
- _phy_has_branch_lengths = Util.isHasAtLeastOneBranchLengthLargerThanZero( _phylogeny );
+ _phy_has_branch_lengths = AptxUtil.isHasAtLeastOneBranchLengthLargerThanZero( _phylogeny );
init();
// if ( !_phylogeny.isEmpty() ) {
_phylogeny.recalculateNumberOfExternalDescendants( true );
// Look in species hash
Color c = getControlPanel().getSpeciesColors().get( species );
if ( c == null ) {
- c = Util.calculateColorFromString( species );
+ c = AptxUtil.calculateColorFromString( species );
getControlPanel().getSpeciesColors().put( species, c );
}
return c;
}
if ( !node.isExternal() && !node.isRoot() ) {
final boolean collapse = !node.isCollapse();
- Util.collapseSubtree( node, collapse );
+ AptxUtil.collapseSubtree( node, collapse );
updateSetOfCollapsedExternalNodes( _phylogeny );
_phylogeny.recalculateNumberOfExternalDescendants( true );
resetNodeIdToDistToLeafMap();
return;
}
setWaitCursor();
- Util.collapseSpeciesSpecificSubtrees( _phylogeny );
+ AptxUtil.collapseSpeciesSpecificSubtrees( _phylogeny );
updateSetOfCollapsedExternalNodes( _phylogeny );
_phylogeny.recalculateNumberOfExternalDescendants( true );
resetNodeIdToDistToLeafMap();
return;
}
setWaitCursor();
- Util.removeBranchColors( _phylogeny );
- Util.colorPhylogenyAccordingToConfidenceValues( _phylogeny, this );
+ AptxUtil.removeBranchColors( _phylogeny );
+ AptxUtil.colorPhylogenyAccordingToConfidenceValues( _phylogeny, this );
_control_panel.setColorBranches( true );
if ( _control_panel.getColorBranchesCb() != null ) {
_control_panel.getColorBranchesCb().setSelected( true );
return;
}
setWaitCursor();
- Util.removeBranchColors( _phylogeny );
- final int colorizations = Util.colorPhylogenyAccordingToRanks( _phylogeny, rank, this );
+ AptxUtil.removeBranchColors( _phylogeny );
+ final int colorizations = AptxUtil.colorPhylogenyAccordingToRanks( _phylogeny, rank, this );
if ( colorizations > 0 ) {
_control_panel.setColorBranches( true );
if ( _control_panel.getColorBranchesCb() != null ) {
return;
}
setWaitCursor();
- Util.inferCommonPartOfScientificNames( _phylogeny );
+ AptxUtil.inferCommonPartOfScientificNames( _phylogeny );
setArrowCursor();
repaint();
}
uri_str = url + URLEncoder.encode( seq.getAccession().getValue(), ForesterConstants.UTF8 );
}
catch ( final UnsupportedEncodingException e ) {
- Util.showErrorMessage( this, e.toString() );
+ AptxUtil.showErrorMessage( this, e.toString() );
e.printStackTrace();
}
if ( !ForesterUtil.isEmpty( uri_str ) ) {
if ( isApplet() ) {
applet = obtainApplet();
}
- Util.launchWebBrowser( new URI( uri_str ), isApplet(), applet, "_aptx_seq" );
+ AptxUtil.launchWebBrowser( new URI( uri_str ), isApplet(), applet, "_aptx_seq" );
}
catch ( final IOException e ) {
- Util.showErrorMessage( this, e.toString() );
+ AptxUtil.showErrorMessage( this, e.toString() );
e.printStackTrace();
}
catch ( final URISyntaxException e ) {
- Util.showErrorMessage( this, e.toString() );
+ AptxUtil.showErrorMessage( this, e.toString() );
e.printStackTrace();
}
}
uri_str = weblink.getUrl() + URLEncoder.encode( tax.getIdentifier().getValue(), ForesterConstants.UTF8 );
}
catch ( final UnsupportedEncodingException e ) {
- Util.showErrorMessage( this, e.toString() );
+ AptxUtil.showErrorMessage( this, e.toString() );
e.printStackTrace();
}
}
uri_str = new URI( tax.getIdentifier().getValue() ).toString();
}
catch ( final URISyntaxException e ) {
- Util.showErrorMessage( this, e.toString() );
+ AptxUtil.showErrorMessage( this, e.toString() );
uri_str = null;
e.printStackTrace();
}
+ URLEncoder.encode( tax.getScientificName(), ForesterConstants.UTF8 );
}
catch ( final UnsupportedEncodingException e ) {
- Util.showErrorMessage( this, e.toString() );
+ AptxUtil.showErrorMessage( this, e.toString() );
e.printStackTrace();
}
}
+ URLEncoder.encode( tax.getTaxonomyCode(), ForesterConstants.UTF8 );
}
catch ( final UnsupportedEncodingException e ) {
- Util.showErrorMessage( this, e.toString() );
+ AptxUtil.showErrorMessage( this, e.toString() );
e.printStackTrace();
}
}
+ URLEncoder.encode( tax.getCommonName(), ForesterConstants.UTF8 );
}
catch ( final UnsupportedEncodingException e ) {
- Util.showErrorMessage( this, e.toString() );
+ AptxUtil.showErrorMessage( this, e.toString() );
e.printStackTrace();
}
}
if ( isApplet() ) {
applet = obtainApplet();
}
- Util.launchWebBrowser( new URI( uri_str ), isApplet(), applet, "_aptx_tax" );
+ AptxUtil.launchWebBrowser( new URI( uri_str ), isApplet(), applet, "_aptx_tax" );
}
catch ( final IOException e ) {
- Util.showErrorMessage( this, e.toString() );
+ AptxUtil.showErrorMessage( this, e.toString() );
e.printStackTrace();
}
catch ( final URISyntaxException e ) {
- Util.showErrorMessage( this, e.toString() );
+ AptxUtil.showErrorMessage( this, e.toString() );
e.printStackTrace();
}
}
if ( ( to_pdf || to_graphics_file ) && getOptions().isPrintBlackAndWhite() ) {
outline_color = Color.BLACK;
}
- else if ( getControlPanel().isEvents() && Util.isHasAssignedEvent( node ) ) {
+ else if ( getControlPanel().isEvents() && AptxUtil.isHasAssignedEvent( node ) ) {
final Event event = node.getNodeData().getEvent();
if ( event.isDuplication() ) {
outline_color = getTreeColorSet().getDuplicationBoxColor();
* @param x
* @param y
*/
- final void setParametersForPainting( final int x, final int y, final boolean recalc_longest_ext_node_info ) {
+ public final void setParametersForPainting( final int x, final int y, final boolean recalc_longest_ext_node_info ) {
// updateStyle(); not needed?
if ( ( _phylogeny != null ) && !_phylogeny.isEmpty() ) {
initNodeData();
return;
}
setWaitCursor();
- Util.colorPhylogenyAccordingToExternalTaxonomy( _phylogeny, this );
+ AptxUtil.colorPhylogenyAccordingToExternalTaxonomy( _phylogeny, this );
_control_panel.setColorBranches( true );
if ( _control_panel.getColorBranchesCb() != null ) {
_control_panel.getColorBranchesCb().setSelected( true );
my_name_for_file = new String( sb.toString().replaceAll( " ", "_" ) );
}
_main_frame.getMainPanel().getCurrentTreePanel().setTreeFile( new File( my_name_for_file ) );
- Util.lookAtSomeTreePropertiesForAptxControlSettings( phylogeny, _main_frame.getMainPanel()
+ AptxUtil.lookAtSomeTreePropertiesForAptxControlSettings( phylogeny, _main_frame.getMainPanel()
.getControlPanel(), _main_frame.getConfiguration() );
_main_frame.getMainPanel().getControlPanel().showWhole();
}
import javax.imageio.ImageIO;
+import org.forester.archaeopteryx.AptxUtil;
import org.forester.archaeopteryx.Constants;
import org.forester.archaeopteryx.TreePanel;
-import org.forester.archaeopteryx.Util;
import org.forester.phylogeny.PhylogenyNode;
import org.forester.phylogeny.data.Taxonomy;
import org.forester.phylogeny.data.Uri;
bi = ImageIO.read( uri.getValue().toURL() );
}
catch ( final MalformedURLException e ) {
- Util.printWarningMessage( Constants.PRG_NAME, "\"" + uri.getValue()
+ AptxUtil.printWarningMessage( Constants.PRG_NAME, "\"" + uri.getValue()
+ "\": Malformed URL Exception: " + e.getLocalizedMessage() );
}
catch ( final IOException e ) {
- Util.printWarningMessage( Constants.PRG_NAME, "\"" + uri.getValue()
+ AptxUtil.printWarningMessage( Constants.PRG_NAME, "\"" + uri.getValue()
+ "\": IO Exception: " + e.getLocalizedMessage() );
}
if ( bi != null ) {
import javax.swing.border.Border;
import javax.swing.border.LineBorder;
+import org.forester.archaeopteryx.AptxUtil;
import org.forester.archaeopteryx.MainFrameApplication;
-import org.forester.archaeopteryx.Util;
import org.forester.evoinference.distance.PairwiseDistanceCalculator.PWD_DISTANCE_METHOD;
import org.forester.sequence.Sequence;
import org.forester.util.BasicDescriptiveStatistics;
bootstrap_pnl.setLayout( new FlowLayout() );
bootstrap_pnl.add( _bootstrap_cb = new JCheckBox( "Perform Bootstrap Resampling" ) );
bootstrap_pnl.add( new JLabel( "Number of Bootstrap Samples:" ) );
- bootstrap_pnl.add( _bootstrap_tf = new JFormattedTextField( Util.createMaskFormatter( "###" ) ) );
+ bootstrap_pnl.add( _bootstrap_tf = new JFormattedTextField( AptxUtil.createMaskFormatter( "###" ) ) );
_bootstrap_tf.setColumns( 4 );
// TODO see
// http://download.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import java.util.regex.Matcher;
import javax.swing.JOptionPane;
+import org.forester.archaeopteryx.AptxUtil;
import org.forester.archaeopteryx.MainFrameApplication;
import org.forester.evoinference.distance.NeighborJoining;
import org.forester.evoinference.distance.PairwiseDistanceCalculator;
import org.forester.msa.MsaTools;
import org.forester.msa.ResampleableMsa;
import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyNode;
+import org.forester.phylogeny.data.Accession;
+import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
import org.forester.sequence.Sequence;
import org.forester.tools.ConfidenceAssessor;
import org.forester.util.ForesterUtil;
}
final NeighborJoining nj = new NeighborJoining();
final Phylogeny phy = nj.execute( m );
- FastaParser.extractFastaInformation( phy );
+ PhylogeneticInferrer.extractFastaInformation( phy );
return phy;
}
}
}
}
+
+ public static void extractFastaInformation( final Phylogeny phy ) {
+ for( final PhylogenyNodeIterator iter = phy.iteratorExternalForward(); iter.hasNext(); ) {
+ final PhylogenyNode node = iter.next();
+ if ( !ForesterUtil.isEmpty( node.getName() ) ) {
+ final Matcher name_m = FastaParser.FASTA_DESC_LINE.matcher( node.getName() );
+ if ( name_m.lookingAt() ) {
+ System.out.println();
+ // System.out.println( name_m.group( 1 ) );
+ // System.out.println( name_m.group( 2 ) );
+ // System.out.println( name_m.group( 3 ) );
+ // System.out.println( name_m.group( 4 ) );
+ final String acc_source = name_m.group( 1 );
+ final String acc = name_m.group( 2 );
+ final String seq_name = name_m.group( 3 );
+ final String tax_sn = name_m.group( 4 );
+ if ( !ForesterUtil.isEmpty( acc_source ) && !ForesterUtil.isEmpty( acc ) ) {
+ AptxUtil.ensurePresenceOfSequence( node );
+ node.getNodeData().getSequence( 0 ).setAccession( new Accession( acc, acc_source ) );
+ }
+ if ( !ForesterUtil.isEmpty( seq_name ) ) {
+ AptxUtil.ensurePresenceOfSequence( node );
+ node.getNodeData().getSequence( 0 ).setName( seq_name );
+ }
+ if ( !ForesterUtil.isEmpty( tax_sn ) ) {
+ AptxUtil.ensurePresenceOfTaxonomy( node );
+ node.getNodeData().getTaxonomy( 0 ).setScientificName( tax_sn );
+ }
+ }
+ }
+ }
+ }
}
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.forester.archaeopteryx.Util;
import org.forester.msa.BasicMsa;
import org.forester.msa.Msa;
import org.forester.msa.MsaFormatException;
-import org.forester.phylogeny.Phylogeny;
-import org.forester.phylogeny.PhylogenyNode;
-import org.forester.phylogeny.data.Accession;
-import org.forester.phylogeny.iterators.PhylogenyNodeIterator;
import org.forester.sequence.BasicSequence;
import org.forester.sequence.Sequence;
-import org.forester.util.ForesterUtil;
public class FastaParser {
private static final Pattern SEQ_REGEX = Pattern.compile( "^\\s*(.+)" );
private static final Pattern ANYTHING_REGEX = Pattern.compile( "[\\d\\s]+" );
//>gi|71834668|ref|NP_001025424.1| Bcl2 [Danio rerio]
- private static final Pattern FASTA_DESC_LINE = Pattern
+ public static final Pattern FASTA_DESC_LINE = Pattern
.compile( ">?\\s*([^|]+)\\|([^|]+)\\S*\\s+(.+)\\s+\\[(.+)\\]" );
public static void main( final String[] args ) {
}
return line;
}
-
- public static void extractFastaInformation( final Phylogeny phy ) {
- for( final PhylogenyNodeIterator iter = phy.iteratorExternalForward(); iter.hasNext(); ) {
- final PhylogenyNode node = iter.next();
- if ( !ForesterUtil.isEmpty( node.getName() ) ) {
- final Matcher name_m = FASTA_DESC_LINE.matcher( node.getName() );
- if ( name_m.lookingAt() ) {
- System.out.println();
- // System.out.println( name_m.group( 1 ) );
- // System.out.println( name_m.group( 2 ) );
- // System.out.println( name_m.group( 3 ) );
- // System.out.println( name_m.group( 4 ) );
- final String acc_source = name_m.group( 1 );
- final String acc = name_m.group( 2 );
- final String seq_name = name_m.group( 3 );
- final String tax_sn = name_m.group( 4 );
- if ( !ForesterUtil.isEmpty( acc_source ) && !ForesterUtil.isEmpty( acc ) ) {
- Util.ensurePresenceOfSequence( node );
- node.getNodeData().getSequence( 0 ).setAccession( new Accession( acc, acc_source ) );
- }
- if ( !ForesterUtil.isEmpty( seq_name ) ) {
- Util.ensurePresenceOfSequence( node );
- node.getNodeData().getSequence( 0 ).setName( seq_name );
- }
- if ( !ForesterUtil.isEmpty( tax_sn ) ) {
- Util.ensurePresenceOfTaxonomy( node );
- node.getNodeData().getTaxonomy( 0 ).setScientificName( tax_sn );
- }
- }
- }
- }
- }
}
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import org.forester.archaeopteryx.Util;
+import org.forester.archaeopteryx.AptxUtil;
import org.forester.io.parsers.nhx.NHXFormatException;
import org.forester.phylogeny.Phylogeny;
import org.forester.phylogeny.PhylogenyNode;
}
if ( new_values != null ) {
if ( new_values.containsKey( TP_TAXONOMY_CODE ) ) {
- Util.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setTaxonomyCode( new_values.get( TP_TAXONOMY_CODE ) );
}
if ( new_values.containsKey( TP_TAXONOMY_ID )
&& new_values.containsKey( TP_TAXONOMY_ID_PROVIDER ) ) {
- Util.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData()
.getTaxonomy()
.setIdentifier( new Identifier( new_values.get( TP_TAXONOMY_ID ),
new_values.get( TP_TAXONOMY_ID_PROVIDER ) ) );
}
else if ( new_values.containsKey( TP_TAXONOMY_ID ) ) {
- Util.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy()
.setIdentifier( new Identifier( new_values.get( TP_TAXONOMY_ID ) ) );
}
if ( new_values.containsKey( TP_TAXONOMY_SN ) ) {
- Util.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setScientificName( new_values.get( TP_TAXONOMY_SN ) );
}
if ( new_values.containsKey( TP_TAXONOMY_CN ) ) {
- Util.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setCommonName( new_values.get( TP_TAXONOMY_CN ) );
}
if ( new_values.containsKey( TP_TAXONOMY_SYN ) ) {
- Util.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().getSynonyms().add( new_values.get( TP_TAXONOMY_SYN ) );
}
if ( new_values.containsKey( TP_SEQ_ACCESSION )
&& new_values.containsKey( TP_SEQ_ACCESSION_SOURCE ) ) {
- Util.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
node.getNodeData()
.getSequence()
.setAccession( new Accession( new_values.get( TP_SEQ_ACCESSION ),
new_values.get( TP_SEQ_ACCESSION_SOURCE ) ) );
}
if ( new_values.containsKey( TP_SEQ_ANNOTATION_DESC ) ) {
- Util.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
final Annotation ann = new Annotation( "?" );
ann.setDesc( new_values.get( TP_SEQ_ANNOTATION_DESC ) );
node.getNodeData().getSequence().addAnnotation( ann );
}
if ( new_values.containsKey( TP_SEQ_ANNOTATION_REF ) ) {
- Util.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
final Annotation ann = new Annotation( new_values.get( TP_SEQ_ANNOTATION_REF ) );
node.getNodeData().getSequence().addAnnotation( ann );
}
if ( new_values.containsKey( TP_SEQ_SYMBOL ) ) {
- Util.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
node.getNodeData().getSequence().setSymbol( new_values.get( TP_SEQ_SYMBOL ) );
}
if ( new_values.containsKey( TP_SEQ_NAME ) ) {
- Util.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
node.getNodeData().getSequence().setName( new_values.get( TP_SEQ_NAME ) );
}
if ( new_values.containsKey( TP_SEQ_MOL_SEQ ) ) {
- Util.ensurePresenceOfSequence( node );
+ AptxUtil.ensurePresenceOfSequence( node );
node.getNodeData().getSequence().setMolecularSequence( new_values.get( TP_SEQ_MOL_SEQ ) );
}
if ( new_values.containsKey( TP_NODE_NAME ) ) {
if ( PhylogenyDecorator.VERBOSE ) {
System.out.println( name + ": " + new_value );
}
- Util.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setTaxonomyCode( new_value );
break;
case TAXONOMY_SCIENTIFIC_NAME:
if ( PhylogenyDecorator.VERBOSE ) {
System.out.println( name + ": " + new_value );
}
- Util.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setScientificName( new_value );
break;
case SEQUENCE_NAME:
private static void extractBracketedScientificNames( final PhylogenyNode node, final String new_value ) {
final int i = new_value.lastIndexOf( "[" );
final String scientific_name = new_value.substring( i + 1, new_value.length() - 1 );
- Util.ensurePresenceOfTaxonomy( node );
+ AptxUtil.ensurePresenceOfTaxonomy( node );
node.getNodeData().getTaxonomy().setScientificName( scientific_name );
}