private boolean _use_tabbed_display = false;
private boolean _hide_controls_and_menus = false;
private CLADOGRAM_TYPE _cladogram_type = Constants.CLADOGRAM_TYPE_DEFAULT;
- private File _mafft = null;
- private File _clustalo = null;
- private File _fastme = null;
-
+ private File _mafft = null;
+ private File _clustalo = null;
+ private File _fastme = null;
private SortedMap<String, WebLink> _weblinks = null;
private SortedMap<String, Color> _display_colors = null;
private boolean _antialias_screen = true;
}
}
else if ( key.equals( "path_to_mafft" ) ) {
- setPathToMafft( new File( (String) st.nextElement() ) );
+ setPathToMafft( new File( ( String ) st.nextElement() ) );
}
else if ( key.equals( "path_to_clustalo" ) ) {
- setPathToClustalOmega( new File( (String) st.nextElement() ) );
+ setPathToClustalOmega( new File( ( String ) st.nextElement() ) );
}
else if ( key.equals( "path_to_fastme" ) ) {
- setPathToFastME( new File( (String) st.nextElement() ) );
+ setPathToFastME( new File( ( String ) st.nextElement() ) );
}
else if ( key.equals( "path_to_mafft" ) ) {
- setPathToMafft( new File( (String) st.nextElement() ) );
+ setPathToMafft( new File( ( String ) st.nextElement() ) );
}
else if ( key.equals( VALIDATE_AGAINST_PHYLOXML_XSD_SCHEMA ) ) {
setValidatePhyloXmlAgainstSchema( parseBoolean( ( String ) st.nextElement() ) );
return DEFAULT_FONT_FAMILY;
}
-
public File getPathToMafft() {
return _mafft;
}
-
-
public File getPathToClustalOmega() {
return _clustalo;
}
-
public File getPathToFastME() {
return _fastme;
}
-
-
+
public void setPathToMafft( final File mafft ) {
_mafft = mafft;
}
-
-
- public void setPathToClustalOmega( final File clustalo ) {
- _clustalo = clustalo ;
+ public void setPathToClustalOmega( final File clustalo ) {
+ _clustalo = clustalo;
}
-
public void setPathToFastME( final File fastme ) {
- _fastme = fastme;
+ _fastme = fastme;
}
static enum TRIPLET {
Configuration _configuration;
JMenuItem _remove_branch_color_item;
Options _options;
- final ProcessPool _process_pool;
-
+ final ProcessPool _process_pool;
+
MainFrame() {
- _process_pool = new ProcessPool();
+ _process_pool = ProcessPool.createInstance();
}
-
- ProcessPool getProcessPool() {
+
+ public ProcessPool getProcessPool() {
return _process_pool;
}
import org.forester.archaeopteryx.Options.PHYLOGENY_GRAPHICS_TYPE;
import org.forester.archaeopteryx.tools.AncestralTaxonomyInferrer;
import org.forester.archaeopteryx.tools.GoAnnotation;
+import org.forester.archaeopteryx.tools.InferenceManager;
import org.forester.archaeopteryx.tools.PhyloInferenceDialog;
import org.forester.archaeopteryx.tools.PhylogeneticInferenceOptions;
import org.forester.archaeopteryx.tools.PhylogeneticInferrer;
JMenuItem _read_values_jmi;
private MainFrameApplication( final Phylogeny[] phys, final Configuration config, final String title ) {
-
this( phys, config, title, null );
}
void buildPhylogeneticInferenceMenu() {
final InferenceManager inference_manager = InferenceManager.getInstance();
_inference_menu = MainFrame.createMenu( "Inference", getConfiguration() );
- _inference_menu
- .add( _inference_from_msa_item = new JMenuItem( "From Multiple Sequence Alignment..." ) );
+ _inference_menu.add( _inference_from_msa_item = new JMenuItem( "From Multiple Sequence Alignment..." ) );
customizeJMenuItem( _inference_from_msa_item );
_inference_from_msa_item.setToolTipText( "Basic phylogenetic inference from MSA" );
- _inference_menu
- .add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences..." ) );
+ _inference_menu.add( _inference_from_seqs_item = new JMenuItem( "From Unaligned Sequences..." ) );
customizeJMenuItem( _inference_from_seqs_item );
_inference_from_seqs_item.setToolTipText( "Basic phylogenetic inference including multiple sequence alignment" );
_jmenubar.add( _inference_menu );
import org.forester.analysis.AncestralTaxonomyInference;
import org.forester.analysis.AncestralTaxonomyInferenceException;
+import org.forester.archaeopteryx.Constants;
import org.forester.archaeopteryx.MainFrameApplication;
import org.forester.archaeopteryx.TreePanel;
import org.forester.phylogeny.Phylogeny;
+import org.forester.util.ForesterUtil;
import org.forester.ws.uniprot.UniProtWsTools;
public class AncestralTaxonomyInferrer implements Runnable {
private final Phylogeny _phy;
private final MainFrameApplication _mf;
private final TreePanel _treepanel;
+ private long _process_id;
+
+ private long getProcessId() {
+ return _process_id;
+ }
+
+ private void setProcessId( final long process_id ) {
+ _process_id = process_id;
+ }
public AncestralTaxonomyInferrer( final MainFrameApplication mf, final TreePanel treepanel, final Phylogeny phy ) {
_phy = phy;
return UniProtWsTools.BASE_URL;
}
- private void inferTaxonomies() {
+ private void start() {
_mf.getMainPanel().getCurrentTreePanel().setWaitCursor();
+ setProcessId( _mf.getProcessPool().addProcess( "ancestral taxonomy" ) );
+ }
+
+ private void end() {
+ final boolean removed = _mf.getProcessPool().removeProcess( getProcessId() );
+ if ( !removed ) {
+ ForesterUtil.printWarningMessage( Constants.PRG_NAME, "could not remove process " + getProcessId()
+ + " from process pool" );
+ }
+ _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
+ }
+
+ private void inferTaxonomies() {
+ start();
try {
AncestralTaxonomyInference.inferTaxonomyFromDescendents( _phy );
}
catch ( final AncestralTaxonomyInferenceException e ) {
- _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
+ end();
JOptionPane.showMessageDialog( _mf,
e.getMessage(),
"Error during ancestral taxonomy inference",
return;
}
catch ( final UnknownHostException e ) {
- _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
+ end();
JOptionPane.showMessageDialog( _mf,
"Could not connect to \"" + getBaseUrl() + "\"",
"Network error during ancestral taxonomy inference",
return;
}
catch ( final Exception e ) {
- _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
+ end();
+ e.printStackTrace();
+ JOptionPane.showMessageDialog( _mf,
+ e.toString(),
+ "Unexpected exception during ancestral taxonomy inference",
+ JOptionPane.ERROR_MESSAGE );
+ return;
+ }
+ catch ( final Error e ) {
+ end();
e.printStackTrace();
JOptionPane.showMessageDialog( _mf,
e.toString(),
JOptionPane.ERROR_MESSAGE );
return;
}
- _mf.getMainPanel().getCurrentTreePanel().setArrowCursor();
_phy.setRerootable( false );
_treepanel.setTree( _phy );
_mf.showWhole();
_treepanel.setEdited( true );
+ end();
try {
JOptionPane.showMessageDialog( _mf,
"Ancestral taxonomy inference successfully completed",
--- /dev/null
+
+package org.forester.archaeopteryx.tools;
+
+public class InferenceManager {
+
+ public static InferenceManager getInstance() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
\r
public class ProcessPool {\r
\r
- private final static boolean DEBUG = true;\r
- final static private ArrayList<ProcessRunning> _processes = new ArrayList<ProcessRunning>();\r
+ private final static boolean DEBUG = true;\r
+ private final ArrayList<ProcessRunning> _processes;\r
+\r
+ private ProcessPool() {\r
+ _processes = new ArrayList<ProcessRunning>();\r
+ }\r
+\r
+ public static ProcessPool createInstance() {\r
+ return new ProcessPool();\r
+ }\r
\r
public synchronized ProcessRunning getProcessByIndex( final int i ) {\r
return getProcesses().get( i );\r
return getProcesses().size();\r
}\r
\r
- public synchronized ProcessRunning getProcessById( final int id ) {\r
+ public synchronized ProcessRunning getProcessById( final long id ) {\r
for( final ProcessRunning p : getProcesses() ) {\r
if ( p.getId() == id ) {\r
return p;\r
return null;\r
}\r
\r
- public synchronized int addProcess( final String name ) {\r
+ public synchronized long addProcess( final String name ) {\r
final ProcessRunning p = ProcessRunning.createInstance( name );\r
- final int id = p.getId();\r
+ final long id = p.getId();\r
if ( getProcessById( id ) != null ) {\r
throw new IllegalStateException( " process with id " + id + "already exists" );\r
}\r
getProcesses().add( p );\r
if ( DEBUG ) {\r
- System.out.println( "added: " + p );\r
+ System.out.println( " pp: added: " + p );\r
}\r
return id;\r
}\r
\r
- public synchronized boolean removeProcess( final int id ) {\r
+ public synchronized boolean removeProcess( final long id ) {\r
final int i = getProcessIndexById( id );\r
if ( i >= 0 ) {\r
if ( DEBUG ) {\r
final ProcessRunning p = getProcessById( id );\r
- System.out.println( " removing: " + p );\r
+ System.out.println( " pp: removing: " + p );\r
}\r
getProcesses().remove( i );\r
return true;\r
return false;\r
}\r
\r
- private synchronized int getProcessIndexById( final int id ) {\r
- final ProcessRunning p = getProcessById( id );\r
- if ( p != null ) {\r
- return p.getId();\r
+ private synchronized int getProcessIndexById( final long id ) {\r
+ for( int i = 0; i < size(); ++i ) {\r
+ if ( getProcesses().get( i ).getId() == id ) {\r
+ return i;\r
+ }\r
}\r
return -1;\r
}\r
\r
final public class ProcessRunning {\r
\r
- private static int count = 0;\r
- final private int _id;\r
+ private static long count = 0;\r
+ final private long _id;\r
final private String _name;\r
final private String _start;\r
\r
- public int getId() {\r
+ public long getId() {\r
return _id;\r
}\r
- \r
- public String getName() {\r
+\r
+ public String getName() {\r
return _name;\r
}\r
- \r
+\r
public String getStart() {\r
return _start;\r
}\r
- \r
+\r
+ @Override\r
public String toString() {\r
return getName() + " [id=" + getId() + "] [start=" + getStart() + "]";\r
}\r
- \r
+\r
synchronized static ProcessRunning createInstance( final String name ) {\r
final Calendar cal = Calendar.getInstance();\r
final SimpleDateFormat sdf = new SimpleDateFormat( "HH:mm:ss" );\r
return new ProcessRunning( count++, name, sdf.format( cal.getTime() ) );\r
}\r
- \r
- private ProcessRunning( final int id, final String name, final String start ) {\r
+\r
+ private ProcessRunning( final long id, final String name, final String start ) {\r
+ if ( id < 0 ) {\r
+ throw new IllegalArgumentException( "process id cannot be negative" );\r
+ }\r
_id = id;\r
_name = name;\r
- _start = start; \r
+ _start = start;\r
}\r
-\r
}\r