diff --git a/build.xml b/build.xml
index fe4c7a3f4..fc495f7cc 100644
--- a/build.xml
+++ b/build.xml
@@ -79,6 +79,17 @@
+
+
+
+
+
+
+
+
+
+
+
@@ -457,6 +468,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -957,6 +988,12 @@
+
+
diff --git a/ivy.xml b/ivy.xml
index 3f3d1c97f..a394aa6d7 100644
--- a/ivy.xml
+++ b/ivy.xml
@@ -30,6 +30,9 @@
+
+
+
diff --git a/public/c/bwa/build_linux.sh b/public/c/bwa/build_linux.sh
index c713f3963..b3631a28d 100755
--- a/public/c/bwa/build_linux.sh
+++ b/public/c/bwa/build_linux.sh
@@ -1,5 +1,5 @@
#!/bin/sh
-export BWA_HOME="/humgen/gsa-scr1/hanna/src/bwa"
+export BWA_HOME="/humgen/gsa-scr1/hanna/src/bwa-trunk/bwa"
export JAVA_INCLUDE="/broad/tools/Linux/x86_64/pkgs/jdk_1.6.0_12/include -I/broad/tools/Linux/x86_64/pkgs/jdk_1.6.0_12/include/linux"
export TARGET_LIB="libbwa.so"
export EXTRA_LIBS="-lc -lz -lstdc++ -lpthread"
diff --git a/public/c/bwa/bwa_gateway.cpp b/public/c/bwa/bwa_gateway.cpp
index 3f6850e37..00f5aa5bc 100644
--- a/public/c/bwa/bwa_gateway.cpp
+++ b/public/c/bwa/bwa_gateway.cpp
@@ -1,5 +1,6 @@
#include
#include
+#include
#include "bwase.h"
#include "bwa_gateway.h"
@@ -27,6 +28,9 @@ BWA::BWA(const char* ann_filename,
bwt_restore_sa(reverse_sa_filename, bwts[1]);
load_default_options();
+ // Always reinitialize the random seed whenever a new set of files are loaded.
+ initialize_random_seed();
+
// initialize the bwase subsystem
bwase_initialize();
}
@@ -207,6 +211,11 @@ void BWA::load_default_options()
options.trim_qual = 0;
}
+void BWA::initialize_random_seed()
+{
+ srand48(bns->seed);
+}
+
void BWA::set_max_edit_distance(float edit_distance) {
if(edit_distance > 0 && edit_distance < 1) {
options.fnr = edit_distance;
diff --git a/public/c/bwa/bwa_gateway.h b/public/c/bwa/bwa_gateway.h
index 0ef0a129b..2d26ec650 100644
--- a/public/c/bwa/bwa_gateway.h
+++ b/public/c/bwa/bwa_gateway.h
@@ -37,6 +37,7 @@ class BWA {
gap_opt_t options;
void load_default_options();
+ void initialize_random_seed();
bwa_seq_t* create_sequence(const char* bases, const unsigned read_length);
void copy_bases_into_sequence(bwa_seq_t* sequence, const char* bases, const unsigned read_length);
Alignment generate_final_alignment_from_sequence(bwa_seq_t* sequence);
diff --git a/public/c/bwa/libbwa.so.1 b/public/c/bwa/libbwa.so.1
deleted file mode 100755
index bfa3c2847..000000000
Binary files a/public/c/bwa/libbwa.so.1 and /dev/null differ
diff --git a/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java b/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java
index aba4fc109..d88e7030e 100644
--- a/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java
+++ b/public/java/src/org/broadinstitute/sting/commandline/CommandLineProgram.java
@@ -43,7 +43,7 @@ import java.util.Locale;
public abstract class CommandLineProgram {
/** The command-line program and the arguments it returned. */
- protected ParsingEngine parser = null;
+ public ParsingEngine parser = null;
/** the default log level */
@Argument(fullName = "logging_level",
@@ -144,6 +144,11 @@ public abstract class CommandLineProgram {
public static int result = -1;
+ @SuppressWarnings("unchecked")
+ public static void start(CommandLineProgram clp, String[] args) throws Exception {
+ start(clp, args, false);
+ }
+
/**
* This function is called to start processing the command line, and kick
* off the execute message of the program.
@@ -153,7 +158,7 @@ public abstract class CommandLineProgram {
* @throws Exception when an exception occurs
*/
@SuppressWarnings("unchecked")
- public static void start(CommandLineProgram clp, String[] args) throws Exception {
+ public static void start(CommandLineProgram clp, String[] args, boolean dryRun) throws Exception {
try {
// setup our log layout
@@ -180,8 +185,9 @@ public abstract class CommandLineProgram {
// - InvalidArgument in case these arguments are specified by plugins.
// - MissingRequiredArgument in case the user requested help. Handle that later, once we've
// determined the full complement of arguments.
- parser.validate(EnumSet.of(ParsingEngine.ValidationType.MissingRequiredArgument,
- ParsingEngine.ValidationType.InvalidArgument));
+ if ( ! dryRun )
+ parser.validate(EnumSet.of(ParsingEngine.ValidationType.MissingRequiredArgument,
+ ParsingEngine.ValidationType.InvalidArgument));
parser.loadArgumentsIntoObject(clp);
// Initialize the logger using the loaded command line.
@@ -195,36 +201,40 @@ public abstract class CommandLineProgram {
if (isHelpPresent(parser))
printHelpAndExit(clp, parser);
- parser.validate();
+ if ( ! dryRun ) parser.validate();
} else {
parser.parse(args);
- if (isHelpPresent(parser))
- printHelpAndExit(clp, parser);
+ if ( ! dryRun ) {
+ if (isHelpPresent(parser))
+ printHelpAndExit(clp, parser);
- parser.validate();
+ parser.validate();
+ }
parser.loadArgumentsIntoObject(clp);
// Initialize the logger using the loaded command line.
clp.setupLoggerLevel(layout);
}
- // if they specify a log location, output our data there
- if (clp.toFile != null) {
- FileAppender appender;
- try {
- appender = new FileAppender(layout, clp.toFile, false);
- logger.addAppender(appender);
- } catch (IOException e) {
- throw new RuntimeException("Unable to re-route log output to " + clp.toFile + " make sure the destination exists");
+ if ( ! dryRun ) {
+ // if they specify a log location, output our data there
+ if (clp.toFile != null) {
+ FileAppender appender;
+ try {
+ appender = new FileAppender(layout, clp.toFile, false);
+ logger.addAppender(appender);
+ } catch (IOException e) {
+ throw new RuntimeException("Unable to re-route log output to " + clp.toFile + " make sure the destination exists");
+ }
}
+
+ // regardless of what happens next, generate the header information
+ HelpFormatter.generateHeaderInformation(clp.getApplicationDetails(), args);
+
+ // call the execute
+ CommandLineProgram.result = clp.execute();
}
-
- // regardless of what happens next, generate the header information
- HelpFormatter.generateHeaderInformation(clp.getApplicationDetails(), args);
-
- // call the execute
- CommandLineProgram.result = clp.execute();
}
catch (ArgumentException e) {
clp.parser.printHelp(clp.getApplicationDetails());
diff --git a/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java b/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java
index 279aed396..b7efcd278 100755
--- a/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java
+++ b/public/java/src/org/broadinstitute/sting/commandline/ParsingEngine.java
@@ -50,7 +50,7 @@ public class ParsingEngine {
* A list of defined arguments against which command lines are matched.
* Package protected for testing access.
*/
- ArgumentDefinitions argumentDefinitions = new ArgumentDefinitions();
+ public ArgumentDefinitions argumentDefinitions = new ArgumentDefinitions();
/**
* A list of matches from defined arguments to command-line text.
diff --git a/public/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java b/public/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java
index da2be74bf..2af29ea70 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/CommandLineGATK.java
@@ -30,25 +30,27 @@ import org.broadinstitute.sting.commandline.Argument;
import org.broadinstitute.sting.commandline.ArgumentCollection;
import org.broadinstitute.sting.commandline.CommandLineProgram;
import org.broadinstitute.sting.gatk.arguments.GATKArgumentCollection;
+import org.broadinstitute.sting.gatk.filters.ReadFilter;
import org.broadinstitute.sting.gatk.walkers.Attribution;
import org.broadinstitute.sting.gatk.walkers.Walker;
import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.help.ApplicationDetails;
+import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
import java.util.*;
/**
- * @author aaron
- * @version 1.0
- * @date May 8, 2009
- *
- * Class CommandLineGATK
- *
+ * The GATK engine itself. Manages map/reduce data access and runs walkers.
+ *
* We run command line GATK programs using this class. It gets the command line args, parses them, and hands the
* gatk all the parsed out information. Pretty much anything dealing with the underlying system should go here,
* the gatk engine should deal with any data related information.
*/
+@DocumentedGATKFeature(
+ groupName = "GATK Engine",
+ summary = "Features and arguments for the GATK engine itself, available to all walkers.",
+ extraDocs = { ReadFilter.class, UserException.class })
public class CommandLineGATK extends CommandLineExecutable {
@Argument(fullName = "analysis_type", shortName = "T", doc = "Type of analysis to run")
private String analysisName = null;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/WalkerManager.java b/public/java/src/org/broadinstitute/sting/gatk/WalkerManager.java
index cf190835e..6aeb42faa 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/WalkerManager.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/WalkerManager.java
@@ -33,9 +33,7 @@ import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.baq.BAQ;
import org.broadinstitute.sting.utils.classloader.PluginManager;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
-import org.broadinstitute.sting.utils.help.DescriptionTaglet;
-import org.broadinstitute.sting.utils.help.DisplayNameTaglet;
-import org.broadinstitute.sting.utils.help.SummaryTaglet;
+import org.broadinstitute.sting.utils.help.ResourceBundleExtractorDoclet;
import org.broadinstitute.sting.utils.text.TextFormattingUtils;
import java.util.*;
@@ -82,19 +80,10 @@ public class WalkerManager extends PluginManager {
* @return A suitable display name for the package.
*/
public String getPackageDisplayName(String packageName) {
- // Try to find an override for the display name of this package.
- String displayNameKey = String.format("%s.%s",packageName,DisplayNameTaglet.NAME);
- String displayName;
- if(helpText.containsKey(displayNameKey)) {
- displayName = helpText.getString(displayNameKey);
- }
- else {
- // If no override exists...
- // ...try to compute the override from the text of the package name, while accounting for
- // unpackaged walkers.
- displayName = packageName.substring(packageName.lastIndexOf('.')+1);
- if(displayName.trim().equals("")) displayName = "";
- }
+ // ...try to compute the override from the text of the package name, while accounting for
+ // unpackaged walkers.
+ String displayName = packageName.substring(packageName.lastIndexOf('.')+1);
+ if (displayName.trim().equals("")) displayName = "";
return displayName;
}
@@ -104,7 +93,7 @@ public class WalkerManager extends PluginManager {
* @return Package help text, or "" if none exists.
*/
public String getPackageSummaryText(String packageName) {
- String key = String.format("%s.%s",packageName,SummaryTaglet.NAME);
+ String key = String.format("%s.%s",packageName, ResourceBundleExtractorDoclet.SUMMARY_TAGLET_NAME);
if(!helpText.containsKey(key))
return "";
return helpText.getString(key);
@@ -116,7 +105,7 @@ public class WalkerManager extends PluginManager {
* @return Walker summary description, or "" if none exists.
*/
public String getWalkerSummaryText(Class extends Walker> walkerType) {
- String walkerSummary = String.format("%s.%s",walkerType.getName(), SummaryTaglet.NAME);
+ String walkerSummary = String.format("%s.%s",walkerType.getName(), ResourceBundleExtractorDoclet.SUMMARY_TAGLET_NAME);
if(!helpText.containsKey(walkerSummary))
return "";
return helpText.getString(walkerSummary);
@@ -137,7 +126,7 @@ public class WalkerManager extends PluginManager {
* @return Walker full description, or "" if none exists.
*/
public String getWalkerDescriptionText(Class extends Walker> walkerType) {
- String walkerDescription = String.format("%s.%s",walkerType.getName(), DescriptionTaglet.NAME);
+ String walkerDescription = String.format("%s.%s",walkerType.getName(), ResourceBundleExtractorDoclet.DESCRIPTION_TAGLET_NAME);
if(!helpText.containsKey(walkerDescription))
return "";
return helpText.getString(walkerDescription);
diff --git a/public/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java b/public/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java
index 9466fdf75..48fd73e0b 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/executive/LinearMicroScheduler.java
@@ -49,7 +49,7 @@ public class LinearMicroScheduler extends MicroScheduler {
Accumulator accumulator = Accumulator.create(engine,walker);
int counter = 0;
- for (Shard shard : processingTracker.onlyOwned(shardStrategy, engine.getName())) {
+ for (Shard shard : shardStrategy ) {
if ( shard == null ) // we ran out of shards that aren't owned
break;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/executive/MicroScheduler.java b/public/java/src/org/broadinstitute/sting/gatk/executive/MicroScheduler.java
index 23e5769f1..e731b9864 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/executive/MicroScheduler.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/executive/MicroScheduler.java
@@ -39,14 +39,10 @@ import org.broadinstitute.sting.gatk.traversals.*;
import org.broadinstitute.sting.gatk.walkers.*;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
import org.broadinstitute.sting.utils.exceptions.UserException;
-import org.broadinstitute.sting.utils.threading.*;
import javax.management.JMException;
import javax.management.MBeanServer;
import javax.management.ObjectName;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.PrintStream;
import java.lang.management.ManagementFactory;
import java.util.Collection;
@@ -83,8 +79,6 @@ public abstract class MicroScheduler implements MicroSchedulerMBean {
private final MBeanServer mBeanServer;
private final ObjectName mBeanName;
- protected GenomeLocProcessingTracker processingTracker;
-
/**
* MicroScheduler factory function. Create a microscheduler appropriate for reducing the
* selected walker.
@@ -98,11 +92,6 @@ public abstract class MicroScheduler implements MicroSchedulerMBean {
* @return The best-fit microscheduler.
*/
public static MicroScheduler create(GenomeAnalysisEngine engine, Walker walker, SAMDataSource reads, IndexedFastaSequenceFile reference, Collection rods, int nThreadsToUse) {
- if (engine.getArguments().processingTrackerFile != null) {
- if ( walker instanceof ReadWalker )
- throw new UserException.BadArgumentValue("C", String.format("Distributed GATK processing not enabled for read walkers"));
- }
-
if (walker instanceof TreeReducible && nThreadsToUse > 1) {
if(walker.isReduceByInterval())
throw new UserException.BadArgumentValue("nt", String.format("The analysis %s aggregates results by interval. Due to a current limitation of the GATK, analyses of this type do not currently support parallel execution. Please run your analysis without the -nt option.", engine.getWalkerName(walker.getClass())));
@@ -157,33 +146,6 @@ public abstract class MicroScheduler implements MicroSchedulerMBean {
catch (JMException ex) {
throw new ReviewedStingException("Unable to register microscheduler with JMX", ex);
}
-
- //
- // create the processing tracker
- //
- if ( engine.getArguments().processingTrackerFile != null ) {
- logger.warn("Distributed GATK is an experimental engine feature, and is likely to not work correctly or reliably.");
- if ( engine.getArguments().restartProcessingTracker && engine.getArguments().processingTrackerFile.exists() ) {
- engine.getArguments().processingTrackerFile.delete();
- logger.info("Deleting ProcessingTracker file " + engine.getArguments().processingTrackerFile);
- }
-
- PrintStream statusStream = null;
- if ( engine.getArguments().processingTrackerStatusFile != null ) {
- try {
- statusStream = new PrintStream(new FileOutputStream(engine.getArguments().processingTrackerStatusFile));
- } catch ( FileNotFoundException e) {
- throw new UserException.CouldNotCreateOutputFile(engine.getArguments().processingTrackerStatusFile, e);
- }
- }
-
- ClosableReentrantLock lock = new SharedFileThreadSafeLock(engine.getArguments().processingTrackerFile, engine.getArguments().processTrackerID);
- processingTracker = new FileBackedGenomeLocProcessingTracker(engine.getArguments().processingTrackerFile, engine.getGenomeLocParser(), lock, statusStream) ;
- logger.info("Creating ProcessingTracker using shared file " + engine.getArguments().processingTrackerFile + " process.id = " + engine.getName() + " CID = " + engine.getArguments().processTrackerID);
- } else {
- // create a NoOp version that doesn't do anything but say "yes"
- processingTracker = new NoOpGenomeLocProcessingTracker();
- }
}
/**
diff --git a/public/java/src/org/broadinstitute/sting/gatk/filters/ReadFilter.java b/public/java/src/org/broadinstitute/sting/gatk/filters/ReadFilter.java
index 227637761..bf3ce352a 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/filters/ReadFilter.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/filters/ReadFilter.java
@@ -2,10 +2,14 @@ package org.broadinstitute.sting.gatk.filters;
import net.sf.picard.filter.SamRecordFilter;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
+import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
/**
* A SamRecordFilter that also depends on the header.
*/
+@DocumentedGATKFeature(
+ groupName = "Read filters",
+ summary = "GATK Engine arguments that filter or transfer incoming SAM/BAM data files" )
public abstract class ReadFilter implements SamRecordFilter {
/**
* Sets the header for use by this filter.
diff --git a/public/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java b/public/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java
index 69c0b3e0a..acee1a6a3 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/phonehome/GATKRunReport.java
@@ -154,9 +154,13 @@ public class GATKRunReport {
private long nReads;
public enum PhoneHomeOption {
+ /** Disable phone home */
NO_ET,
+ /** Standard option. Writes to local repository if it can be found, or S3 otherwise */
STANDARD,
+ /** Force output to STDOUT. For debugging only */
STDOUT,
+ /** Force output to S3. For debugging only */
AWS_S3 // todo -- remove me -- really just for testing purposes
}
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/ReadFilters.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/ReadFilters.java
index ff3b6d82f..5f11686a1 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/ReadFilters.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/ReadFilters.java
@@ -25,6 +25,7 @@
package org.broadinstitute.sting.gatk.walkers;
import net.sf.picard.filter.SamRecordFilter;
+import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
import java.lang.annotation.*;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/Walker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/Walker.java
index 384742302..9e261a0b1 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/Walker.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/Walker.java
@@ -26,11 +26,14 @@
package org.broadinstitute.sting.gatk.walkers;
import org.apache.log4j.Logger;
+import org.broadinstitute.sting.gatk.CommandLineGATK;
import org.broadinstitute.sting.gatk.GenomeAnalysisEngine;
import org.broadinstitute.sting.gatk.filters.MalformedReadFilter;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.baq.BAQ;
import org.broadinstitute.sting.utils.collections.Pair;
+import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
+import org.broadinstitute.sting.utils.help.GenericDocumentationHandler;
import java.util.List;
@@ -44,6 +47,10 @@ import java.util.List;
@ReadFilters(MalformedReadFilter.class)
@PartitionBy(PartitionType.NONE)
@BAQMode(QualityMode = BAQ.QualityMode.OVERWRITE_QUALS, ApplicationTime = BAQ.ApplicationTime.ON_INPUT)
+@DocumentedGATKFeature(
+ groupName = "GATK walkers",
+ summary = "General tools available for running on the command line as part of the GATK package",
+ extraDocs = {CommandLineGATK.class})
public abstract class Walker {
final protected static Logger logger = Logger.getLogger(Walker.class);
private GenomeAnalysisEngine toolkit;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java
index 3144098a8..784927ab4 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalance.java
@@ -42,7 +42,7 @@ import java.util.List;
import java.util.Map;
-public class AlleleBalance implements InfoFieldAnnotation {
+public class AlleleBalance extends InfoFieldAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java
index a99f87a70..f70a87dc5 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AlleleBalanceBySample.java
@@ -15,7 +15,7 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.*;
-public class AlleleBalanceBySample implements GenotypeAnnotation, ExperimentalAnnotation {
+public class AlleleBalanceBySample extends GenotypeAnnotation implements ExperimentalAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g) {
Double ratio = annotateSNP(stratifiedContext, vc, g);
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AnnotationByDepth.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AnnotationByDepth.java
index 6c14e7445..dc41dbc81 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AnnotationByDepth.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/AnnotationByDepth.java
@@ -8,7 +8,7 @@ import java.util.Map;
-public abstract class AnnotationByDepth implements InfoFieldAnnotation {
+public abstract class AnnotationByDepth extends InfoFieldAnnotation {
protected int annotationByVariantDepth(final Map genotypes, Map stratifiedContexts) {
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java
index 66416ce11..7cd159c5d 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/BaseCounts.java
@@ -46,7 +46,7 @@ import java.util.List;
import java.util.Map;
-public class BaseCounts implements InfoFieldAnnotation {
+public class BaseCounts extends InfoFieldAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java
index 74f7f9d80..9b30079d0 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ChromosomeCounts.java
@@ -43,7 +43,7 @@ import java.util.List;
import java.util.Map;
-public class ChromosomeCounts implements InfoFieldAnnotation, StandardAnnotation {
+public class ChromosomeCounts extends InfoFieldAnnotation implements StandardAnnotation {
private String[] keyNames = { VCFConstants.ALLELE_NUMBER_KEY, VCFConstants.ALLELE_COUNT_KEY, VCFConstants.ALLELE_FREQUENCY_KEY };
private VCFInfoHeaderLine[] descriptions = { new VCFInfoHeaderLine(VCFConstants.ALLELE_FREQUENCY_KEY, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Allele Frequency, for each ALT allele, in the same order as listed"),
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java
index c384e0d09..d8907c57f 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthOfCoverage.java
@@ -16,7 +16,7 @@ import java.util.List;
import java.util.Map;
-public class DepthOfCoverage implements InfoFieldAnnotation, StandardAnnotation {
+public class DepthOfCoverage extends InfoFieldAnnotation implements StandardAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java
index e3e8bc258..20513421d 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/DepthPerAlleleBySample.java
@@ -22,7 +22,7 @@ import java.util.List;
import java.util.Map;
-public class DepthPerAlleleBySample implements GenotypeAnnotation, StandardAnnotation {
+public class DepthPerAlleleBySample extends GenotypeAnnotation implements StandardAnnotation {
private static String REF_ALLELE = "REF";
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java
index 97ed221e7..e71febece 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/FisherStrand.java
@@ -42,7 +42,7 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.*;
-public class FisherStrand implements InfoFieldAnnotation, StandardAnnotation {
+public class FisherStrand extends InfoFieldAnnotation implements StandardAnnotation {
private static final String FS = "FS";
private static final double MIN_PVALUE = 1E-320;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java
index 48677bbe5..588d3e98a 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GCContent.java
@@ -16,7 +16,7 @@ import java.util.List;
import java.util.Map;
-public class GCContent implements InfoFieldAnnotation, ExperimentalAnnotation {
+public class GCContent extends InfoFieldAnnotation implements ExperimentalAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
double content = computeGCContent(ref);
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GLstats.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GLstats.java
index cca0ad4bc..862e12f7d 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GLstats.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/GLstats.java
@@ -23,7 +23,7 @@ import java.util.Map;
*/
// A set of annotations calculated directly from the GLs
-public class GLstats implements InfoFieldAnnotation, StandardAnnotation {
+public class GLstats extends InfoFieldAnnotation implements StandardAnnotation {
private static final int MIN_SAMPLES = 10;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java
index b175579f1..2196de389 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HaplotypeScore.java
@@ -48,7 +48,7 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.*;
-public class HaplotypeScore implements InfoFieldAnnotation, StandardAnnotation {
+public class HaplotypeScore extends InfoFieldAnnotation implements StandardAnnotation {
private final static boolean DEBUG = false;
private final static int MIN_CONTEXT_WING_SIZE = 10;
private final static int MAX_CONSENSUS_HAPLOTYPES_TO_CONSIDER = 50;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java
index d86728d5e..2d9424e98 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HardyWeinberg.java
@@ -18,7 +18,7 @@ import java.util.List;
import java.util.Map;
-public class HardyWeinberg implements InfoFieldAnnotation, WorkInProgressAnnotation {
+public class HardyWeinberg extends InfoFieldAnnotation implements WorkInProgressAnnotation {
private static final int MIN_SAMPLES = 10;
private static final int MIN_GENOTYPE_QUALITY = 10;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java
index 02efd854c..870e9992b 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/HomopolymerRun.java
@@ -16,7 +16,7 @@ import java.util.List;
import java.util.Map;
-public class HomopolymerRun implements InfoFieldAnnotation, StandardAnnotation {
+public class HomopolymerRun extends InfoFieldAnnotation implements StandardAnnotation {
private boolean ANNOTATE_INDELS = true;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java
index 2fd62ddf3..b1c16ba0d 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/IndelType.java
@@ -19,7 +19,7 @@ import java.util.*;
* Time: 11:47:33 AM
* To change this template use File | Settings | File Templates.
*/
-public class IndelType implements InfoFieldAnnotation, ExperimentalAnnotation {
+public class IndelType extends InfoFieldAnnotation implements ExperimentalAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java
index 1d999c531..5de9aaa3b 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/LowMQ.java
@@ -16,7 +16,7 @@ import java.util.List;
import java.util.Map;
-public class LowMQ implements InfoFieldAnnotation {
+public class LowMQ extends InfoFieldAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java
index f240d02bc..60bfe945f 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZero.java
@@ -18,7 +18,7 @@ import java.util.List;
import java.util.Map;
-public class MappingQualityZero implements InfoFieldAnnotation, StandardAnnotation {
+public class MappingQualityZero extends InfoFieldAnnotation implements StandardAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java
index 0ca53adf2..f2b7b72b9 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroBySample.java
@@ -49,7 +49,7 @@ import java.util.Map;
* Time: 6:46:25 PM
* To change this template use File | Settings | File Templates.
*/
-public class MappingQualityZeroBySample implements GenotypeAnnotation {
+public class MappingQualityZeroBySample extends GenotypeAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref,
AlignmentContext context, VariantContext vc, Genotype g) {
if ( g == null || !g.isCalled() )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroFraction.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroFraction.java
index 08a25a7e3..3a6c9dce9 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroFraction.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MappingQualityZeroFraction.java
@@ -18,7 +18,7 @@ import java.util.Map;
-public class MappingQualityZeroFraction implements InfoFieldAnnotation, ExperimentalAnnotation {
+public class MappingQualityZeroFraction extends InfoFieldAnnotation implements ExperimentalAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java
index 1c70a1b33..9f67acf65 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/NBaseCount.java
@@ -21,7 +21,7 @@ import java.util.Map;
* Date: 5/16/11
*/
-public class NBaseCount implements InfoFieldAnnotation {
+public class NBaseCount extends InfoFieldAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if( stratifiedContexts.size() == 0 )
return null;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java
index 2175d39e6..20bee9008 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/QualByDepth.java
@@ -16,7 +16,7 @@ import java.util.List;
import java.util.Map;
-public class QualByDepth extends AnnotationByDepth implements InfoFieldAnnotation, StandardAnnotation {
+public class QualByDepth extends AnnotationByDepth implements StandardAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java
index d52f07b58..d1d9871e7 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RMSMappingQuality.java
@@ -20,7 +20,7 @@ import java.util.List;
import java.util.Map;
-public class RMSMappingQuality implements InfoFieldAnnotation, StandardAnnotation {
+public class RMSMappingQuality extends InfoFieldAnnotation implements StandardAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java
index 5466828f6..643056c1d 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/RankSumTest.java
@@ -21,7 +21,7 @@ import java.util.Map;
-public abstract class RankSumTest implements InfoFieldAnnotation, StandardAnnotation {
+public abstract class RankSumTest extends InfoFieldAnnotation implements StandardAnnotation {
static final double INDEL_LIKELIHOOD_THRESH = 0.1;
static final boolean DEBUG = false;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java
index c56e2622d..f3e99235a 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/ReadDepthAndAllelicFractionBySample.java
@@ -52,7 +52,7 @@ import java.util.Map;
* Time: 3:59:27 PM
* To change this template use File | Settings | File Templates.
*/
-public class ReadDepthAndAllelicFractionBySample implements GenotypeAnnotation {
+public class ReadDepthAndAllelicFractionBySample extends GenotypeAnnotation {
private static String REF_ALLELE = "REF";
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SampleList.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SampleList.java
index ff9092a71..3712ca8ae 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SampleList.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SampleList.java
@@ -41,7 +41,7 @@ import java.util.List;
import java.util.Map;
-public class SampleList implements InfoFieldAnnotation {
+public class SampleList extends InfoFieldAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if ( vc.isMonomorphic() || !vc.hasGenotypes() )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java
index a4668eeb6..332b0226b 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/SpanningDeletions.java
@@ -16,7 +16,7 @@ import java.util.List;
import java.util.Map;
-public class SpanningDeletions implements InfoFieldAnnotation, StandardAnnotation {
+public class SpanningDeletions extends InfoFieldAnnotation implements StandardAnnotation {
public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) {
if ( stratifiedContexts.size() == 0 )
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/TechnologyComposition.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/TechnologyComposition.java
index b46d82d8b..626142cd2 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/TechnologyComposition.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/TechnologyComposition.java
@@ -24,7 +24,7 @@ import java.util.Map;
* Time: 3:14 PM
* To change this template use File | Settings | File Templates.
*/
-public class TechnologyComposition implements ExperimentalAnnotation,InfoFieldAnnotation {
+public class TechnologyComposition extends InfoFieldAnnotation implements ExperimentalAnnotation {
private String nSLX = "NumSLX";
private String n454 ="Num454";
private String nSolid = "NumSOLiD";
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java
index 05c1b3c52..0e8360484 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/genomicannotator/GenomicAnnotation.java
@@ -48,7 +48,7 @@ import java.util.Map.Entry;
*
* For details, see: http://www.broadinstitute.org/gsa/wiki/index.php/GenomicAnnotator
*/
-public class GenomicAnnotation implements InfoFieldAnnotation {
+public class GenomicAnnotation extends InfoFieldAnnotation {
public static final String CHR_COLUMN = "chr";
public static final String START_COLUMN = "start";
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java
index 57bc44ab8..e982582ee 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/GenotypeAnnotation.java
@@ -10,15 +10,12 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.List;
import java.util.Map;
-public interface GenotypeAnnotation {
+public abstract class GenotypeAnnotation extends VariantAnnotatorAnnotation {
// return annotations for the given contexts/genotype split by sample
- public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g);
-
- // return the FORMAT keys
- public List getKeyNames();
+ public abstract Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext stratifiedContext, VariantContext vc, Genotype g);
// return the descriptions used for the VCF FORMAT meta field
- public List getDescriptions();
-
+ public abstract List getDescriptions();
+
}
\ No newline at end of file
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java
index 4e850d01b..84438ccd8 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/InfoFieldAnnotation.java
@@ -3,21 +3,18 @@ package org.broadinstitute.sting.gatk.walkers.annotator.interfaces;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
+import org.broadinstitute.sting.gatk.walkers.annotator.VariantAnnotator;
import org.broadinstitute.sting.utils.codecs.vcf.VCFInfoHeaderLine;
+import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.List;
import java.util.Map;
-public interface InfoFieldAnnotation {
-
+public abstract class InfoFieldAnnotation extends VariantAnnotatorAnnotation {
// return annotations for the given contexts split by sample
- public Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc);
-
- // return the INFO keys
- public List getKeyNames();
+ public abstract Map annotate(RefMetaDataTracker tracker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc);
// return the descriptions used for the VCF INFO meta field
- public List getDescriptions();
-
+ public abstract List getDescriptions();
}
\ No newline at end of file
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/VariantAnnotatorAnnotation.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/VariantAnnotatorAnnotation.java
new file mode 100644
index 000000000..f33d61df9
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/interfaces/VariantAnnotatorAnnotation.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+package org.broadinstitute.sting.gatk.walkers.annotator.interfaces;
+
+import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
+import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
+import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
+import org.broadinstitute.sting.utils.codecs.vcf.VCFInfoHeaderLine;
+import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
+import org.broadinstitute.sting.utils.variantcontext.VariantContext;
+
+import java.util.List;
+import java.util.Map;
+
+@DocumentedGATKFeature(enable = true, groupName = "VariantAnnotator annotations", summary = "VariantAnnotator annotations")
+public abstract class VariantAnnotatorAnnotation {
+ // return the INFO keys
+ public abstract List getKeyNames();
+}
\ No newline at end of file
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffEngine.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffEngine.java
index 89e20dad1..5f8f19892 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffEngine.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffEngine.java
@@ -42,6 +42,7 @@ import java.util.*;
* Date: 7/4/11
* Time: 12:51 PM
* A generic engine for comparing tree-structured objects
+ *
*/
public class DiffEngine {
final protected static Logger logger = Logger.getLogger(DiffEngine.class);
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffObjectsWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffObjectsWalker.java
index fba6549fb..b679f967a 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffObjectsWalker.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/diffengine/DiffObjectsWalker.java
@@ -25,6 +25,7 @@
package org.broadinstitute.sting.gatk.walkers.diffengine;
import org.broadinstitute.sting.commandline.Argument;
+import org.broadinstitute.sting.commandline.Hidden;
import org.broadinstitute.sting.commandline.Output;
import org.broadinstitute.sting.gatk.contexts.AlignmentContext;
import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
@@ -34,45 +35,159 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
import java.io.File;
import java.io.PrintStream;
+import java.util.Arrays;
import java.util.List;
/**
+ * A generic engine for comparing tree-structured objects
+ *
* Compares two record-oriented files, itemizing specific difference between equivalent
* records in the two files. Reports both itemized and summarized differences.
+ *
+ * What are the summarized differences and the DiffObjectsWalker
+ *
+ * The GATK contains a summarizing difference engine that compares hierarchical data structures to emit:
+ *
+ *
A list of specific differences between the two data structures. This is similar to saying the value in field A in record 1 in file F differences from the value in field A in record 1 in file G.
+ *
A summarized list of differences ordered by frequency of the difference. This output is similar to saying field A in 50 records in files F and G differed.
+ *
+ *
+ *
+ * The GATK contains a private walker DiffObjects that allows you access to the DiffEngine capabilities on the command line. Simply provide the walker with the master and test files and it will emit summarized differences for you.
+ *
+ *
+ * Why?
+ *
+ * The reason for this system is that it allows you to compare two structured files -- such as BAMs and VCFs -- for common differences among them. This is primarily useful in regression testing or optimization, where you want to ensure that the differences are those that you expect and not any others.
+ *
+ *
Understanding the output
+ *
The DiffEngine system compares to two hierarchical data structures for specific differences in the values of named
+ * nodes. Suppose I have two trees:
+ *
+ * where every node in the tree is named, or is a raw value (here all leaf values are integers). The DiffEngine
+ * traverses these data structures by name, identifies equivalent nodes by fully qualified names
+ * (Tree1.A is distinct from Tree2.A, and determines where their values are equal (Tree1.A=1, Tree2.A=1, so they are).
+ * These itemized differences are listed as:
+ *
+ * This conceptually very similar to the output of the unix command line tool diff. What's nice about DiffEngine though
+ * is that it computes similarity among the itemized differences and displays the count of differences names
+ * in the system. In the above example, the field C is not equal three times, while the missing E in Tree1 occurs
+ * only once. So the summary is:
+ *
+ *
+ * *.B.C : 3
+ * *.B.E : 1
+ *
+ *
where the * operator indicates that any named field matches. This output is sorted by counts, and provides an
+ * immediate picture of the commonly occurring differences among the files.
+ *
+ * Below is a detailed example of two VCF fields that differ because of a bug in the AC, AF, and AN counting routines,
+ * detected by the integrationtest integration (more below). You can see that in the although there are many specific
+ * instances of these differences between the two files, the summarized differences provide an immediate picture that
+ * the AC, AF, and AN fields are the major causes of the differences.
+ *
+ *
* @author Mark DePristo
- * @version 0.1
+ * @since 7/4/11
*/
@Requires(value={})
public class DiffObjectsWalker extends RodWalker {
+ /**
+ * Writes out a file of the DiffEngine format:
+ *
+ * http://www.broadinstitute.org/gsa/wiki/index.php/DiffEngine
+ */
@Output(doc="File to which results should be written",required=true)
protected PrintStream out;
- @Argument(fullName="maxObjectsToRead", shortName="motr", doc="Max. number of objects to read from the files. -1 [default] means unlimited", required=false)
- int MAX_OBJECTS_TO_READ = -1;
-
- @Argument(fullName="maxDiffs", shortName="M", doc="Max. number of diffs to process", required=false)
- int MAX_DIFFS = 0;
-
- @Argument(fullName="maxCount1Diffs", shortName="M1", doc="Max. number of diffs occuring exactly once in the file to process", required=false)
- int MAX_COUNT1_DIFFS = 0;
-
- @Argument(fullName="minCountForDiff", shortName="MCFD", doc="Min number of observations for a records to display", required=false)
- int minCountForDiff = 1;
-
- @Argument(fullName="showItemizedDifferences", shortName="SID", doc="Should we enumerate all differences between the files?", required=false)
- boolean showItemizedDifferences = false;
-
+ /**
+ * The master file against which we will compare test. This is one of the two required
+ * files to do the comparison. Conceptually master is the original file contained the expected
+ * results, but this doesn't currently have an impact on the calculations, but might in the future.
+ */
@Argument(fullName="master", shortName="m", doc="Master file: expected results", required=true)
File masterFile;
+ /**
+ * The test file against which we will compare to the master. This is one of the two required
+ * files to do the comparison. Conceptually test is the derived file from master, but this
+ * doesn't currently have an impact on the calculations, but might in the future.
+ */
@Argument(fullName="test", shortName="t", doc="Test file: new results to compare to the master file", required=true)
File testFile;
- final DiffEngine diffEngine = new DiffEngine();
+ /**
+ * The engine will read at most this number of objects from each of master and test files. This reduces
+ * the memory requirements for DiffObjects but does limit you to comparing at most this number of objects
+ */
+ @Argument(fullName="maxObjectsToRead", shortName="motr", doc="Max. number of objects to read from the files. -1 [default] means unlimited", required=false)
+ int MAX_OBJECTS_TO_READ = -1;
+
+ /**
+ * The max number of differences to display when summarizing. For example, if there are 10M differences, but
+ * maxDiffs is 10, then the comparison aborts after first ten summarized differences are shown. Note that
+ * the system shows differences sorted by frequency, so these 10 would be the most common between the two files.
+ * A value of 0 means show all possible differences.
+ */
+ @Argument(fullName="maxDiffs", shortName="M", doc="Max. number of diffs to process", required=false)
+ int MAX_DIFFS = 0;
+
+ /**
+ * The maximum number of singleton (occurs exactly once between the two files) to display when writing out
+ * the summary. Only applies if maxDiffs hasn't been exceeded. For example, if maxDiffs is 10 and maxCount1Diffs
+ * is 2 and there are 20 diffs with count > 1, then only 10 are shown, all of which have count above 1.
+ */
+ @Argument(fullName="maxCount1Diffs", shortName="M1", doc="Max. number of diffs occuring exactly once in the file to process", required=false)
+ int MAX_COUNT1_DIFFS = 0;
+
+ /**
+ * Only differences that occur more than minCountForDiff are displayed. For example, if minCountForDiff is 10, then
+ * a difference must occur at least 10 times between the two files to be shown.
+ */
+ @Argument(fullName="minCountForDiff", shortName="MCFD", doc="Min number of observations for a records to display", required=false)
+ int minCountForDiff = 1;
+
+ /**
+ * If provided, the system will write out the summarized, individual differences. May lead to enormous outputs,
+ * depending on how many differences are found. Note these are not sorted in any way, so if you have 10M
+ * common differences in the files, you will see 10M records, whereas the final summarize will just list the
+ * difference and its count of 10M.
+ */
+ @Argument(fullName="showItemizedDifferences", shortName="SID", doc="Should we enumerate all differences between the files?", required=false)
+ boolean showItemizedDifferences = false;
+
+ DiffEngine diffEngine;
@Override
public void initialize() {
-
+ this.diffEngine = new DiffEngine();
}
@Override
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java
index b24437c4a..d3ed46ce8 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/phasing/PhaseByTransmission.java
@@ -9,12 +9,14 @@ import org.broadinstitute.sting.gatk.walkers.RodWalker;
import org.broadinstitute.sting.utils.MathUtils;
import org.broadinstitute.sting.utils.SampleUtils;
import org.broadinstitute.sting.utils.codecs.vcf.*;
-import org.broadinstitute.sting.utils.exceptions.UserException;
+import org.broadinstitute.sting.utils.text.XReadLines;
import org.broadinstitute.sting.utils.variantcontext.Allele;
import org.broadinstitute.sting.utils.variantcontext.Genotype;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import org.broadinstitute.sting.utils.variantcontext.VariantContextUtils;
+import java.io.File;
+import java.io.FileNotFoundException;
import java.util.*;
/**
@@ -29,37 +31,75 @@ import java.util.*;
* begin.
*/
public class PhaseByTransmission extends RodWalker {
- @Argument(shortName="f", fullName="familyPattern", required=true, doc="Pattern for the family structure (usage: mom+dad=child)")
- public String familyStr = null;
-
- @Argument(shortName="nofilters", fullName="disableFilters", required=false, doc="Disable filters for sites where the phase can't be determined, where the parental origin of the alleles is ambiguous (i.e. everyone is heterozygous), or Mendelian violations")
- public Boolean noFilters = false;
+ @Argument(shortName="f", fullName="familySpec", required=true, doc="Patterns for the family structure (usage: mom+dad=child). Specify several trios by supplying this argument many times and/or a file containing many patterns.")
+ public ArrayList familySpecs = null;
@Output
protected VCFWriter vcfWriter = null;
- private String SAMPLE_NAME_MOM;
- private String SAMPLE_NAME_DAD;
- private String SAMPLE_NAME_CHILD;
-
private final String ROD_NAME = "variant";
- private final String AMBIGUOUS_ALLELE_ORIGIN_FILTER_NAME = "AmbiguousAlleleOrigin";
- private final String INSUFFICIENT_DATA_FILTER_NAME = "InsufficientInformation";
- private final String MENDELIAN_VIOLATION_FILTER_NAME = "MendelianViolation";
private final String TRANSMISSION_PROBABILITY_TAG_NAME = "TP";
private final String SOURCE_NAME = "PhaseByTransmission";
private final Double MENDELIAN_VIOLATION_PRIOR = 1e-8;
+ private class Trio {
+ private String mother;
+ private String father;
+ private String child;
+
+ public Trio(String mother, String father, String child) {
+ this.mother = mother;
+ this.father = father;
+ this.child = child;
+ }
+
+ public Trio(String familySpec) {
+ String[] pieces = familySpec.split("[\\+\\=]");
+
+ this.mother = pieces[0];
+ this.father = pieces[1];
+ this.child = pieces[2];
+ }
+
+ public String getMother() { return mother; }
+ public String getFather() { return father; }
+ public String getChild() { return child; }
+ }
+
+ private ArrayList trios = new ArrayList();
+
+ public ArrayList getFamilySpecsFromCommandLineInput(ArrayList familySpecs) {
+ if (familySpecs != null) {
+ // Let's first go through the list and see if we were given any files. We'll add every entry in the file to our
+ // spec list set, and treat the entries as if they had been specified on the command line.
+ ArrayList specs = new ArrayList();
+ for (String familySpec : familySpecs) {
+ File specFile = new File(familySpec);
+
+ try {
+ XReadLines reader = new XReadLines(specFile);
+
+ List lines = reader.readLines();
+ for (String line : lines) {
+ specs.add(new Trio(line));
+ }
+ } catch (FileNotFoundException e) {
+ specs.add(new Trio(familySpec)); // not a file, so must be a family spec
+ }
+ }
+
+ return specs;
+ }
+
+ return new ArrayList();
+ }
+
/**
* Parse the familial relationship specification, and initialize VCF writer
*/
public void initialize() {
- String[] pieces = familyStr.split("[\\+\\=]");
-
- SAMPLE_NAME_MOM = pieces[0];
- SAMPLE_NAME_DAD = pieces[1];
- SAMPLE_NAME_CHILD = pieces[2];
+ trios = getFamilySpecsFromCommandLineInput(familySpecs);
ArrayList rodNames = new ArrayList();
rodNames.add(ROD_NAME);
@@ -67,34 +107,11 @@ public class PhaseByTransmission extends RodWalker {
Map vcfRods = VCFUtils.getVCFHeadersFromRods(getToolkit(), rodNames);
Set vcfSamples = SampleUtils.getSampleList(vcfRods, VariantContextUtils.GenotypeMergeType.REQUIRE_UNIQUE);
- if (vcfSamples.size() != 3) {
- throw new UserException("File to phase by transmission contains more than three samples. This walker only" +
- "accepts VCFs with three samples, so that the meaning of the applied filters is" +
- "unambiguous.");
- }
-
- if (!vcfSamples.contains(SAMPLE_NAME_MOM) || !vcfSamples.contains(SAMPLE_NAME_DAD) || !vcfSamples.contains(SAMPLE_NAME_CHILD)) {
- throw new UserException("One or more of the samples specified in the familyPattern argument is not present" +
- "in this file. Please supply a VCF file that contains only three samples: the" +
- "mother, the father, and the child");
- }
-
- Set samples = new TreeSet();
- samples.add(SAMPLE_NAME_MOM);
- samples.add(SAMPLE_NAME_DAD);
- samples.add(SAMPLE_NAME_CHILD);
-
Set headerLines = new HashSet();
headerLines.addAll(VCFUtils.getHeaderFields(this.getToolkit()));
-
- if (!noFilters) {
- headerLines.add(new VCFFilterHeaderLine(AMBIGUOUS_ALLELE_ORIGIN_FILTER_NAME, "The parental origin of each of the child's allele cannot be determined (ie everyone is heterozygous)"));
- headerLines.add(new VCFFilterHeaderLine(INSUFFICIENT_DATA_FILTER_NAME, "The phase of the child's genotype cannot be determined (ie someone is a no-call)"));
- headerLines.add(new VCFFilterHeaderLine(MENDELIAN_VIOLATION_FILTER_NAME, "No combination of the parents' alleles can yield the child's genotype (ie a possible Mendelian violation)"));
- }
-
- headerLines.add(new VCFInfoHeaderLine(TRANSMISSION_PROBABILITY_TAG_NAME, 1, VCFHeaderLineType.Float, "Probability that the phase is correct given that the genotypes are correct"));
- vcfWriter.writeHeader(new VCFHeader(headerLines, samples));
+ headerLines.add(new VCFFormatHeaderLine(TRANSMISSION_PROBABILITY_TAG_NAME, 1, VCFHeaderLineType.Float, "Probability that the phase is correct given that the genotypes are correct"));
+ headerLines.add(new VCFHeaderLine("source", SOURCE_NAME));
+ vcfWriter.writeHeader(new VCFHeader(headerLines, vcfSamples));
}
private double computeTransmissionLikelihoodOfGenotypeConfiguration(Genotype mom, Genotype dad, Genotype child) {
@@ -211,68 +228,52 @@ public class PhaseByTransmission extends RodWalker {
return finalGenotypes;
}
- private VariantContext phaseTrioGenotypes(VariantContext vc) {
- Genotype mom = vc.getGenotype(SAMPLE_NAME_MOM);
- Genotype dad = vc.getGenotype(SAMPLE_NAME_DAD);
- Genotype child = vc.getGenotype(SAMPLE_NAME_CHILD);
-
- Set filters = new HashSet();
- filters.addAll(vc.getFilters());
-
- Map attributes = new HashMap();
- attributes.putAll(vc.getAttributes());
- attributes.put(TRANSMISSION_PROBABILITY_TAG_NAME, 0.0);
-
+ private ArrayList phaseTrioGenotypes(Allele ref, Allele alt, Genotype mother, Genotype father, Genotype child) {
ArrayList finalGenotypes = new ArrayList();
- finalGenotypes.add(mom);
- finalGenotypes.add(dad);
+ finalGenotypes.add(mother);
+ finalGenotypes.add(father);
finalGenotypes.add(child);
- if (!mom.isCalled() || !dad.isCalled() || !child.isCalled()) {
- filters.add(INSUFFICIENT_DATA_FILTER_NAME);
- } else {
- ArrayList possibleMomGenotypes = createAllThreeGenotypes(vc.getReference(), vc.getAlternateAllele(0), mom);
- ArrayList possibleDadGenotypes = createAllThreeGenotypes(vc.getReference(), vc.getAlternateAllele(0), dad);
- ArrayList possibleChildGenotypes = createAllThreeGenotypes(vc.getReference(), vc.getAlternateAllele(0), child);
+ if (mother.isCalled() && father.isCalled() && child.isCalled() && !(mother.isHet() && father.isHet() && child.isHet())) {
+ ArrayList possibleMotherGenotypes = createAllThreeGenotypes(ref, alt, mother);
+ ArrayList possibleFatherGenotypes = createAllThreeGenotypes(ref, alt, father);
+ ArrayList possibleChildGenotypes = createAllThreeGenotypes(ref, alt, child);
double bestConfigurationLikelihood = 0.0;
double bestPrior = 0.0;
- Genotype bestMomGenotype = mom;
- Genotype bestDadGenotype = dad;
+ Genotype bestMotherGenotype = mother;
+ Genotype bestFatherGenotype = father;
Genotype bestChildGenotype = child;
double norm = 0.0;
- for (Genotype momGenotype : possibleMomGenotypes) {
- for (Genotype dadGenotype : possibleDadGenotypes) {
+ for (Genotype motherGenotype : possibleMotherGenotypes) {
+ for (Genotype fatherGenotype : possibleFatherGenotypes) {
for (Genotype childGenotype : possibleChildGenotypes) {
- double prior = isMendelianViolation(vc.getReference(), vc.getAlternateAllele(0), momGenotype, dadGenotype, childGenotype) ? MENDELIAN_VIOLATION_PRIOR : 1.0 - 12*MENDELIAN_VIOLATION_PRIOR;
- double configurationLikelihood = computeTransmissionLikelihoodOfGenotypeConfiguration(momGenotype, dadGenotype, childGenotype);
+ double prior = isMendelianViolation(ref, alt, motherGenotype, fatherGenotype, childGenotype) ? MENDELIAN_VIOLATION_PRIOR : 1.0 - 12*MENDELIAN_VIOLATION_PRIOR;
+ double configurationLikelihood = computeTransmissionLikelihoodOfGenotypeConfiguration(motherGenotype, fatherGenotype, childGenotype);
norm += prior*configurationLikelihood;
if (prior*configurationLikelihood > bestPrior*bestConfigurationLikelihood) {
bestConfigurationLikelihood = configurationLikelihood;
bestPrior = prior;
- bestMomGenotype = momGenotype;
- bestDadGenotype = dadGenotype;
+ bestMotherGenotype = motherGenotype;
+ bestFatherGenotype = fatherGenotype;
bestChildGenotype = childGenotype;
}
}
}
}
- if (isMendelianViolation(vc.getReference(), vc.getAlternateAllele(0), bestMomGenotype, bestDadGenotype, bestChildGenotype)) {
- filters.add(MENDELIAN_VIOLATION_FILTER_NAME);
- } else if (bestMomGenotype.isHet() && bestDadGenotype.isHet() && bestChildGenotype.isHet()) {
- filters.add(AMBIGUOUS_ALLELE_ORIGIN_FILTER_NAME);
- } else {
- finalGenotypes = getPhasedGenotypes(bestMomGenotype, bestDadGenotype, bestChildGenotype);
+ Map attributes = new HashMap();
+ attributes.putAll(bestChildGenotype.getAttributes());
+ attributes.put(TRANSMISSION_PROBABILITY_TAG_NAME, bestPrior*bestConfigurationLikelihood / norm);
+ bestChildGenotype = Genotype.modifyAttributes(bestChildGenotype, attributes);
- attributes.put(TRANSMISSION_PROBABILITY_TAG_NAME, bestPrior*bestConfigurationLikelihood / norm);
- }
+ finalGenotypes = getPhasedGenotypes(bestMotherGenotype, bestFatherGenotype, bestChildGenotype);
}
- return new VariantContext(SOURCE_NAME, vc.getChr(), vc.getStart(), vc.getStart(), vc.getAlleles(), finalGenotypes, vc.getNegLog10PError(), noFilters ? vc.getFilters() : filters, attributes);
+ return finalGenotypes;
}
/**
@@ -289,7 +290,27 @@ public class PhaseByTransmission extends RodWalker {
Collection vcs = tracker.getVariantContexts(ref, ROD_NAME, null, context.getLocation(), true, true);
for (VariantContext vc : vcs) {
- vcfWriter.add(phaseTrioGenotypes(vc), ref.getBase());
+ Map genotypeMap = vc.getGenotypes();
+
+ for (Trio trio : trios) {
+ Genotype mother = vc.getGenotype(trio.getMother());
+ Genotype father = vc.getGenotype(trio.getFather());
+ Genotype child = vc.getGenotype(trio.getChild());
+
+ ArrayList trioGenotypes = phaseTrioGenotypes(vc.getReference(), vc.getAltAlleleWithHighestAlleleCount(), mother, father, child);
+
+ Genotype phasedMother = trioGenotypes.get(0);
+ Genotype phasedFather = trioGenotypes.get(1);
+ Genotype phasedChild = trioGenotypes.get(2);
+
+ genotypeMap.put(phasedMother.getSampleName(), phasedMother);
+ genotypeMap.put(phasedFather.getSampleName(), phasedFather);
+ genotypeMap.put(phasedChild.getSampleName(), phasedChild);
+ }
+
+ VariantContext newvc = VariantContext.modifyGenotypes(vc, genotypeMap);
+
+ vcfWriter.add(newvc, ref.getBase());
}
}
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountPairsWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountPairsWalker.java
index df89efe6d..26fa9a258 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountPairsWalker.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/qc/CountPairsWalker.java
@@ -40,7 +40,6 @@ import java.util.List;
* of paired reads.
*
* @author mhanna
- * @version 0.1
*/
public class CountPairsWalker extends ReadPairWalker {
@Output
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CountCovariatesWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CountCovariatesWalker.java
index 8c6539f8d..775cde1f4 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CountCovariatesWalker.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/CountCovariatesWalker.java
@@ -58,6 +58,8 @@ import java.util.List;
import java.util.Map;
/**
+ * First pass of the recalibration. Generates recalibration table based on various user-specified covariates (such as reported quality score, cycle, and dinucleotide).
+ *
* This walker is designed to work as the first pass in a two-pass processing step.
* It does a by-locus traversal operating only at sites that are not in dbSNP.
* We assume that all reference mismatches we see are therefore errors and indicative of poor base quality.
@@ -72,7 +74,6 @@ import java.util.Map;
*
* @author rpoplin
* @since Nov 3, 2009
- * @help.summary First pass of the recalibration. Generates recalibration table based on various user-specified covariates (such as reported quality score, cycle, and dinucleotide).
*/
@BAQMode(ApplicationTime = BAQ.ApplicationTime.FORBIDDEN)
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/TableRecalibrationWalker.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/TableRecalibrationWalker.java
index 0277fda0d..fec7ee4e6 100644
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/TableRecalibrationWalker.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/recalibration/TableRecalibrationWalker.java
@@ -54,8 +54,10 @@ import java.util.ResourceBundle;
import java.util.regex.Pattern;
/**
+ * Second pass of the recalibration. Uses the table generated by CountCovariates to update the base quality scores of the input bam file using a sequential table calculation making the base quality scores more accurately reflect the actual quality of the bases as measured by reference mismatch rate.
+ *
* This walker is designed to work as the second pass in a two-pass processing step, doing a by-read traversal.
-
+ *
* For each base in each read this walker calculates various user-specified covariates (such as read group, reported quality score, cycle, and dinuc)
* Using these values as a key in a large hashmap the walker calculates an empirical base quality score and overwrites the quality score currently in the read.
* This walker then outputs a new bam file with these updated (recalibrated) reads.
@@ -65,7 +67,6 @@ import java.util.regex.Pattern;
*
* @author rpoplin
* @since Nov 3, 2009
- * @help.summary Second pass of the recalibration. Uses the table generated by CountCovariates to update the base quality scores of the input bam file using a sequential table calculation making the base quality scores more accurately reflect the actual quality of the bases as measured by reference mismatch rate.
*/
@BAQMode(QualityMode = BAQ.QualityMode.ADD_TAG, ApplicationTime = BAQ.ApplicationTime.ON_OUTPUT)
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/validation/ValidationAmplicons.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/validation/ValidationAmplicons.java
index 7e39d2658..cb03d4c61 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/validation/ValidationAmplicons.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/validation/ValidationAmplicons.java
@@ -228,14 +228,12 @@ public class ValidationAmplicons extends RodWalker {
}
public void onTraversalDone(Integer fin ) {
- if(aligner != null)
- aligner.close();
-
validateSequence();
if ( doNotUseBWA ) {
lowerRepeats();
} else {
lowerNonUniqueSegments();
+ aligner.close();
}
print();
}
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/stratifications/CpG.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/stratifications/CpG.java
index 3e8a6ed17..e1f2ae983 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/stratifications/CpG.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/varianteval/stratifications/CpG.java
@@ -8,6 +8,18 @@ import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.util.ArrayList;
import java.util.Set;
+/**
+ * CpG is a stratification module for VariantEval that divides the input data by within/not within a CpG site
+ *
+ *
+ * It is a three-state stratification:
+ *
+ *
The locus is a CpG site ("CpG")
+ *
The locus is not a CpG site ("non_CpG")
+ *
The locus is either a CpG or not a CpG site ("all")
+ *
+ * A CpG site is defined as a site where the reference base at a locus is a C and the adjacent reference base in the 3' direction is a G.
+ */
public class CpG extends VariantStratifier {
private ArrayList states;
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyRecalibration.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyRecalibration.java
index 403c67d3e..b195fd35f 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyRecalibration.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/ApplyRecalibration.java
@@ -49,8 +49,6 @@ import java.util.*;
*
* @author rpoplin
* @since Mar 14, 2011
- *
- * @help.summary Applies cuts to the input vcf file (by adding filter lines) to achieve the desired novel FDR levels which were specified during VariantRecalibration
*/
public class ApplyRecalibration extends RodWalker {
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java
index 8179463eb..76c888640 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantrecalibration/VariantRecalibrator.java
@@ -53,8 +53,6 @@ import java.util.*;
*
* User: rpoplin
* Date: 3/12/11
- *
- * @help.summary Takes variant calls as .vcf files, learns a Gaussian mixture model over the variant annotations and evaluates the variant -- assigning an informative lod score
*/
public class VariantRecalibrator extends RodWalker, ExpandingArrayList> implements TreeReducible> {
diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java
index ac6797609..e1a3659b8 100755
--- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java
+++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java
@@ -274,7 +274,7 @@ public class SelectVariants extends RodWalker {
}
SELECT_RANDOM_FRACTION = fractionRandom > 0;
- if (SELECT_RANDOM_FRACTION) logger.info("Selecting approximately " + fractionRandom + "% of the variants at random from the variant track");
+ if (SELECT_RANDOM_FRACTION) logger.info("Selecting approximately " + 100.0*fractionRandom + "% of the variants at random from the variant track");
if (KEEP_AF_SPECTRUM) {
diff --git a/public/java/src/org/broadinstitute/sting/utils/ContigComparator.java b/public/java/src/org/broadinstitute/sting/utils/ContigComparator.java
new file mode 100644
index 000000000..619beddb8
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/utils/ContigComparator.java
@@ -0,0 +1,71 @@
+package org.broadinstitute.sting.utils;
+
+import java.util.Comparator;
+import java.util.Set;
+import java.util.TreeSet;
+
+/**
+ * Created by IntelliJ IDEA.
+ * User: carneiro
+ * Date: 7/23/11
+ * Time: 6:07 PM
+ *
+ * Contig comparator -- sorting contigs like Picard
+ *
+ * This is very useful if you want to output your text files or manipulate data in the usual chromosome ordering :
+ * 1
+ * 2
+ * 3
+ * ...
+ * 21
+ * 22
+ * X
+ * Y
+ * GL***
+ * ...
+ * Just use this comparator in any SortedSet class constructor and your data will be sorted like in the BAM file.
+ */
+public class ContigComparator implements Comparator {
+ private Set specialChrs;
+
+ public ContigComparator() {
+ specialChrs = new TreeSet();
+ specialChrs.add("X");
+ specialChrs.add("Y");
+ }
+
+ public int compare(String chr1, String chr2) {
+ if (chr1.equals(chr2))
+ return 0;
+
+ Integer x = convertStringWithoutException(chr1);
+ Integer y = convertStringWithoutException(chr2);
+ // both contigs are numbered
+ if (x != null && y != null)
+ return (x < y) ? -1:1;
+
+ // both contigs are named
+ if (x == null && y == null) {
+ // both contigs are special contigs or neither contig is a special contigs
+ if (specialChrs.contains(chr1) && specialChrs.contains(chr2) || (!specialChrs.contains(chr1) && !specialChrs.contains(chr2)))
+ return chr1.compareTo(chr2);
+ // one contig is a special and the other is not special
+ if (specialChrs.contains(chr1))
+ return -1;
+ return 1;
+ }
+
+ // one contig is named the other is numbered
+ if (x != null)
+ return -1;
+ return 1;
+ }
+
+ private Integer convertStringWithoutException(String contig) {
+ Integer x = null;
+ try {
+ x = Integer.decode(contig);
+ } catch (NumberFormatException n){}
+ return x;
+ }
+}
diff --git a/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java b/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java
index 7eab6f6c9..3c3299ff5 100755
--- a/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java
+++ b/public/java/src/org/broadinstitute/sting/utils/exceptions/UserException.java
@@ -29,6 +29,7 @@ import net.sf.samtools.SAMRecord;
import net.sf.samtools.SAMSequenceDictionary;
import net.sf.samtools.SAMSequenceRecord;
import org.broadinstitute.sting.utils.GenomeLoc;
+import org.broadinstitute.sting.utils.help.DocumentedGATKFeature;
import org.broadinstitute.sting.utils.variantcontext.VariantContext;
import java.io.File;
@@ -43,6 +44,9 @@ import java.util.Arrays;
* Date: Sep 3, 2010
* Time: 2:24:09 PM
*/
+@DocumentedGATKFeature(
+ groupName = "User exceptions",
+ summary = "Exceptions caused by incorrect user behavior, such as bad files, bad arguments, etc." )
public class UserException extends ReviewedStingException {
public UserException(String msg) { super(msg); }
public UserException(String msg, Throwable e) { super(msg, e); }
diff --git a/public/java/src/org/broadinstitute/sting/utils/help/DescriptionTaglet.java b/public/java/src/org/broadinstitute/sting/utils/help/DescriptionTaglet.java
deleted file mode 100644
index 65c332048..000000000
--- a/public/java/src/org/broadinstitute/sting/utils/help/DescriptionTaglet.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package org.broadinstitute.sting.utils.help;
-
-import com.sun.tools.doclets.Taglet;
-
-import java.util.Map;
-
-/**
- * Provide an alternate description for the given help system.
- *
- * @author mhanna
- * @version 0.1
- */
-public class DescriptionTaglet extends HelpTaglet {
- /**
- * The key tag for this taglet.
- */
- public static final String NAME = "help.description";
-
- /**
- * Return the name of this custom tag.
- */
- @Override
- public String getName() {
- return NAME;
- }
-
- /**
- * Will return false since overviews are always named
- * by the @WalkerName tag.
- * @return false always
- */
- @Override
- public boolean inOverview() {
- return true;
- }
-
- /**
- * Will return true to indicate that packages can be given useful
- * description.
- * @return true always
- */
- @Override
- public boolean inPackage() {
- return true;
- }
-
- /**
- * Register this Taglet.
- * @param tagletMap the map to register this tag to.
- */
- public static void register(Map tagletMap) {
- DescriptionTaglet tag = new DescriptionTaglet();
- Taglet t = (Taglet)tagletMap.get(tag.getName());
- if (t != null) {
- tagletMap.remove(tag.getName());
- }
- tagletMap.put(tag.getName(), tag);
- }
-}
\ No newline at end of file
diff --git a/public/java/src/org/broadinstitute/sting/utils/help/DisplayNameTaglet.java b/public/java/src/org/broadinstitute/sting/utils/help/DisplayNameTaglet.java
deleted file mode 100644
index 6c6dad736..000000000
--- a/public/java/src/org/broadinstitute/sting/utils/help/DisplayNameTaglet.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package org.broadinstitute.sting.utils.help;
-
-import com.sun.tools.doclets.Taglet;
-
-import java.util.Map;
-
-/**
- * Provide a display name in the help for packages
- *
- * @author mhanna
- * @version 0.1
- */
-public class DisplayNameTaglet extends HelpTaglet {
- /**
- * The display name for this taglet.
- */
- public static final String NAME = "help.display.name";
-
- /**
- * Return the name of this custom tag.
- */
- @Override
- public String getName() {
- return NAME;
- }
-
- /**
- * Will return true to indicate that packages can be given useful
- * display text.
- * @return true always
- */
- @Override
- public boolean inPackage() {
- return true;
- }
-
- /**
- * Register this Taglet.
- * @param tagletMap the map to register this tag to.
- */
- public static void register(Map tagletMap) {
- DisplayNameTaglet tag = new DisplayNameTaglet();
- Taglet t = (Taglet)tagletMap.get(tag.getName());
- if (t != null) {
- tagletMap.remove(tag.getName());
- }
- tagletMap.put(tag.getName(), tag);
- }
-}
diff --git a/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeature.java b/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeature.java
new file mode 100644
index 000000000..710503ca8
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeature.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+package org.broadinstitute.sting.utils.help;
+
+import java.lang.annotation.*;
+
+/**
+ * An annotation to identify a class as a GATK capability for documentation
+ *
+ * @author depristo
+ */
+@Documented
+@Inherited
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+public @interface DocumentedGATKFeature {
+ public boolean enable() default true;
+ public String groupName();
+ public String summary() default "";
+ public Class extends DocumentedGATKFeatureHandler> handler() default GenericDocumentationHandler.class;
+ public Class[] extraDocs() default {};
+}
diff --git a/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeatureHandler.java b/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeatureHandler.java
new file mode 100644
index 000000000..366df0c3a
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/utils/help/DocumentedGATKFeatureHandler.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+package org.broadinstitute.sting.utils.help;
+
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.RootDoc;
+
+import java.io.*;
+import java.util.Set;
+
+/**
+ *
+ */
+public abstract class DocumentedGATKFeatureHandler {
+ private GATKDoclet doclet;
+
+ protected RootDoc getRootDoc() {
+ return this.doclet.rootDoc;
+ }
+
+ public void setDoclet(GATKDoclet doclet) {
+ this.doclet = doclet;
+ }
+
+ public GATKDoclet getDoclet() {
+ return doclet;
+ }
+
+ public boolean shouldBeProcessed(ClassDoc doc) { return true; }
+
+ public String getDestinationFilename(ClassDoc doc) {
+ return HelpUtils.getClassName(doc).replace(".", "_") + ".html";
+ }
+
+ public abstract String getTemplateName(ClassDoc doc) throws IOException;
+ public abstract void processOne(RootDoc rootDoc, GATKDocWorkUnit toProcess, Set all);
+}
diff --git a/public/java/src/org/broadinstitute/sting/utils/help/GATKDocWorkUnit.java b/public/java/src/org/broadinstitute/sting/utils/help/GATKDocWorkUnit.java
new file mode 100644
index 000000000..65c6624d5
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/utils/help/GATKDocWorkUnit.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+package org.broadinstitute.sting.utils.help;
+
+import com.sun.javadoc.ClassDoc;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+* Created by IntelliJ IDEA.
+* User: depristo
+* Date: 7/24/11
+* Time: 7:59 PM
+* To change this template use File | Settings | File Templates.
+*/
+public class GATKDocWorkUnit implements Comparable {
+ // known at the start
+ final String name, filename, group;
+ final DocumentedGATKFeatureHandler handler;
+ final ClassDoc classDoc;
+ final Class clazz;
+ final DocumentedGATKFeature annotation;
+ final String buildTimestamp, absoluteVersion;
+
+ // set by the handler
+ String summary;
+ Map forTemplate;
+
+ public GATKDocWorkUnit(String name, String filename, String group,
+ DocumentedGATKFeature annotation, DocumentedGATKFeatureHandler handler,
+ ClassDoc classDoc, Class clazz,
+ String buildTimestamp, String absoluteVersion) {
+ this.annotation = annotation;
+ this.name = name;
+ this.filename = filename;
+ this.group = group;
+ this.handler = handler;
+ this.classDoc = classDoc;
+ this.clazz = clazz;
+ this.buildTimestamp = buildTimestamp;
+ this.absoluteVersion = absoluteVersion;
+ }
+
+ public void setHandlerContent(String summary, Map forTemplate) {
+ this.summary = summary;
+ this.forTemplate = forTemplate;
+ }
+
+ public Map toMap() {
+ Map data = new HashMap();
+ data.put("name", name);
+ data.put("summary", summary);
+ data.put("filename", filename);
+ data.put("group", group);
+ return data;
+ }
+
+ public int compareTo(GATKDocWorkUnit other) {
+ return this.name.compareTo(other.name);
+ }
+}
diff --git a/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java b/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java
new file mode 100644
index 000000000..49214237a
--- /dev/null
+++ b/public/java/src/org/broadinstitute/sting/utils/help/GATKDoclet.java
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2011, 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.
+ */
+
+package org.broadinstitute.sting.utils.help;
+
+import com.sun.javadoc.ClassDoc;
+import com.sun.javadoc.RootDoc;
+import freemarker.template.Configuration;
+import freemarker.template.DefaultObjectWrapper;
+import freemarker.template.Template;
+import freemarker.template.TemplateException;
+import org.apache.commons.io.FileUtils;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ *
+ */
+public class GATKDoclet {
+ final protected static File SETTINGS_DIR = new File("settings/helpTemplates");
+ final protected static File DESTINATION_DIR = new File("gatkdocs");
+ final protected static Logger logger = Logger.getLogger(GATKDoclet.class);
+ protected static String buildTimestamp = null, absoluteVersion = null;
+ protected static boolean showHiddenFeatures = false;
+
+ RootDoc rootDoc;
+
+ /**
+ * Extracts the contents of certain types of javadoc and adds them to an XML file.
+ * @param rootDoc The documentation root.
+ * @return Whether the JavaDoc run succeeded.
+ * @throws java.io.IOException if output can't be written.
+ */
+ public static boolean start(RootDoc rootDoc) throws IOException {
+ logger.setLevel(Level.DEBUG);
+ // load arguments
+ for(String[] options: rootDoc.options()) {
+ if(options[0].equals("-build-timestamp"))
+ buildTimestamp = options[1];
+ if (options[0].equals("-absolute-version"))
+ absoluteVersion = options[1];
+ if (options[0].equals("-include-hidden"))
+ showHiddenFeatures = true;
+ }
+
+ GATKDoclet doclet = new GATKDoclet();
+ doclet.processDocs(rootDoc);
+ return true;
+ }
+
+ /**
+ * Validate the given options against options supported by this doclet.
+ * @param option Option to validate.
+ * @return Number of potential parameters; 0 if not supported.
+ */
+ public static int optionLength(String option) {
+ if(option.equals("-build-timestamp") || option.equals("-absolute-version") || option.equals("-include-hidden")) {
+ return 2;
+ }
+ return 0;
+ }
+
+ public boolean showHiddenFeatures() {
+ return showHiddenFeatures;
+ }
+
+ public Set workUnits() {
+ TreeSet m = new TreeSet();
+
+ for ( ClassDoc doc : rootDoc.classes() ) {
+ logger.debug("Considering " + doc);
+ Class clazz = getClassForClassDoc(doc);
+
+ if ( clazz != null && clazz.getName().equals("org.broadinstitute.sting.gatk.walkers.annotator.AlleleBalance"))
+ logger.debug("foo");
+
+ DocumentedGATKFeature feature = getFeatureForClassDoc(doc);
+ DocumentedGATKFeatureHandler handler = createHandler(doc, feature);
+ if ( handler != null && handler.shouldBeProcessed(doc) ) {
+ logger.info("Going to generate documentation for class " + doc);
+ String filename = handler.getDestinationFilename(doc);
+ GATKDocWorkUnit unit = new GATKDocWorkUnit(doc.name(),
+ filename, feature.groupName(),
+ feature, handler, doc, clazz,
+ buildTimestamp, absoluteVersion);
+ m.add(unit);
+ }
+ }
+
+ return m;
+ }
+
+ protected void processDocs(RootDoc rootDoc) {
+ // setup the global access to the root
+ this.rootDoc = rootDoc;
+
+ try {
+ // basic setup
+ DESTINATION_DIR.mkdirs();
+ FileUtils.copyFile(new File(SETTINGS_DIR + "/style.css"), new File(DESTINATION_DIR + "/style.css"));
+
+ /* ------------------------------------------------------------------- */
+ /* You should do this ONLY ONCE in the whole application life-cycle: */
+
+ Configuration cfg = new Configuration();
+ // Specify the data source where the template files come from.
+ cfg.setDirectoryForTemplateLoading(SETTINGS_DIR);
+ // Specify how templates will see the data-model. This is an advanced topic...
+ cfg.setObjectWrapper(new DefaultObjectWrapper());
+
+ Set myWorkUnits = workUnits();
+ for ( GATKDocWorkUnit workUnit : myWorkUnits ) {
+ processDocWorkUnit(cfg, workUnit, myWorkUnits);
+ }
+
+ processIndex(cfg, new ArrayList(myWorkUnits));
+ } catch ( FileNotFoundException e ) {
+ throw new RuntimeException(e);
+ } catch ( IOException e ) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private DocumentedGATKFeatureHandler createHandler(ClassDoc doc, DocumentedGATKFeature feature) {
+ try {
+ if ( feature != null ) {
+ if ( feature.enable() ) {
+ DocumentedGATKFeatureHandler handler = feature.handler().newInstance();
+ handler.setDoclet(this);
+ return handler;
+ } else {
+ logger.info("Skipping disabled Documentation for " + doc);
+ }
+ }
+ } catch ( IllegalAccessException e) {
+ throw new RuntimeException(e); // the constructor is now private -- this is an error
+ } catch ( InstantiationException e) {
+ throw new RuntimeException(e); // the constructor is now private -- this is an error
+ }
+
+ return null;
+ }
+
+ private DocumentedGATKFeature getFeatureForClassDoc(ClassDoc doc) {
+ // todo -- what do I need the ? extends Object to pass the compiler?
+ Class extends Object> docClass = getClassForClassDoc(doc);
+ if ( docClass != null && docClass.isAnnotationPresent(DocumentedGATKFeature.class) ) {
+ return docClass.getAnnotation(DocumentedGATKFeature.class);
+ } else {
+ return null; // not annotated so it shouldn't be documented
+ }
+ }
+
+ private Class extends Object> getClassForClassDoc(ClassDoc doc) {
+ try {
+ // todo -- what do I need the ? extends Object to pass the compiler?
+ return (Class extends Object>)HelpUtils.getClassForDoc(doc);
+ } catch ( ClassNotFoundException e) {
+ //logger.warn("Couldn't find class for ClassDoc " + doc);
+ // we got a classdoc for a class we can't find. Maybe in a library or something
+ return null;
+ } catch ( NoClassDefFoundError e ) {
+ return null;
+ } catch ( UnsatisfiedLinkError e) {
+ return null; // naughty BWA bindings
+ }
+ }
+
+ public static ClassDoc getClassDocForClass(RootDoc rootDoc, Class clazz) {
+ return rootDoc.classNamed(clazz.getName());
+ }
+
+ private void processIndex(Configuration cfg, List indexData) throws IOException {
+ /* Get or create a template */
+ Template temp = cfg.getTemplate("generic.index.template.html");
+
+ /* Merge data-model with template */
+ Writer out = new OutputStreamWriter(new FileOutputStream(new File(DESTINATION_DIR + "/index.html")));
+ try {
+ temp.process(groupIndexData(indexData), out);
+ out.flush();
+ } catch ( TemplateException e ) {
+ throw new ReviewedStingException("Failed to create GATK documentation", e);
+ }
+ }
+
+ private Map groupIndexData(List indexData) {
+ //
+ // root -> data -> { summary -> y, filename -> z }, etc
+ // -> groups -> group1, group2, etc.
+ Map root = new HashMap();
+
+ Collections.sort(indexData);
+
+ Set docFeatures = new HashSet();
+ List