Skip to content

Commit 3b05ed7

Browse files
committed
BEASTGen packaging scripts
1 parent 757045c commit 3b05ed7

File tree

10 files changed

+441
-64
lines changed

10 files changed

+441
-64
lines changed

build_beastgen.xml

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<project name="BEASTGen" default="build" basedir=".">
2+
<description>
3+
Build file for the phylogeography.jar tools package.
4+
$Id:$
5+
</description>
6+
<!-- set global properties for this build -->
7+
<property name="src" location="src"/>
8+
<property name="build" location="build"/>
9+
<property name="lib" location="lib"/>
10+
<property name="dist" location="dist"/>
11+
12+
<path id="classpath">
13+
<fileset dir="${lib}" includes="**/*.jar"/>
14+
</path>
15+
16+
<property environment="env"/>
17+
18+
<target name="init">
19+
<!-- Create the time stamp -->
20+
<echo message="${ant.project.name}: ${ant.file}" />
21+
<tstamp/>
22+
<!-- Create the build directory structure used by compile -->
23+
<mkdir dir="${build}"/>
24+
<mkdir dir="${dist}"/>
25+
</target>
26+
27+
<target name="compile" depends="init">
28+
<!-- Compile the java code from ${src} into ${build} -->
29+
<javac source="1.6" srcdir="${src}" destdir="${build}" classpathref="classpath">
30+
<include name="dr/app/beastgen/**"/>
31+
<include name="dr/app/beast/**"/>
32+
<include name="dr/app/util/**"/>
33+
<include name="dr/evolution/**"/>
34+
<include name="dr/inference/trace/**"/>
35+
<include name="dr/matrix/**"/>
36+
<include name="dr/stats/**"/>
37+
<include name="dr/math/**"/>
38+
<include name="dr/util/**"/>
39+
</javac>
40+
</target>
41+
42+
<target name="build" depends="compile" description="generate the jar file">
43+
<!-- Create the distribution directory -->
44+
<mkdir dir="${dist}"/>
45+
46+
<!-- Put everything in ${build} into the treestat.jar file -->
47+
<jar jarfile="${dist}/beastgen.jar">
48+
<manifest>
49+
<attribute name="Built-By" value="${user.name}"/>
50+
<attribute name="Main-Class" value="dr.app.beastgen.BEASTGen"/>
51+
</manifest>
52+
<fileset dir="${build}">
53+
<include name="dr/app/beastgen/**/*.class"/>
54+
<include name="dr/app/beast/BeastVersion.class"/>
55+
<include name="dr/app/util/**/*.class"/>
56+
<include name="dr/evolution/**/*.class"/>
57+
<include name="dr/inference/trace/**/*.class"/>
58+
<include name="dr/matrix/**/*.class"/>
59+
<include name="dr/stats/**/*.class"/>
60+
<include name="dr/math/**/*.class"/>
61+
<include name="dr/util/**/*.class"/>
62+
</fileset>
63+
<zipgroupfileset dir="${lib}" includes="**/freemarker.jar"/>
64+
<zipgroupfileset dir="${lib}" includes="**/jdom.jar"/>
65+
</jar>
66+
</target>
67+
68+
<property name="version" value="1.0" />
69+
<property name="release_dir" value="release_beastgen" />
70+
<property name="name" value="BEASTGen" />
71+
72+
<property name="common_dir" value="${release_dir}/common" />
73+
74+
<property name="package_dir" value="${release_dir}/${name}_v${version}" />
75+
76+
<target name="package" depends="build" description="release Linux/Unix version">
77+
<delete dir="${package_dir}" />
78+
<!-- Create the release directory -->
79+
<mkdir dir="${package_dir}" />
80+
81+
<copy todir="${package_dir}/bin">
82+
<fileset dir="${common_dir}/bin"/>
83+
</copy>
84+
85+
<copy todir="${package_dir}/templates">
86+
<fileset dir="${common_dir}/templates"/>
87+
</copy>
88+
89+
<copy file="${dist}/beastgen.jar" todir="${package_dir}/lib"/>
90+
<copy file="${common_dir}/README.txt" todir="${package_dir}"/>
91+
92+
<tar destfile="${release_dir}/${name}_v${version}.tgz" compression="gzip">
93+
<tarfileset dir="${package_dir}" prefix="${name}_v${version}"/>
94+
</tar>
95+
96+
<zip destfile="${release_dir}/${name} v${version}.zip">
97+
<zipfileset dir="${package_dir}" prefix="${name} v${version}"/>
98+
</zip>
99+
100+
<echo message="Linux/Unix version release is finished." />
101+
</target>
102+
103+
</project>

release_beastgen/common/README.txt

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
BEASTGen Tool
2+
3+
This package contains a simple program for transforming data from one format to another.
4+
5+
The program is run using the following command line:
6+
7+
beastgen <template_filename> <input_filename> <output_filename>
8+
9+
For example:
10+
11+
beastgen to_fasta.template dengue.nex dengue.fasta
12+
13+
This will change the NEXUS file into a FASTA file by using the to_fasta template (a FASTA
14+
to NEXUS template is also given in the templates folder).
15+
16+
Also in the templates folder is 'beast_example.template' which demonstrates how to
17+
set up a template from a BEAST XML file.
18+
19+
beastgen -chain_length 10000000 -log_every 1000 beast_example.template dengue.nex
20+
21+
More detailed instructions are to be found on the BEAST website:
22+
23+
http://beast.bio.ed.ac.uk/
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
if [ -z "$BEASTGEN" ]; then
4+
## resolve links - $0 may be a link to application
5+
PRG="$0"
6+
7+
# need this for relative symlinks
8+
while [ -h "$PRG" ] ; do
9+
ls=`ls -ld "$PRG"`
10+
link=`expr "$ls" : '.*-> \(.*\)$'`
11+
if expr "$link" : '/.*' > /dev/null; then
12+
PRG="$link"
13+
else
14+
PRG="`dirname "$PRG"`/$link"
15+
fi
16+
done
17+
18+
# make it fully qualified
19+
saveddir=`pwd`
20+
BEASTGEN0=`dirname "$PRG"`/..
21+
BEASTGEN=`cd "$BEASTGEN0" && pwd`
22+
cd "$saveddir"
23+
fi
24+
25+
BEASTGEN_LIB=$BEASTGEN/lib
26+
java -Xmx1024M -cp $BEASTGEN_LIB/beastgen.jar dr.app.beastgen.BEASTGen $*
27+

src/dr/app/beastgen/BEASTGen.java

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
package beast;
1+
package dr.app.beastgen;
22

3-
import dr.app.util.Arguments;
43
import dr.evolution.io.Importer;
54
import freemarker.template.*;
65

76
import java.io.*;
87
import java.util.HashMap;
98
import java.util.Map;
10-
import java.util.StringTokenizer;
119

1210
public class BEASTGen {
1311

@@ -52,19 +50,6 @@ private Map constructDataModel(String inputFileName) throws IOException, Importe
5250
return root;
5351
}
5452

55-
private int findArgument(String[] arguments, String label) {
56-
for (int i = 0; i < arguments.length; i++) {
57-
58-
if (arguments[i].length() - 1 >= label.length()) {
59-
if (arguments[i].startsWith("-")) {
60-
61-
}
62-
}
63-
}
64-
return -1;
65-
}
66-
67-
6853
public static String[] parseArguments(String[] arguments, Map dataModel) {
6954

7055
int[] optionIndex = new int[arguments.length];

src/dr/app/beastgen/BeastImporter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package beast;
1+
package dr.app.beastgen;
22

33
import dr.evolution.alignment.Alignment;
44
import dr.evolution.alignment.SimpleAlignment;

src/dr/app/beastgen/DataModelImporter.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package beast;
1+
package dr.app.beastgen;
22

33
import dr.app.beauti.options.*;
44
import dr.app.util.Utils;
@@ -322,7 +322,7 @@ private void setData(Map dataModel, String fileName, TaxonList taxonList, List<T
322322

323323
checkTaxonList(taxonList);
324324
dataModel.put("taxa", createTaxonList(taxonList));
325-
dataModel.put("taxon_count", taxonList.getTaxonCount());
325+
dataModel.put("taxon_count", Integer.toString(taxonList.getTaxonCount()));
326326

327327
if (taxonLists != null) {
328328
List<Map> tss = new ArrayList<Map>();
@@ -338,7 +338,7 @@ private void setData(Map dataModel, String fileName, TaxonList taxonList, List<T
338338
}
339339

340340
dataModel.put("alignment", createAlignment(alignment));
341-
dataModel.put("site_count", alignment.getSiteCount());
341+
dataModel.put("site_count", Integer.toString(alignment.getSiteCount()));
342342

343343
dataModel.put("filename", fileName);
344344
dataModel.put("filename_stem", fileNameStem);

src/dr/app/beastgen/NexusApplicationImporter.java

+1-26
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,4 @@
1-
/*
2-
* NexusApplicationImporter.java
3-
*
4-
* Copyright (C) 2002-2011 Alexei Drummond and Andrew Rambaut
5-
*
6-
* This file is part of BEAST.
7-
* See the NOTICE file distributed with this work for additional
8-
* information regarding copyright ownership and licensing.
9-
*
10-
* BEAST is free software; you can redistribute it and/or modify
11-
* it under the terms of the GNU Lesser General Public License as
12-
* published by the Free Software Foundation; either version 2
13-
* of the License, or (at your option) any later version.
14-
*
15-
* BEAST is distributed in the hope that it will be useful,
16-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18-
* GNU Lesser General Public License for more details.
19-
*
20-
* You should have received a copy of the GNU Lesser General Public
21-
* License along with BEAST; if not, write to the
22-
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23-
* Boston, MA 02110-1301 USA
24-
*/
25-
26-
package beast;
1+
package dr.app.beastgen;
272

283
import dr.app.beauti.options.BeautiOptions;
294
import dr.app.beauti.options.PartitionSubstitutionModel;

0 commit comments

Comments
 (0)