Additional logging of the temp file creation, management, and merging process
for VCF files. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5234 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
5f10fffa47
commit
8d6db5d188
|
|
@ -1,5 +1,6 @@
|
||||||
package org.broadinstitute.sting.gatk.io.storage;
|
package org.broadinstitute.sting.gatk.io.storage;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.broad.tribble.source.BasicFeatureSource;
|
import org.broad.tribble.source.BasicFeatureSource;
|
||||||
import org.broad.tribble.vcf.*;
|
import org.broad.tribble.vcf.*;
|
||||||
import org.broad.tribble.util.variantcontext.VariantContext;
|
import org.broad.tribble.util.variantcontext.VariantContext;
|
||||||
|
|
@ -18,6 +19,11 @@ import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||||
* @version 0.1
|
* @version 0.1
|
||||||
*/
|
*/
|
||||||
public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
|
public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
|
||||||
|
/**
|
||||||
|
* our log, which we want to capture anything from this class
|
||||||
|
*/
|
||||||
|
private static Logger logger = Logger.getLogger(VCFWriterStorage.class);
|
||||||
|
|
||||||
protected final File file;
|
protected final File file;
|
||||||
protected OutputStream stream;
|
protected OutputStream stream;
|
||||||
protected final VCFWriter writer;
|
protected final VCFWriter writer;
|
||||||
|
|
@ -70,6 +76,7 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
|
||||||
* @param tempFile File into which to direct the output data.
|
* @param tempFile File into which to direct the output data.
|
||||||
*/
|
*/
|
||||||
public VCFWriterStorage(VCFWriterStub stub, File tempFile) {
|
public VCFWriterStorage(VCFWriterStub stub, File tempFile) {
|
||||||
|
logger.debug("Creating temporary VCF file " + tempFile.getAbsolutePath() + " for VCF output.");
|
||||||
this.file = tempFile;
|
this.file = tempFile;
|
||||||
this.writer = vcfWriterToFile(stub, file, false);
|
this.writer = vcfWriterToFile(stub, file, false);
|
||||||
writer.writeHeader(stub.getVCFHeader());
|
writer.writeHeader(stub.getVCFHeader());
|
||||||
|
|
@ -92,12 +99,16 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
|
||||||
* Close the VCF storage object.
|
* Close the VCF storage object.
|
||||||
*/
|
*/
|
||||||
public void close() {
|
public void close() {
|
||||||
|
if(file != null)
|
||||||
|
logger.debug("Closing temporary file " + file.getAbsolutePath());
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mergeInto(VCFWriterStorage target) {
|
public void mergeInto(VCFWriterStorage target) {
|
||||||
try {
|
try {
|
||||||
//System.out.printf("merging %s%n", file);
|
String sourceFilePath = file.getAbsolutePath();
|
||||||
|
String targetFilePath = target.file != null ? target.file.getAbsolutePath() : "/dev/stdin";
|
||||||
|
logger.debug(String.format("Merging %s into %s",sourceFilePath,targetFilePath));
|
||||||
BasicFeatureSource<VariantContext> source = BasicFeatureSource.getFeatureSource(file.getAbsolutePath(), new VCFCodec(), false);
|
BasicFeatureSource<VariantContext> source = BasicFeatureSource.getFeatureSource(file.getAbsolutePath(), new VCFCodec(), false);
|
||||||
|
|
||||||
for ( VariantContext vc : source.iterator() ) {
|
for ( VariantContext vc : source.iterator() ) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue