Scala walkers can now be build and run like any other walker in the GATK. Added the getUrlsForClasspath to PackageUtils, the Reflections package isn't getting the manifest files from jars in the classpath, and so we weren't seeing any walkers outside of the GenomeAnalysisTK.jar.
A couple of notes: -Commented out BaseTransitionTableCalculator.scala because it's won't build; Chris could you fix this one (or kill it if it's not needed). -Removed the PrintReadsScala walker; moved the code over to a ScalaCountLoci walker (which is what the code was really doing). -Added configurations items to the ivy xml file. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1956 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
1896f334d9
commit
de6ae51f7e
115
build.xml
115
build.xml
|
|
@ -40,21 +40,18 @@
|
|||
<property name="ivy.jar.file" value="ivy-${ivy.install.version}.jar"/>
|
||||
<property name="ivy.settings.dir" value="settings"/>
|
||||
<property file="${ivy.settings.dir}/ivysettings.properties"/>
|
||||
|
||||
<property name="ivy.conf" value="default"/>
|
||||
<target name="resolve" depends="init"
|
||||
description="locate and download library dependencies">
|
||||
<!-- retrieve ivy if necessary -->
|
||||
<mkdir dir="${ivy.jar.dir}"/>
|
||||
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/${ivy.jar.file}"
|
||||
dest="${ivy.jar.dir}/${ivy.jar.file}"
|
||||
usetimestamp="true"/>
|
||||
<!-- initialize and load ivy -->
|
||||
<taskdef resource="org/apache/ivy/ant/antlib.xml"
|
||||
uri="antlib:org.apache.ivy.ant"
|
||||
classpath="${ivy.jar.dir}/${ivy.jar.file}"/>
|
||||
<ivy:settings file="${ivy.settings.dir}/ivysettings.xml"/>
|
||||
<!-- retrieve dependencies -->
|
||||
<ivy:retrieve/>
|
||||
<mkdir dir="${ivy.jar.dir}"/>
|
||||
<get src="http://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/${ivy.jar.file}"
|
||||
dest="${ivy.jar.dir}/${ivy.jar.file}"
|
||||
usetimestamp="true"/>
|
||||
<taskdef resource="org/apache/ivy/ant/antlib.xml"
|
||||
uri="antlib:org.apache.ivy.ant"
|
||||
classpath="${ivy.jar.dir}/${ivy.jar.file}"/>
|
||||
<ivy:settings file="${ivy.settings.dir}/ivysettings.xml"/>
|
||||
<ivy:retrieve file="ivy.xml" conf="${ivy.conf}" />
|
||||
</target>
|
||||
|
||||
|
||||
|
|
@ -104,10 +101,7 @@
|
|||
</jar>
|
||||
|
||||
<jar jarfile="${dist}/GenomeAnalysisTK.jar">
|
||||
<fileset dir="build">
|
||||
<include name="**/gatk/**/*.class"/>
|
||||
<include name="**/alignment/**/*.class"/>
|
||||
</fileset>
|
||||
<fileset dir="build" includes="**/gatk/**/*.class"/>
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="org.broadinstitute.sting.gatk.CommandLineGATK"/>
|
||||
</manifest>
|
||||
|
|
@ -134,6 +128,7 @@
|
|||
<pathconvert property="jar.classpath" pathsep=" ">
|
||||
<flattenmapper/>
|
||||
<fileset dir="${dist}" includes="*.jar"/>
|
||||
<filelist files="GATKScala.jar"/>
|
||||
</pathconvert>
|
||||
|
||||
<jar jarfile="${dist}/StingUtils.jar" update="true">
|
||||
|
|
@ -186,54 +181,47 @@
|
|||
</javac>
|
||||
</target>
|
||||
|
||||
|
||||
<property name="scala.home" value="scala/installation"/>
|
||||
<property
|
||||
name="build.dir"
|
||||
value="${base.dir}/build"
|
||||
/>
|
||||
<target name="init.scala">
|
||||
<property
|
||||
name="scala-library.jar"
|
||||
value="${scala.home}/lib/scala-library.jar"
|
||||
/>
|
||||
<path id="build.classpath">
|
||||
<pathelement location="${scala-library.jar}" />
|
||||
<!--<pathelement location="${your.path}" />-->
|
||||
<pathelement location="${build.dir}" />
|
||||
<!-- new scala target -->
|
||||
|
||||
<target name="scala" description="build the scala directory">
|
||||
<antcall target="resolve">
|
||||
<param name="ivy.conf" value="scala"/>
|
||||
</antcall>
|
||||
<antcall target="dist"/>
|
||||
<property name="scala.src" value="scala/src" />
|
||||
<property name="scala.classes" value="scala/classes" />
|
||||
<pathconvert property="scalajar.classpath" pathsep=";">
|
||||
<flattenmapper/>
|
||||
<fileset dir="${basedir}" includes="dist/*.jar"/>
|
||||
</pathconvert>
|
||||
|
||||
<path id="scala.classpath">
|
||||
<pathelement location="lib/scala-compiler-2.7.7.jar"/>
|
||||
<pathelement location="lib/scala-library-2.7.7.jar"/>
|
||||
<fileset dir="${dist}">
|
||||
<patternset id="scalaStuff">
|
||||
<include name="*.jar"/>
|
||||
</patternset>
|
||||
</fileset>
|
||||
</path>
|
||||
<taskdef name="scalac" classname="scala.tools.ant.Scalac">
|
||||
<classpath>
|
||||
<pathelement location="${scala.home}/lib/scala-compiler.jar" />
|
||||
<pathelement location="${scala-library.jar}" />
|
||||
</classpath>
|
||||
</taskdef>
|
||||
<taskdef resource="scala/tools/ant/antlib.xml">
|
||||
<classpath refid="scala.classpath"/>
|
||||
</taskdef>
|
||||
<mkdir dir="${scala.classes}"/>
|
||||
<echo>Building Scala...</echo>
|
||||
<scalac srcdir="${scala.src}" destdir="${scala.classes}" classpathref="scala.classpath" force="changed">
|
||||
<include name="**/*.scala"/>
|
||||
</scalac>
|
||||
|
||||
<jar jarfile="${dist}/GATKScala.jar">
|
||||
<fileset dir="${scala.classes}">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<property name="scala.src" value="scala/src" />
|
||||
<property name="scala.classes" value="scala/classes" />
|
||||
<target name="scala" depends="init.scala" description="build the scala code">
|
||||
<echo message="Sting: Compiling scala!"/>
|
||||
<mkdir dir="${scala.classes}"/>
|
||||
|
||||
<scalac srcdir="${scala.src}" destdir="${scala.classes}" force="changed">
|
||||
<include name="**/*.scala"/>
|
||||
<classpath>
|
||||
<path refid="runtime.dependencies" />
|
||||
<pathelement location="build"/>
|
||||
<pathelement location="lib/junit-4.4.jar"/>
|
||||
<pathelement location="${scala.home}/lib/scala-compiler.jar" />
|
||||
<pathelement location="${scala-library.jar}" />
|
||||
</classpath>
|
||||
</scalac>
|
||||
|
||||
<delete file="${dist}/GATKScala.jar"/>
|
||||
<jar jarfile="${dist}/GATKScala.jar">
|
||||
<fileset dir="${scala.classes}">
|
||||
<include name="**/*.class"/>
|
||||
</fileset>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
|
||||
<!-- TEST -->
|
||||
<target name="test" depends="test.compile,agent" description="Run unit tests">
|
||||
|
|
@ -265,10 +253,13 @@
|
|||
<mkdir dir="${report}"/>
|
||||
<echo message="Sting: Running integration test cases!"/>
|
||||
<junit printsummary="yes" showoutput="yes" clonevm="yes" haltonfailure="yes" failureProperty="test.failure">
|
||||
|
||||
<jvmarg value="-Xdebug"/>
|
||||
<jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8090"/>
|
||||
<formatter type="${testOutput}" usefile="${usefile}" />
|
||||
<classpath>
|
||||
<path refid="runtime.dependencies"/>
|
||||
<pathelement location="build"/>
|
||||
<pathelement location="${dist}/GenomeAnalysisTK.jar"/>
|
||||
<pathelement location="${test.classes}"/>
|
||||
<pathelement location="lib/junit-4.4.jar"/>
|
||||
</classpath>
|
||||
|
|
|
|||
41
ivy.xml
41
ivy.xml
|
|
@ -1,21 +1,30 @@
|
|||
|
||||
<ivy-module version="1.0">
|
||||
<info organisation="org.broadinstitute" module="Sting"/>
|
||||
<dependencies>
|
||||
<dependency org="net.sf" name="sam" rev="latest.integration" />
|
||||
<dependency org="net.sf" name="picard" rev="latest.integration" />
|
||||
<dependency org="edu.mit.broad" name="picard-private" rev="latest.integration" />
|
||||
<dependency org="junit" name="junit" rev="4.4" />
|
||||
<dependency org="log4j" name="log4j" rev="1.2.15" />
|
||||
<dependency org="colt" name="colt" rev="1.2.0" />
|
||||
<dependency org="jboss" name="javassist" rev="3.7.ga" />
|
||||
<dependency org="org.simpleframework" name="simple-xml" rev="2.0.4" />
|
||||
<dependency org="org.apache.bcel" name="bcel" rev="5.2" />
|
||||
|
||||
<configurations>
|
||||
<conf name="default" description="the core dependencies for the GATK"/>
|
||||
<conf name="scala" extends="default" description="the dependencies for scala"/>
|
||||
</configurations>
|
||||
<dependencies defaultconf="default">
|
||||
<dependency org="net.sf" name="sam" rev="latest.integration" conf="default"/>
|
||||
<dependency org="net.sf" name="picard" rev="latest.integration" conf="default"/>
|
||||
<dependency org="edu.mit.broad" name="picard-private" rev="latest.integration" conf="default"/>
|
||||
<dependency org="junit" name="junit" rev="4.4" conf="default"/>
|
||||
<dependency org="log4j" name="log4j" rev="1.2.15" conf="default"/>
|
||||
<dependency org="colt" name="colt" rev="1.2.0" conf="default"/>
|
||||
<dependency org="jboss" name="javassist" rev="3.7.ga" conf="default"/>
|
||||
<dependency org="org.simpleframework" name="simple-xml" rev="2.0.4" conf="default"/>
|
||||
<dependency org="org.apache.bcel" name="bcel" rev="5.2" conf="default"/>
|
||||
|
||||
<!-- Dependencies for reflections mvn repository -->
|
||||
<dependency org="org.reflections" name="reflections" rev="0.9.2" />
|
||||
<dependency org="com.google.collections" name="google-collections" rev="0.9" />
|
||||
|
||||
<!-- JGraph -->
|
||||
<dependency org="org.jgrapht" name="jgrapht-jdk1.5" rev="0.7.3" />
|
||||
<dependency org="org.reflections" name="reflections" rev="0.9.2" conf="default"/>
|
||||
<dependency org="com.google.collections" name="google-collections" rev="0.9" conf="default"/>
|
||||
|
||||
<!-- Dependencies for the graph aligner -->
|
||||
<dependency org="org.jgrapht" name="jgrapht-jdk1.5" rev="0.7.3" conf="default"/>
|
||||
|
||||
<!-- Scala dependancies -->
|
||||
<dependency org="org.scala-lang" name="scala-compiler" rev="2.7.7" conf="scala->default"/>
|
||||
<dependency org="org.scala-lang" name="scala-library" rev="2.7.7" conf="scala->default"/>
|
||||
</dependencies>
|
||||
</ivy-module>
|
||||
|
|
|
|||
|
|
@ -3,16 +3,30 @@ package org.broadinstitute.sting.utils;
|
|||
import org.reflections.Reflections;
|
||||
import org.reflections.scanners.SubTypesScanner;
|
||||
import org.reflections.util.AbstractConfiguration;
|
||||
import org.reflections.util.ClasspathHelper;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* PackageUtils contains some useful methods for package introspection.
|
||||
*/
|
||||
public class PackageUtils {
|
||||
/**
|
||||
* our log, which we want to capture anything from this class
|
||||
*/
|
||||
private static Logger logger = Logger.getLogger(PackageUtils.class);
|
||||
|
||||
/**
|
||||
* A reference into our introspection utility.
|
||||
*/
|
||||
|
|
@ -20,9 +34,9 @@ public class PackageUtils {
|
|||
|
||||
static {
|
||||
// Initialize general-purpose source tree reflector.
|
||||
reflections = new Reflections( new AbstractConfiguration() {
|
||||
reflections = new Reflections(new AbstractConfiguration() {
|
||||
{
|
||||
setUrls(ClasspathHelper.getUrlsForCurrentClasspath());
|
||||
setUrls(PackageUtils.getUrlsForClasspath(System.getProperty("java.class.path")));
|
||||
setScanners(new SubTypesScanner());
|
||||
}
|
||||
});
|
||||
|
|
@ -31,25 +45,116 @@ public class PackageUtils {
|
|||
/**
|
||||
* Private constructor. No instantiating this class!
|
||||
*/
|
||||
private PackageUtils() {}
|
||||
private PackageUtils() {
|
||||
}
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the classes that implement the specified interface.
|
||||
*
|
||||
* @param iface the interface which returned classes should implement.
|
||||
* @return the list of classes that implement the interface.
|
||||
* @param iface the interface which returned classes should implement.
|
||||
* @return the list of classes that implement the interface.
|
||||
*/
|
||||
public static <T> List<Class<? extends T>> getClassesImplementingInterface(Class<T> iface) {
|
||||
// Load all classes implementing the given interface, then filter out any class that isn't concrete.
|
||||
Set<Class<? extends T>> allTypes = reflections.getSubTypesOf(iface);
|
||||
List<Class<? extends T>> concreteTypes = new ArrayList<Class<? extends T>>();
|
||||
for( Class<? extends T> type: allTypes ) {
|
||||
if( JVMUtils.isConcrete(type) )
|
||||
for (Class<? extends T> type : allTypes) {
|
||||
if (JVMUtils.isConcrete(type))
|
||||
concreteTypes.add(type);
|
||||
}
|
||||
|
||||
return concreteTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* get a list of URL's, given the current classpath. This function is a fix for the
|
||||
* reflections package, which doesn't correctly expand the classpath from a jar (it doesn't
|
||||
* get the manifest and parse out the embedded classpth).
|
||||
* @param classpath the current classpath
|
||||
* @return
|
||||
*/
|
||||
public static Collection<URL> getUrlsForClasspath(String classpath) {
|
||||
// if the classpath is null, we can't really do anything
|
||||
if (classpath == null || classpath.equals(""))
|
||||
throw new StingException("Classpath cannot be empty or null");
|
||||
List<URL> urls = Lists.newArrayList();
|
||||
|
||||
// the current working directory
|
||||
String baseDir = System.getProperty("user.dir");
|
||||
|
||||
// our collection of classpath's to expand
|
||||
List<JarPath> javaClassPath = new ArrayList<JarPath>();
|
||||
|
||||
// the current classpath can be a list of path's seperated by a semicolon
|
||||
String[] classPaths = classpath.split(File.pathSeparator);
|
||||
for (String part : classPaths) {
|
||||
extractJarClasspath(baseDir, javaClassPath, part);
|
||||
}
|
||||
|
||||
// check to make sure each extracted path exists, if so add it to our list
|
||||
if (javaClassPath.size() > 0)
|
||||
for (JarPath path : javaClassPath) {
|
||||
try {
|
||||
if (path.isValid())
|
||||
urls.add(path.toValidFile().toURL());
|
||||
} catch (MalformedURLException e) {
|
||||
throw new StingException("could not create url from " + path, e);
|
||||
}
|
||||
}
|
||||
|
||||
return urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* extract the classpath from a jar
|
||||
*
|
||||
* @param baseDir the base
|
||||
* @param javaClassPath the list of jar paths
|
||||
* @param part the current the subsection of the classpath we're processing
|
||||
*/
|
||||
private static void extractJarClasspath(String baseDir, List<JarPath> javaClassPath, String part) {
|
||||
try {
|
||||
JarFile myJar = new JarFile(part);
|
||||
Attributes.Name classPath = new Attributes.Name("Class-Path");
|
||||
if (myJar.getManifest().getMainAttributes().containsKey(classPath)) {
|
||||
for (String jar : myJar.getManifest().getMainAttributes().getValue(classPath).split(" "))
|
||||
javaClassPath.add(new JarPath(baseDir, new File(part).getParent(), jar));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
logger.warn("could not retreive manifest from " + part);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* a simple helper class, to determine the absolute path to a jar file
|
||||
*/
|
||||
static class JarPath {
|
||||
private final String mPath;
|
||||
private final String mFilename;
|
||||
private final String mWorkingDir;
|
||||
|
||||
public JarPath(String workingDir, String path, String filename) {
|
||||
this.mPath = path;
|
||||
this.mFilename = filename;
|
||||
mWorkingDir = workingDir;
|
||||
}
|
||||
|
||||
public File toValidFile() {
|
||||
if (new File(mFilename).exists())
|
||||
return new File(mFilename);
|
||||
if (new File(mPath + File.separator + mFilename).exists())
|
||||
return new File(mPath + File.separator + mFilename);
|
||||
if (new File(mWorkingDir + File.separator + mFilename).exists())
|
||||
return new File(mWorkingDir + File.separator + mFilename);
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return (toValidFile() != null) ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package org.broadinstitute.sting.scala
|
||||
/**package org.broadinstitute.sting.scala
|
||||
|
||||
import gatk.walkers.genotyper.{UnifiedGenotyper, GenotypeCall}
|
||||
import java.io.File
|
||||
|
|
@ -68,7 +68,7 @@ class TransitionTable() {
|
|||
}
|
||||
}
|
||||
|
||||
class BaseTransitionTableCalculator extends LocusWalker[Unit,Int] {
|
||||
class BaseTransitionTableCalculator { // extends LocusWalker[Unit,Int] {
|
||||
private var MIN_MAPPING_QUALITY = 30
|
||||
private var MIN_BASE_QUALITY = 20
|
||||
private var MIN_LOD = 5
|
||||
|
|
@ -208,3 +208,4 @@ class BaseTransitionTableCalculator extends LocusWalker[Unit,Int] {
|
|||
print1("1-mismatch-rev", tableREV)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
@ -5,9 +5,8 @@ import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker
|
|||
import org.broadinstitute.sting.gatk.contexts.ReferenceContext
|
||||
import org.broadinstitute.sting.gatk.contexts.AlignmentContext
|
||||
|
||||
class PrintReadsScala extends LocusWalker[Int,Int] {
|
||||
class ScalaCountLoci extends LocusWalker[Int,Int] {
|
||||
override def map(tracker: RefMetaDataTracker, ref: ReferenceContext, context: AlignmentContext): Int = {
|
||||
//println(context.getReads().size())
|
||||
return 1
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue