From 84e438d08cf3b2df706d0830be5123be8c4d80dc Mon Sep 17 00:00:00 2001 From: Siavash Mirarab Date: Thu, 3 Dec 2015 11:15:13 -0800 Subject: [PATCH] version 4.7.12 (-c added) --- CHANGELOG.md | 3 ++ README.md | 18 ++++++------ .../AbstractComputeMinCostTask.java | 3 ++ .../coalescent/AbstractInference.java | 4 ++- main/phylonet/coalescent/CommandLine.java | 28 +++++++++++++------ main/phylonet/coalescent/DLInference.java | 6 ++-- main/phylonet/coalescent/WQInference.java | 4 +-- 7 files changed, 43 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e1201eb12..a60f3d9d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +- version 4.7.12: + - Added an option (-c) so that ties are broken randomly + - version 4.7.8: - Fixed a bug in normalization of quartet scores. For very large datasets, the normalization of the quartet scores was incorrect. This only affected the outputted normalized score. The tree topology, and the non-normalized scores were not affected. diff --git a/README.md b/README.md index 3b278918b..0b93706ad 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Email: `astral-users@googlegroups.com` for questions. INSTALLATION: ----------- There is no installation required to run ASTRAL. -You simply need to download the [zip file](https://github.com/smirarab/ASTRAL/raw/master/Astral.4.7.8.zip) +You simply need to download the [zip file](https://github.com/smirarab/ASTRAL/raw/master/Astral.4.7.12.zip) and extract the contents to a folder of your choice. Alternatively, you can clone the [github repository](https://github.com/smirarab/ASTRAL/). You can run `make.sh` to build the project or simply use the jar file that is included with the repository. ASTRAL is a java-based application, and should run in any environment (Windows, Linux, Mac, etc.) as long as java is installed. Java 1.5 or later is required. We have tested ASTRAL only on Linux and MAC. @@ -24,13 +24,13 @@ ASTRAL is a java-based application, and should run in any environment (Windows, To test your installation, go to the place where you uncompressed ASTRAL, and run: ``` -java -jar astral.4.7.8.jar -i test_data/song_primates.424.gene.tre +java -jar astral.4.7.12.jar -i test_data/song_primates.424.gene.tre ``` This should quickly finish. There are also other sample input files under `test_data/` that can be used. -ASTRAL can be run from any directories. You just need to run `java -jar /path/to/astral/astral.4.7.8.jar`. -Also, you can move `astral.4.7.8.jar` to any location you like and run it from there, but note that you need +ASTRAL can be run from any directories. You just need to run `java -jar /path/to/astral/astral.4.7.12.jar`. +Also, you can move `astral.4.7.12.jar` to any location you like and run it from there, but note that you need to move the `lib` directory as well. EXECUTION: @@ -38,7 +38,7 @@ EXECUTION: ASTRAL currently has no GUI. You need to run it through command-line. In a terminal, go the location where you have downloaded the software, and issue the following command: ``` - java -jar astral.4.7.8.jar + java -jar astral.4.7.12.jar ``` This will give you a list of options available in ASTRAL. @@ -46,13 +46,13 @@ This will give you a list of options available in ASTRAL. To find the species tree given a set of gene trees in a file called `in.tree`, use: ``` -java -jar astral.4.7.8.jar -i in.tree +java -jar astral.4.7.12.jar -i in.tree ``` The results will be outputted to the standard output. To save the results in a file use the `-o` option (**Strongly recommended, unless you are using a pipeline**): ``` -java -jar astral.4.7.8.jar -i in.tree -o out.tre +java -jar astral.4.7.12.jar -i in.tree -o out.tre ``` The input gene trees can have missing taxa, polytommies (unresolved branches), and also multiple individuals per species. When multiple individuals from the same species are available, a mapping file needs to be provided using a `-a` option. This mapping file should have one line per species, and each line needs to be in one of two formats: @@ -71,7 +71,7 @@ that you test [multiind](https://github.com/smirarab/ASTRAL/tree/multiind) branc To perform 100 replicates of multi-locus bootstrapping ([Seo 2008](http://www.ncbi.nlm.nih.gov/pubmed/18281270)), use: ``` -java -jar astral.4.7.8.jar -i best_ml -b bs_paths -r 100 +java -jar astral.4.7.12.jar -i best_ml -b bs_paths -r 100 ``` In this command, `bs_paths` is a file that gives the location of gene tree bootstrap files, one line per gene. @@ -96,7 +96,7 @@ Also related to bootstrapping are `-g` (to enable gene/site resampling) and `-s` For big datasets (say more than 100 taxon) increasing the memory available to Java can result in speed ups. Note that you should give Java only as much free memory as you have available on your machine. So, for example, if you have 3GB of free memory, you can invoke ASTRAL using the following command to make all the 3GB available to Java: ``` -java -Xmx3000M -jar astral.4.7.8.jar -i in.tree +java -Xmx3000M -jar astral.4.7.12.jar -i in.tree ``` Acknowledgment diff --git a/main/phylonet/coalescent/AbstractComputeMinCostTask.java b/main/phylonet/coalescent/AbstractComputeMinCostTask.java index 86ff3d4a5..79fa0d3c9 100644 --- a/main/phylonet/coalescent/AbstractComputeMinCostTask.java +++ b/main/phylonet/coalescent/AbstractComputeMinCostTask.java @@ -180,6 +180,9 @@ private double computeMinCost() throws CannotResolveException { && (lscore + rscore + c < v._max_score)) { continue; } + if (lscore + rscore + c == v._max_score && GlobalMaps.random.nextBoolean()) { + continue; + } v._max_score = (lscore + rscore + c); v._min_lc = smallV; v._min_rc = bigv; diff --git a/main/phylonet/coalescent/AbstractInference.java b/main/phylonet/coalescent/AbstractInference.java index 5443192b9..d41985744 100644 --- a/main/phylonet/coalescent/AbstractInference.java +++ b/main/phylonet/coalescent/AbstractInference.java @@ -44,10 +44,11 @@ public abstract class AbstractInference { public boolean outputCompleted; boolean searchSpace; private boolean run; + private boolean randtie; public AbstractInference(boolean rooted, boolean extrarooted, List trees, List extraTrees, boolean exactSolution, int addExtra, - boolean outputCompletedGenes, boolean outSearch, boolean run) { + boolean outputCompletedGenes, boolean outSearch, boolean run, boolean randomtiebreaker) { super(); this.rooted = rooted; this.extrarooted = extrarooted; @@ -58,6 +59,7 @@ public AbstractInference(boolean rooted, boolean extrarooted, List trees, this.outputCompleted = outputCompletedGenes; this.searchSpace = outSearch; this.run = run; + this.randtie = randomtiebreaker; } protected Collapse.CollapseDescriptor doCollapse(List trees) { diff --git a/main/phylonet/coalescent/CommandLine.java b/main/phylonet/coalescent/CommandLine.java index e2b574a62..665d972f8 100644 --- a/main/phylonet/coalescent/CommandLine.java +++ b/main/phylonet/coalescent/CommandLine.java @@ -38,7 +38,7 @@ public class CommandLine { - protected static String _versinon = "4.7.8"; + protected static String _versinon = "4.7.12"; private static void exitWithErr(String extraMessage, SimpleJSAP jsap) { @@ -143,6 +143,10 @@ private static SimpleJSAP getJSAP() throws JSAPException { JSAP.INTEGER_PARSER, null, JSAP.NOT_REQUIRED, 'm', "minleaves", "Remove genes with less than specificed number of leaves "), + + new Switch("random tie breaker", + 'c', "random-tie-break", + "beeaks ties randomly (the random seed given with -s controls the random choices)."), new Switch( "duplication", 'd', "dup", @@ -196,6 +200,7 @@ public static void main(String[] args) throws Exception{ Integer minleaves = null; BufferedWriter outbuffer; Set keepOptions = new HashSet(); + boolean randtie; jsap = getJSAP(); config = jsap.parse(args); @@ -240,6 +245,8 @@ public static void main(String[] args) throws Exception{ System.err.println("Using DynaDup application, minimizing MGDL (not ASTRAL)."); } + randtie = config.getBoolean("random tie breaker"); + System.err.println("\n================== ASTRAL ===================== \n" ); System.err.println("This is ASTRAL version " + _versinon); @@ -325,7 +332,7 @@ public static void main(String[] args) throws Exception{ AbstractInference inference = initializeInference(criterion, rooted, extrarooted, mainTrees, - extraTrees, cs, cd, wh, exact, addExtra, keepOptions); + extraTrees, cs, cd, wh, exact, addExtra, keepOptions, randtie); for (Tree tr : toScore) { inference.scoreGeneTree(tr); } @@ -448,7 +455,7 @@ public static void main(String[] args) throws Exception{ rooted, extrarooted, extraTrees, cs, cd, wh, exact, outbuffer, readInputTrees(input, rooted, false, false, minleaves), - null, outgroup, addExtra, keepOptions)); + null, outgroup, addExtra, keepOptions, randtie)); } if (bootstraps != null && bootstraps.size() != 0) { @@ -461,7 +468,8 @@ public static void main(String[] args) throws Exception{ System.err.println("\n======== Running the main analysis"); runOnOneInput(criterion, rooted, extrarooted, extraTrees, cs, cd, - wh, exact, outbuffer, mainTrees, bootstraps, outgroup, addExtra, keepOptions); + wh, exact, outbuffer, mainTrees, bootstraps, outgroup, addExtra, + keepOptions, randtie); outbuffer.close(); @@ -473,13 +481,13 @@ public static void main(String[] args) throws Exception{ private static Tree runOnOneInput(int criterion, boolean rooted, boolean extrarooted, List extraTrees, double cs, double cd, double wh, boolean exact, BufferedWriter outbuffer, List input, - Iterable bootstraps, String outgroup, int addExtra, Set keepOptions) { + Iterable bootstraps, String outgroup, int addExtra, Set keepOptions, boolean randtie) { long startTime; startTime = System.currentTimeMillis(); AbstractInference inference = initializeInference(criterion, rooted, extrarooted, input, - extraTrees, cs, cd, wh, exact, addExtra, keepOptions); + extraTrees, cs, cd, wh, exact, addExtra, keepOptions, randtie); List solutions = inference.inferSpeciesTree(); @@ -502,17 +510,19 @@ private static Tree runOnOneInput(int criterion, boolean rooted, private static AbstractInference initializeInference(int criterion, boolean rooted, boolean extrarooted, List trees, List extraTrees, - double cs, double cd, double wh, boolean exact, int addExtra, Set keepOptions) { + double cs, double cd, double wh, boolean exact, int addExtra, Set keepOptions, + boolean randtie) { AbstractInference inference; if (criterion == 1 || criterion == 0) { inference = new DLInference(rooted, extrarooted, - trees, extraTrees,exact ,criterion > 0, keepOptions.contains("completed")); + trees, extraTrees,exact ,criterion > 0, keepOptions.contains("completed"), + randtie); } else if (criterion == 2) { inference = new WQInference(rooted, extrarooted, trees, extraTrees, exact,criterion > 0, 1, addExtra, keepOptions.contains("completed"), keepOptions.contains("searchspace_norun") || keepOptions.contains("searchspace"), - !keepOptions.contains("searchspace_norun") ); + !keepOptions.contains("searchspace_norun"), randtie ); } else { throw new RuntimeException("criterion not set?"); } diff --git a/main/phylonet/coalescent/DLInference.java b/main/phylonet/coalescent/DLInference.java index 6624797cf..6183f5958 100644 --- a/main/phylonet/coalescent/DLInference.java +++ b/main/phylonet/coalescent/DLInference.java @@ -17,8 +17,10 @@ public class DLInference extends AbstractInference { //Map clusterToVertex; public DLInference(boolean rooted, boolean extrarooted, List trees, - List extraTrees, boolean exactSolution, boolean duploss, boolean outputCompletedGenes) { - super(rooted, extrarooted, trees, extraTrees, exactSolution, 0, outputCompletedGenes, false, true); + List extraTrees, boolean exactSolution, boolean duploss, boolean outputCompletedGenes, + boolean randtie) { + super(rooted, extrarooted, trees, extraTrees, exactSolution, 0, outputCompletedGenes, false, true, + randtie); this.optimizeDuploss = duploss ? 3 : 1; } diff --git a/main/phylonet/coalescent/WQInference.java b/main/phylonet/coalescent/WQInference.java index 90eb1375d..a2f2cf3c1 100644 --- a/main/phylonet/coalescent/WQInference.java +++ b/main/phylonet/coalescent/WQInference.java @@ -18,9 +18,9 @@ public class WQInference extends AbstractInference { public WQInference(boolean rooted, boolean extrarooted, List trees, List extraTrees, boolean exactSolution, boolean duploss, int alg, int addExtra, - boolean outputCompletedGenes, boolean outSearch, boolean run) { + boolean outputCompletedGenes, boolean outSearch, boolean run, boolean randomtiebreaker) { super(rooted, extrarooted, trees, extraTrees, exactSolution, - addExtra, outputCompletedGenes, outSearch, run); + addExtra, outputCompletedGenes, outSearch, run, randomtiebreaker); this.forceAlg = alg; }