Search in sources :

Example 11 with LogFileTraces

use of dr.inference.trace.LogFileTraces in project beast-mcmc by beast-dev.

the class CoalGenFrame method readFromFile.

protected boolean readFromFile(final File file) throws IOException {
    try {
        final String fileName = file.getName();
        final ProgressMonitorInputStream in = new ProgressMonitorInputStream(this, "Reading " + fileName, new FileInputStream(file));
        //            final Reader reader = new InputStreamReader(in);
        final JFrame frame = this;
        // the monitored activity must be in a new thread.
        Thread readThread = new Thread() {

            public void run() {
                try {
                    final File file1 = new File(fileName);
                    final LogFileTraces traces = new LogFileTraces(fileName, file1);
                    traces.loadTraces(in);
                    EventQueue.invokeLater(new Runnable() {

                        public void run() {
                            data.logFile = file;
                            data.traces = traces;
                            fireTracesChanged();
                        }
                    });
                } catch (final TraceException tex) {
                    EventQueue.invokeLater(new Runnable() {

                        public void run() {
                            JOptionPane.showMessageDialog(frame, "Error reading trace file: " + tex, "Error reading trace file", JOptionPane.ERROR_MESSAGE);
                        }
                    });
                } catch (final InterruptedIOException iioex) {
                // The cancel dialog button was pressed - do nothing
                } catch (final IOException ioex) {
                    EventQueue.invokeLater(new Runnable() {

                        public void run() {
                            JOptionPane.showMessageDialog(frame, "File I/O Error: " + ioex, "File I/O Error", JOptionPane.ERROR_MESSAGE);
                        }
                    });
                } catch (final Exception ex) {
                    EventQueue.invokeLater(new Runnable() {

                        public void run() {
                            JOptionPane.showMessageDialog(frame, "Fatal exception: " + ex, "Error reading file", JOptionPane.ERROR_MESSAGE);
                        }
                    });
                }
            }
        };
        readThread.start();
    } catch (IOException ioex) {
        JOptionPane.showMessageDialog(this, "File I/O Error: " + ioex, "File I/O Error", JOptionPane.ERROR_MESSAGE);
        return false;
    } catch (Exception ex) {
        JOptionPane.showMessageDialog(this, "Fatal exception: " + ex, "Error reading file", JOptionPane.ERROR_MESSAGE);
        return false;
    }
    return true;
}
Also used : TraceException(dr.inference.trace.TraceException) LogFileTraces(dr.inference.trace.LogFileTraces) TraceException(dr.inference.trace.TraceException)

Aggregations

LogFileTraces (dr.inference.trace.LogFileTraces)11 TraceException (dr.inference.trace.TraceException)7 File (java.io.File)5 MarginalLikelihoodAnalysis (dr.inference.trace.MarginalLikelihoodAnalysis)4 FileNotFoundException (java.io.FileNotFoundException)4 Distribution (dr.math.distributions.Distribution)1 XMLObject (dr.xml.XMLObject)1 XMLParseException (dr.xml.XMLParseException)1 IOException (java.io.IOException)1 List (java.util.List)1 EmpiricalDemographicFunction (jebl.evolution.coalescent.EmpiricalDemographicFunction)1 ImportException (jebl.evolution.io.ImportException)1 NewickExporter (jebl.evolution.io.NewickExporter)1 NexusImporter (jebl.evolution.io.NexusImporter)1 TreeImporter (jebl.evolution.io.TreeImporter)1 RootedTree (jebl.evolution.trees.RootedTree)1 CoalescentIntervalGenerator (jebl.evolution.treesimulation.CoalescentIntervalGenerator)1 IntervalGenerator (jebl.evolution.treesimulation.IntervalGenerator)1 TreeSimulator (jebl.evolution.treesimulation.TreeSimulator)1