Add a getFormat() method to get the output format from the writer. The need for
this call suggests that I may be thinking about the typing of the GenotypeWriter object the wrong way. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2418 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
11cbfcec9c
commit
b780ffb34a
|
|
@ -45,6 +45,7 @@ import edu.mit.broad.picard.genotype.geli.GeliFileReader;
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
public class GenotypeWriterStorage implements GenotypeWriter, Storage<GenotypeWriter> {
|
public class GenotypeWriterStorage implements GenotypeWriter, Storage<GenotypeWriter> {
|
||||||
|
private final GenotypeWriterFactory.GENOTYPE_FORMAT format;
|
||||||
private final File file;
|
private final File file;
|
||||||
private final GenotypeWriter writer;
|
private final GenotypeWriter writer;
|
||||||
|
|
||||||
|
|
@ -53,12 +54,23 @@ public class GenotypeWriterStorage implements GenotypeWriter, Storage<GenotypeWr
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenotypeWriterStorage( GenotypeWriterStub stub, File file ) {
|
public GenotypeWriterStorage( GenotypeWriterStub stub, File file ) {
|
||||||
|
this.format = stub.getFormat();
|
||||||
this.file = file;
|
this.file = file;
|
||||||
writer = GenotypeWriterFactory.create(stub.getFormat(), file);
|
writer = GenotypeWriterFactory.create(stub.getFormat(), file);
|
||||||
Set<String> samples = SampleUtils.getSAMFileSamples(stub.getSAMFileHeader());
|
Set<String> samples = SampleUtils.getSAMFileSamples(stub.getSAMFileHeader());
|
||||||
GenotypeWriterFactory.writeHeader(writer, stub.getSAMFileHeader(), samples, new HashSet<VCFHeaderLine>());
|
GenotypeWriterFactory.writeHeader(writer, stub.getSAMFileHeader(), samples, new HashSet<VCFHeaderLine>());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 ) {
|
public void mergeInto( GenotypeWriter targetStream ) {
|
||||||
|
|
||||||
// TODO -- This is ugly, but there is no GenotypeWriter interface since
|
// TODO -- This is ugly, but there is no GenotypeWriter interface since
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,13 @@ import java.util.List;
|
||||||
*/
|
*/
|
||||||
public interface GenotypeWriter {
|
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
|
* Add a genotype, given a genotype locus
|
||||||
* @param call the locus to add
|
* @param call the locus to add
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,15 @@ public class GeliAdapter implements GenotypeWriter {
|
||||||
this.writeTo = writeTo;
|
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
|
* wrap a GeliFileWriter in the Genotype writer interface
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,15 @@ public class GeliTextWriter implements GenotypeWriter {
|
||||||
mWriter.println(headerLine);
|
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";
|
public final static String headerLine = "#Sequence Position ReferenceBase NumberOfReads MaxMappingQuality BestGenotype BtrLod BtnbLod AA AC AG AT CC CG CT GG GT TT";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,15 @@ public class GLFWriter implements GenotypeWriter {
|
||||||
outputBinaryCodec.setOutputFileName(writeTo.toString());
|
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
|
* 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
|
* the magic number, the length of the header text, the text itself, the reference
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,16 @@ public class TabularLFWriter implements GenotypeWriter {
|
||||||
outStream.println("location sample_name ref alt genotype qhat qstar lodVsRef lodVsNextBest depth bases");
|
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
|
* Add a genotype, given a genotype locus
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,15 @@ public class VCFGenotypeWriterAdapter implements GenotypeWriter {
|
||||||
mWriter = new VCFWriter(writeTo);
|
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
|
* initialize this VCF header
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue