Disable OTF indexing when writing indices for temporary VCFs when running

with -nt option.  When last I checked in, Ryan was seeing a ~25% speedup 
per shard by not indexing.


git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4556 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
hanna 2010-10-22 17:40:37 +00:00
parent e6b008f87c
commit e6d61197e6
1 changed files with 12 additions and 30 deletions

View File

@ -32,7 +32,7 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
public VCFWriterStorage( VCFWriterStub stub ) {
if ( stub.getFile() != null ) {
this.file = stub.getFile();
writer = VCFWriterToFile(stub, stub.getFile());
writer = vcfWriterToFile(stub,stub.getFile(),true);
}
else if ( stub.getOutputStream() != null ) {
this.file = null;
@ -45,11 +45,12 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
/**
* common initialization routine for multiple constructors
* @param stub
* @param file
* @param stub Stub to use when constructing the output file.
* @param file Target file into which to write VCF records.
* @param indexOnTheFly true to index the file on the fly. NOTE: will be forced to false for compressed files.
* @return A VCF writer for use with this class
*/
private StandardVCFWriter VCFWriterToFile(VCFWriterStub stub, File file) {
private StandardVCFWriter vcfWriterToFile(VCFWriterStub stub, File file, boolean indexOnTheFly) {
try {
if ( stub.isCompressed() )
stream = new BlockCompressedOutputStream(file);
@ -60,18 +61,19 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
throw new UserException.CouldNotCreateOutputFile(file, "Unable to open target output stream", ex);
}
return new StandardVCFWriter(file, this.stream, ! stub.isCompressed());
// The GATK/Tribble can't currently index block-compressed files on the fly. Disable OTF indexing even if the user explicitly asked for it.
return new StandardVCFWriter(file, this.stream, indexOnTheFly && !stub.isCompressed());
}
/**
* Constructs an object which will redirect into a different file.
* @param stub Stub to use when synthesizing file / header info.
* @param file File into which to direct the output data.
* @param tempFile File into which to direct the output data.
*/
public VCFWriterStorage(VCFWriterStub stub, File file) {
this.file = file;
this.writer = VCFWriterToFile(stub, file);
public VCFWriterStorage(VCFWriterStub stub, File tempFile) {
this.file = tempFile;
this.writer = vcfWriterToFile(stub, file, false);
writer.writeHeader(stub.getVCFHeader());
}
@ -95,30 +97,10 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
writer.close();
}
/**
* Merges the stream backing up this temporary storage into the target.
* @param target Target stream for the temporary storage. May not be null.
*/
// public void mergeInto(VCFWriterStorage target) {
// PrintStream formattingTarget = new PrintStream(target.stream);
// try {
// BufferedReader reader = new BufferedReader(new FileReader(file));
// String line = reader.readLine();
// while ( line != null ) {
// if (!VCFHeaderLine.isHeaderLine(line))
// formattingTarget.printf("%s%n",line);
// line = reader.readLine();
// }
//
// reader.close();
// } catch (IOException e) {
// throw new UserException.CouldNotReadInputFile(file, "Error reading file in VCFWriterStorage: ", e);
// }
// }
public void mergeInto(VCFWriterStorage target) {
try {
//System.out.printf("merging %s%n", file);
BasicFeatureSource<VariantContext> source = BasicFeatureSource.getFeatureSource(file.getAbsolutePath(), new VCFCodec());
BasicFeatureSource<VariantContext> source = BasicFeatureSource.getFeatureSource(file.getAbsolutePath(), new VCFCodec(), false);
for ( VariantContext vc : source.iterator() ) {
target.writer.add(vc, vc.getReferenceBaseForIndel());