First step in replacing the Hello, World! document. Revamped the HelloWalker and checked it into the source tree, created a special build file for it, and added it to the packaging tool.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1135 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
fdff233d70
commit
e93f751bd7
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2009 The Broad Institute
|
||||||
|
* Permission is hereby granted, free of charge, to any person
|
||||||
|
* obtaining a copy of this software and associated documentation
|
||||||
|
* files (the "Software"), to deal in the Software without
|
||||||
|
* restriction, including without limitation the rights to use,
|
||||||
|
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
* copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following
|
||||||
|
* conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be
|
||||||
|
* included in all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
* OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
|
||||||
|
import org.broadinstitute.sting.gatk.LocusContext;
|
||||||
|
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An example walker for illustrative purposes.
|
||||||
|
*/
|
||||||
|
public class HelloWalker extends LocusWalker<Integer,Long> {
|
||||||
|
/**
|
||||||
|
* The map function runs once per single-base locus, and accepts a 'context', a
|
||||||
|
* data structure consisting of the reads which overlap the locus, the sites over
|
||||||
|
* which they fall, and the base from the reference that overlaps.
|
||||||
|
* @param tracker The accessor for reference metadata.
|
||||||
|
* @param ref The reference base that lines up with this locus.
|
||||||
|
* @param context Information about reads overlapping this locus.
|
||||||
|
* @return In this case, returns a count of how many loci were seen at this site (1).
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Integer map(RefMetaDataTracker tracker, char ref, LocusContext context) {
|
||||||
|
out.printf("Hello locus %s; your ref base is %c and you have %d reads%n", context.getLocation(), ref, context.getReads().size() );
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides an initial value for the reduce function. Hello walker counts loci,
|
||||||
|
* so the base case for the inductive step is 0, indicating that the walker has seen 0 loci.
|
||||||
|
* @return 0.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Long reduceInit() { return 0L; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Combines the result of the latest map with the accumulator. In inductive terms,
|
||||||
|
* this represents the step loci[x + 1] = loci[x] + 1
|
||||||
|
* @param value result of the map.
|
||||||
|
* @param sum accumulator for the reduce.
|
||||||
|
* @return The total count of loci processed so far.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Long reduce(Integer value, Long sum) {
|
||||||
|
return sum + value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the final result of the traversal.
|
||||||
|
* @param result The ultimate value of the traversal, produced when map[n] is combined with reduce[n-1]
|
||||||
|
* by the reduce function.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onTraversalDone(Long result) {
|
||||||
|
out.println("Number of loci viewed is: " + result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,40 @@
|
||||||
|
<!--
|
||||||
|
~ Copyright (c) 2009 The Broad Institute
|
||||||
|
~ Permission is hereby granted, free of charge, to any person
|
||||||
|
~ obtaining a copy of this software and associated documentation
|
||||||
|
~ files (the "Software"), to deal in the Software without
|
||||||
|
~ restriction, including without limitation the rights to use,
|
||||||
|
~ copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
~ copies of the Software, and to permit persons to whom the
|
||||||
|
~ Software is furnished to do so, subject to the following
|
||||||
|
~ conditions:
|
||||||
|
~
|
||||||
|
~ The above copyright notice and this permission notice shall be
|
||||||
|
~ included in all copies or substantial portions of the Software.
|
||||||
|
~
|
||||||
|
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
~ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||||
|
~ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
~ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||||
|
~ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
~ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
~ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||||
|
~ OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<project name="BuildHelloWalker" default="dist" basedir=".">
|
||||||
|
<description>Build the GATK examples</description>
|
||||||
|
|
||||||
|
<property name="gatk.home" value="${user.home}/GenomeAnalysisTK" />
|
||||||
|
<property name="walker.home" value="${gatk.home}/walkers" />
|
||||||
|
|
||||||
|
<target name="dist">
|
||||||
|
<mkdir dir="${walker.home}" />
|
||||||
|
<javac srcdir="${basedir}" destdir="${walker.home}">
|
||||||
|
<classpath>
|
||||||
|
<fileset dir="${gatk.home}" includes="GenomeAnalysisTK.jar" />
|
||||||
|
</classpath>
|
||||||
|
</javac>
|
||||||
|
</target>
|
||||||
|
|
||||||
|
</project>
|
||||||
|
|
@ -7,4 +7,8 @@
|
||||||
<class>org.broadinstitute.sting.gatk.walkers.PileupWalker</class>
|
<class>org.broadinstitute.sting.gatk.walkers.PileupWalker</class>
|
||||||
<class>org.broadinstitute.sting.gatk.walkers.PrintReadsWalker</class>
|
<class>org.broadinstitute.sting.gatk.walkers.PrintReadsWalker</class>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
<resources>
|
||||||
|
<file>java/src/org/broadinstitute/sting/gatk/examples/HelloWalker.java</file>
|
||||||
|
<file>java/src/org/broadinstitute/sting/gatk/examples/build.xml</file>
|
||||||
|
</resources>
|
||||||
</package>
|
</package>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue