Skip to content

Commit

Permalink
removed prottest dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
ddarriba committed Mar 3, 2016
1 parent 27a9f3a commit 69919a8
Show file tree
Hide file tree
Showing 15 changed files with 1,557 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Manifest
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Main-Class: es.uvigo.darwin.jmodeltest.ModelTest
Class-Path: lib/appframework-1.0.3.jar lib/prottest-3.4.1.jar lib/mpj.
Class-Path: lib/appframework-1.0.3.jar lib/mpj.
jar lib/pal.jar lib/alter.jar lib/swing-worker-1.1.jar.
jar lib/freemarker.jar lib/BrowserLauncher2-all-1_3.
jar lib/jfreechart-1.0.14.jar lib/jcommon-1.0.17.jar
Binary file removed lib/prottest-3.4.1.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package es.uvigo.darwin.jmodeltest.exception;

/**
* The Class ProtTestInternalException.
* The Class InternalException.
*
* @author Diego Darriba
*/
Expand All @@ -28,12 +28,12 @@ public class InternalException extends RuntimeException {
private static final long serialVersionUID = 20090728L;

/**
* Instantiates a new prot test internal exception.
* Instantiates a new internal exception.
*/
public InternalException() {}

/**
* Instantiates a new prot test internal exception.
* Instantiates a new internal exception.
*
* @param description the description
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/*
Copyright (C) 2009 Diego Darriba
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package es.uvigo.darwin.jmodeltest.exe;

import java.util.ArrayList;
import java.util.Collection;

/**
* A thrid-party applications manager to control proccesses running on
* the machine and kill them when necessary.
*
* @author Diego Darriba
* @since 3.0
*/
public class ExternalExecutionManager {

/** Unique instance of the manager */
private static ExternalExecutionManager instance;
/** Collection of running processes */
private final Collection<Process> processes;

/**
* Instantiates a new execution manager
*/
private ExternalExecutionManager() {
this.processes = new ArrayList<Process>();
}

/**
* Gets the unique instance of the class
*
* @return the ExternalExecutionManager instance
*/
public static ExternalExecutionManager getInstance() {
if (instance == null) {
instance = new ExternalExecutionManager();
}
return instance;
}

/**
* Adds a process in execution to the collection
*
* @param proc the running process
*
* @return true, if succesfully added the process
*/
public boolean addProcess(Process proc) {
boolean result = false;
if (!processes.contains(proc)) {
result = processes.add(proc);
}
return result;
}

/**
* Removes a process from the collection
*
* @param proc the process to remove
*
* @return true, if succesfully removed the process
*/
public boolean removeProcess(Process proc) {
boolean result = false;
if (processes.contains(proc)) {
result = processes.remove(proc);
}
return result;
}

/**
* Kills all running processes in the collection
*/
public void killProcesses() {
for (final Process proc : processes) {
if (proc != null) {
try {
proc.exitValue();
} catch (IllegalThreadStateException e) {
// The process is executing, so we should kill it
Runtime.getRuntime().addShutdownHook(
new Thread(new Runnable() {

public void run() {
proc.destroy();
}
}));
}
}
}
processes.clear();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,6 @@ public void distribute(List<Model> models) throws InterruptedException {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
// throw new
// ProtTestInternalException("Thread interrupted");
}

}
Expand All @@ -228,7 +226,6 @@ public void distribute(List<Model> models) throws InterruptedException {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
// throw new ProtTestInternalException("Thread interrupted");
}
}
caller.rootModel = null;
Expand Down
20 changes: 12 additions & 8 deletions src/main/java/es/uvigo/darwin/jmodeltest/exe/RunConsense.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
*/
package es.uvigo.darwin.jmodeltest.exe;

import java.io.PrintWriter;
import java.io.PushbackReader;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
Expand All @@ -34,12 +36,11 @@
import es.uvigo.darwin.jmodeltest.io.TextOutputStream;
import es.uvigo.darwin.jmodeltest.model.Model;
import es.uvigo.darwin.jmodeltest.selection.InformationCriterion;
import es.uvigo.darwin.jmodeltest.tree.Consensus;
import es.uvigo.darwin.jmodeltest.tree.TreeUtilities;
import es.uvigo.darwin.jmodeltest.tree.WeightedTree;
import es.uvigo.darwin.jmodeltest.utilities.FixedBitSet;
import es.uvigo.darwin.jmodeltest.utilities.Utilities;
import es.uvigo.darwin.prottest.consensus.Consensus;
import es.uvigo.darwin.prottest.facade.TreeFacade;
import es.uvigo.darwin.prottest.facade.TreeFacadeImpl;
import es.uvigo.darwin.prottest.tree.WeightedTree;
import es.uvigo.darwin.prottest.util.FixedBitSet;

public class RunConsense {

Expand Down Expand Up @@ -242,7 +243,6 @@ public Tree getConsensus() {
private void printConsensus() {

double consensusThreshold = consensusType.equals("50% majority rule")?0.5:1.0;
TreeFacade treeFacade = new TreeFacadeImpl();

// print results for best AIC model
stream.println(" ");stream.println(" ");stream.println(" ");
Expand Down Expand Up @@ -306,9 +306,13 @@ private void printConsensus() {
stream.println(" ");

Tree consensusTree = consensus.getConsensusTree();
stream.println(treeFacade.toASCII(consensusTree));
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
TreeUtilities.printASCII(consensusTree, pw);
pw.flush();
stream.println(sw);
stream.println(" ");
String newickTree = treeFacade.toNewick(consensusTree, true, true, true);
String newickTree = TreeUtilities.toNewick(consensusTree, true, true, true);
stream.println(newickTree);
stream.println(" ");
stream.println("Note: this tree is unrooted. Branch lengths are the expected number of "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@
import es.uvigo.darwin.jmodeltest.ApplicationOptions;
import es.uvigo.darwin.jmodeltest.ModelTest;
import es.uvigo.darwin.jmodeltest.ModelTestConfiguration;
import es.uvigo.darwin.jmodeltest.exe.ExternalExecutionManager;
import es.uvigo.darwin.jmodeltest.exe.ProcessManager;
import es.uvigo.darwin.jmodeltest.io.TextOutputStream;
import es.uvigo.darwin.jmodeltest.model.Model;
import es.uvigo.darwin.jmodeltest.observer.ProgressInfo;
import es.uvigo.darwin.jmodeltest.utilities.Utilities;
import es.uvigo.darwin.prottest.exe.ExternalExecutionManager;

public class Frame_Progress extends JModelTestFrame implements Observer,
ActionListener {
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/es/uvigo/darwin/jmodeltest/io/HtmlReporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@
import es.uvigo.darwin.jmodeltest.tree.TreeSummary;
import es.uvigo.darwin.jmodeltest.tree.TreeUtilities;
import es.uvigo.darwin.jmodeltest.utilities.Utilities;
import es.uvigo.darwin.prottest.facade.TreeFacade;
import es.uvigo.darwin.prottest.facade.TreeFacadeImpl;
import freemarker.template.Configuration;
import freemarker.template.Template;

Expand All @@ -60,7 +58,6 @@ public abstract class HtmlReporter {
"resources" + File.separator + "homeIcon.gif",
"resources" + File.separator + "topIcon.gif",
"resources" + File.separator + "logo0.png" };
private static TreeFacade treeFacade = new TreeFacadeImpl();
private static Map<String, Object> datamodel;
private static File LOG_DIR;
private static File IMAGES_DIR;
Expand Down Expand Up @@ -244,7 +241,7 @@ public static void buildReport(ApplicationOptions options, Model models[],
ModelTest.getConsensusAIC() != null ? new Integer(1)
: new Integer(0));
if (ModelTest.getConsensusAIC() != null) {
datamodel.put("aicConsensusTree", treeFacade.toNewick(ModelTest
datamodel.put("aicConsensusTree", TreeUtilities.toNewick(ModelTest
.getConsensusAIC().getConsensus(), true, true, true));
datamodel.put("consensusType", ModelTest.getConsensusAIC()
.getConsensusType());
Expand All @@ -253,7 +250,7 @@ public static void buildReport(ApplicationOptions options, Model models[],
ModelTest.getConsensusAICc() != null ? new Integer(1)
: new Integer(0));
if (ModelTest.getConsensusAICc() != null) {
datamodel.put("aiccConsensusTree", treeFacade.toNewick(ModelTest
datamodel.put("aiccConsensusTree", TreeUtilities.toNewick(ModelTest
.getConsensusAICc().getConsensus(), true, true, true));
datamodel.put("consensusType", ModelTest.getConsensusAICc()
.getConsensusType());
Expand All @@ -262,7 +259,7 @@ public static void buildReport(ApplicationOptions options, Model models[],
ModelTest.getConsensusBIC() != null ? new Integer(1)
: new Integer(0));
if (ModelTest.getConsensusBIC() != null) {
datamodel.put("bicConsensusTree", treeFacade.toNewick(ModelTest
datamodel.put("bicConsensusTree", TreeUtilities.toNewick(ModelTest
.getConsensusBIC().getConsensus(), true, true, true));
datamodel.put("consensusType", ModelTest.getConsensusBIC()
.getConsensusType());
Expand All @@ -271,7 +268,7 @@ public static void buildReport(ApplicationOptions options, Model models[],
ModelTest.getConsensusDT() != null ? new Integer(1)
: new Integer(0));
if (ModelTest.getConsensusDT() != null) {
datamodel.put("dtConsensusTree", treeFacade.toNewick(ModelTest
datamodel.put("dtConsensusTree", TreeUtilities.toNewick(ModelTest
.getConsensusDT().getConsensus(), true, true, true));
datamodel.put("consensusType", ModelTest.getConsensusDT()
.getConsensusType());
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/es/uvigo/darwin/jmodeltest/io/RFHistogram.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,14 @@ public static JFreeChart buildDistancesHistogram(InformationCriterion ic, TreeDi
List<Model> models = ic.getConfidenceModels();

Tree bestTree = ic.getMinModel().getTree();
int maxRF = 2 * (bestTree.getIdCount()-3);
double values[] = new double[models.size()-1];
int i = 0;
for (Model model : models) {
if (!model.equals(ic.getMinModel())) {
double distance = distances.getDistance(bestTree, model.getTree());
values[i] = distance;
/* make relative RF distance */
values[i] = 1.0 * distance / maxRF;
i++;
}
}
Expand Down
Loading

0 comments on commit 69919a8

Please sign in to comment.