diff --git a/java/src/org/broadinstitute/sting/gatk/io/storage/GenotypeWriterStorage.java b/java/src/org/broadinstitute/sting/gatk/io/storage/GenotypeWriterStorage.java index 7f9fca85d..d7c68056c 100755 --- a/java/src/org/broadinstitute/sting/gatk/io/storage/GenotypeWriterStorage.java +++ b/java/src/org/broadinstitute/sting/gatk/io/storage/GenotypeWriterStorage.java @@ -45,6 +45,7 @@ import edu.mit.broad.picard.genotype.geli.GeliFileReader; * @version 0.1 */ public class GenotypeWriterStorage implements GenotypeWriter, Storage { + private final GenotypeWriterFactory.GENOTYPE_FORMAT format; private final File file; private final GenotypeWriter writer; @@ -53,12 +54,23 @@ public class GenotypeWriterStorage implements GenotypeWriter, Storage samples = SampleUtils.getSAMFileSamples(stub.getSAMFileHeader()); GenotypeWriterFactory.writeHeader(writer, stub.getSAMFileHeader(), samples, new HashSet()); } + /** + * Reports the format of the given genotyping data, taken directly from the stub. + * @return The format of the genotyping file. + */ + @Override + public GenotypeWriterFactory.GENOTYPE_FORMAT getFormat() { + return format; + } + + public void mergeInto( GenotypeWriter targetStream ) { // TODO -- This is ugly, but there is no GenotypeWriter interface since diff --git a/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriter.java b/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriter.java index ea82403aa..3c0867d75 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/GenotypeWriter.java @@ -36,6 +36,13 @@ import java.util.List; */ public interface GenotypeWriter { + /** + * Gets the file format of this genotype writer, to disambiguate + * between different forms of data required. + * @return Type of this GenotypeWriter. + */ + public GenotypeWriterFactory.GENOTYPE_FORMAT getFormat(); + /** * Add a genotype, given a genotype locus * @param call the locus to add diff --git a/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliAdapter.java b/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliAdapter.java index 80a9dfb7a..739b408c8 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliAdapter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliAdapter.java @@ -61,6 +61,15 @@ public class GeliAdapter implements GenotypeWriter { this.writeTo = writeTo; } + /** + * Indicates that this is a binary-format geli writer. + * @return GENOTYPE_FORMAT.GELI_BINARY always. + */ + @Override + public GenotypeWriterFactory.GENOTYPE_FORMAT getFormat() { + return GenotypeWriterFactory.GENOTYPE_FORMAT.GELI_BINARY; + } + /** * wrap a GeliFileWriter in the Genotype writer interface * diff --git a/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliTextWriter.java b/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliTextWriter.java index 1f249955b..23f4aca22 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliTextWriter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/geli/GeliTextWriter.java @@ -44,6 +44,15 @@ public class GeliTextWriter implements GenotypeWriter { mWriter.println(headerLine); } + /** + * Indicates that this is a geli writer. + * @return GENOTYPE_FORMAT.GELI always. + */ + @Override + public GenotypeWriterFactory.GENOTYPE_FORMAT getFormat() { + return GenotypeWriterFactory.GENOTYPE_FORMAT.GELI; + } + public final static String headerLine = "#Sequence Position ReferenceBase NumberOfReads MaxMappingQuality BestGenotype BtrLod BtnbLod AA AC AG AT CC CG CT GG GT TT"; /** diff --git a/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFWriter.java b/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFWriter.java index 275fd136e..668f5c446 100755 --- a/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFWriter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/glf/GLFWriter.java @@ -83,6 +83,15 @@ public class GLFWriter implements GenotypeWriter { outputBinaryCodec.setOutputFileName(writeTo.toString()); } + /** + * Indicates that this is a GLF writer. + * @return GENOTYPE_FORMAT.GLF always. + */ + @Override + public GenotypeWriterFactory.GENOTYPE_FORMAT getFormat() { + return GenotypeWriterFactory.GENOTYPE_FORMAT.GLF; + } + /** * Write out the header information for the GLF file. The header contains * the magic number, the length of the header text, the text itself, the reference diff --git a/java/src/org/broadinstitute/sting/utils/genotype/tabular/TabularLFWriter.java b/java/src/org/broadinstitute/sting/utils/genotype/tabular/TabularLFWriter.java index 17199dd08..9078a1e9d 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/tabular/TabularLFWriter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/tabular/TabularLFWriter.java @@ -38,6 +38,16 @@ public class TabularLFWriter implements GenotypeWriter { outStream.println("location sample_name ref alt genotype qhat qstar lodVsRef lodVsNextBest depth bases"); } + /** + * Indicates that this is a tabular genotype writer. + * @return GENOTYPE_FORMAT.TABULAR always. + */ + @Override + public GenotypeWriterFactory.GENOTYPE_FORMAT getFormat() { + return GenotypeWriterFactory.GENOTYPE_FORMAT.TABULAR; + } + + /** * Add a genotype, given a genotype locus * diff --git a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java index 3f0c1cce6..22c79a708 100644 --- a/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java +++ b/java/src/org/broadinstitute/sting/utils/genotype/vcf/VCFGenotypeWriterAdapter.java @@ -35,6 +35,15 @@ public class VCFGenotypeWriterAdapter implements GenotypeWriter { mWriter = new VCFWriter(writeTo); } + /** + * Indicates that this is a VCF writer. + * @return GENOTYPE_FORMAT.VCF always. + */ + @Override + public GenotypeWriterFactory.GENOTYPE_FORMAT getFormat() { + return GenotypeWriterFactory.GENOTYPE_FORMAT.VCF; + } + /** * initialize this VCF header *