Skip to content

Commit

Permalink
BEASTGen packaging scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rambaut committed Oct 17, 2013
1 parent 757045c commit 3b05ed7
Show file tree
Hide file tree
Showing 10 changed files with 441 additions and 64 deletions.
103 changes: 103 additions & 0 deletions build_beastgen.xml
@@ -0,0 +1,103 @@
<project name="BEASTGen" default="build" basedir=".">
<description>
Build file for the phylogeography.jar tools package.
$Id:$
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="build" location="build"/>
<property name="lib" location="lib"/>
<property name="dist" location="dist"/>

<path id="classpath">
<fileset dir="${lib}" includes="**/*.jar"/>
</path>

<property environment="env"/>

<target name="init">
<!-- Create the time stamp -->
<echo message="${ant.project.name}: ${ant.file}" />
<tstamp/>
<!-- Create the build directory structure used by compile -->
<mkdir dir="${build}"/>
<mkdir dir="${dist}"/>
</target>

<target name="compile" depends="init">
<!-- Compile the java code from ${src} into ${build} -->
<javac source="1.6" srcdir="${src}" destdir="${build}" classpathref="classpath">
<include name="dr/app/beastgen/**"/>
<include name="dr/app/beast/**"/>
<include name="dr/app/util/**"/>
<include name="dr/evolution/**"/>
<include name="dr/inference/trace/**"/>
<include name="dr/matrix/**"/>
<include name="dr/stats/**"/>
<include name="dr/math/**"/>
<include name="dr/util/**"/>
</javac>
</target>

<target name="build" depends="compile" description="generate the jar file">
<!-- Create the distribution directory -->
<mkdir dir="${dist}"/>

<!-- Put everything in ${build} into the treestat.jar file -->
<jar jarfile="${dist}/beastgen.jar">
<manifest>
<attribute name="Built-By" value="${user.name}"/>
<attribute name="Main-Class" value="dr.app.beastgen.BEASTGen"/>
</manifest>
<fileset dir="${build}">
<include name="dr/app/beastgen/**/*.class"/>
<include name="dr/app/beast/BeastVersion.class"/>
<include name="dr/app/util/**/*.class"/>
<include name="dr/evolution/**/*.class"/>
<include name="dr/inference/trace/**/*.class"/>
<include name="dr/matrix/**/*.class"/>
<include name="dr/stats/**/*.class"/>
<include name="dr/math/**/*.class"/>
<include name="dr/util/**/*.class"/>
</fileset>
<zipgroupfileset dir="${lib}" includes="**/freemarker.jar"/>
<zipgroupfileset dir="${lib}" includes="**/jdom.jar"/>
</jar>
</target>

<property name="version" value="1.0" />
<property name="release_dir" value="release_beastgen" />
<property name="name" value="BEASTGen" />

<property name="common_dir" value="${release_dir}/common" />

<property name="package_dir" value="${release_dir}/${name}_v${version}" />

<target name="package" depends="build" description="release Linux/Unix version">
<delete dir="${package_dir}" />
<!-- Create the release directory -->
<mkdir dir="${package_dir}" />

<copy todir="${package_dir}/bin">
<fileset dir="${common_dir}/bin"/>
</copy>

<copy todir="${package_dir}/templates">
<fileset dir="${common_dir}/templates"/>
</copy>

<copy file="${dist}/beastgen.jar" todir="${package_dir}/lib"/>
<copy file="${common_dir}/README.txt" todir="${package_dir}"/>

<tar destfile="${release_dir}/${name}_v${version}.tgz" compression="gzip">
<tarfileset dir="${package_dir}" prefix="${name}_v${version}"/>
</tar>

<zip destfile="${release_dir}/${name} v${version}.zip">
<zipfileset dir="${package_dir}" prefix="${name} v${version}"/>
</zip>

<echo message="Linux/Unix version release is finished." />
</target>

</project>
23 changes: 23 additions & 0 deletions release_beastgen/common/README.txt
@@ -0,0 +1,23 @@
BEASTGen Tool

This package contains a simple program for transforming data from one format to another.

The program is run using the following command line:

beastgen <template_filename> <input_filename> <output_filename>

For example:

beastgen to_fasta.template dengue.nex dengue.fasta

This will change the NEXUS file into a FASTA file by using the to_fasta template (a FASTA
to NEXUS template is also given in the templates folder).

Also in the templates folder is 'beast_example.template' which demonstrates how to
set up a template from a BEAST XML file.

beastgen -chain_length 10000000 -log_every 1000 beast_example.template dengue.nex

More detailed instructions are to be found on the BEAST website:

http://beast.bio.ed.ac.uk/
27 changes: 27 additions & 0 deletions release_phylogeography/common/bin/beastgen
@@ -0,0 +1,27 @@
#!/bin/sh

if [ -z "$BEASTGEN" ]; then
## resolve links - $0 may be a link to application
PRG="$0"

# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done

# make it fully qualified
saveddir=`pwd`
BEASTGEN0=`dirname "$PRG"`/..
BEASTGEN=`cd "$BEASTGEN0" && pwd`
cd "$saveddir"
fi

BEASTGEN_LIB=$BEASTGEN/lib
java -Xmx1024M -cp $BEASTGEN_LIB/beastgen.jar dr.app.beastgen.BEASTGen $*

17 changes: 1 addition & 16 deletions src/dr/app/beastgen/BEASTGen.java
@@ -1,13 +1,11 @@
package beast;
package dr.app.beastgen;

import dr.app.util.Arguments;
import dr.evolution.io.Importer;
import freemarker.template.*;

import java.io.*;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class BEASTGen {

Expand Down Expand Up @@ -52,19 +50,6 @@ private Map constructDataModel(String inputFileName) throws IOException, Importe
return root;
}

private int findArgument(String[] arguments, String label) {
for (int i = 0; i < arguments.length; i++) {

if (arguments[i].length() - 1 >= label.length()) {
if (arguments[i].startsWith("-")) {

}
}
}
return -1;
}


public static String[] parseArguments(String[] arguments, Map dataModel) {

int[] optionIndex = new int[arguments.length];
Expand Down
2 changes: 1 addition & 1 deletion src/dr/app/beastgen/BeastImporter.java
@@ -1,4 +1,4 @@
package beast;
package dr.app.beastgen;

import dr.evolution.alignment.Alignment;
import dr.evolution.alignment.SimpleAlignment;
Expand Down
6 changes: 3 additions & 3 deletions src/dr/app/beastgen/DataModelImporter.java
@@ -1,4 +1,4 @@
package beast;
package dr.app.beastgen;

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

checkTaxonList(taxonList);
dataModel.put("taxa", createTaxonList(taxonList));
dataModel.put("taxon_count", taxonList.getTaxonCount());
dataModel.put("taxon_count", Integer.toString(taxonList.getTaxonCount()));

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

dataModel.put("alignment", createAlignment(alignment));
dataModel.put("site_count", alignment.getSiteCount());
dataModel.put("site_count", Integer.toString(alignment.getSiteCount()));

dataModel.put("filename", fileName);
dataModel.put("filename_stem", fileNameStem);
Expand Down
27 changes: 1 addition & 26 deletions src/dr/app/beastgen/NexusApplicationImporter.java
@@ -1,29 +1,4 @@
/*
* NexusApplicationImporter.java
*
* Copyright (C) 2002-2011 Alexei Drummond and Andrew Rambaut
*
* This file is part of BEAST.
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership and licensing.
*
* BEAST is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* BEAST 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with BEAST; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

package beast;
package dr.app.beastgen;

import dr.app.beauti.options.BeautiOptions;
import dr.app.beauti.options.PartitionSubstitutionModel;
Expand Down

0 comments on commit 3b05ed7

Please sign in to comment.