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:
parent
e6b008f87c
commit
e6d61197e6
|
|
@ -32,7 +32,7 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
|
||||||
public VCFWriterStorage( VCFWriterStub stub ) {
|
public VCFWriterStorage( VCFWriterStub stub ) {
|
||||||
if ( stub.getFile() != null ) {
|
if ( stub.getFile() != null ) {
|
||||||
this.file = stub.getFile();
|
this.file = stub.getFile();
|
||||||
writer = VCFWriterToFile(stub, stub.getFile());
|
writer = vcfWriterToFile(stub,stub.getFile(),true);
|
||||||
}
|
}
|
||||||
else if ( stub.getOutputStream() != null ) {
|
else if ( stub.getOutputStream() != null ) {
|
||||||
this.file = null;
|
this.file = null;
|
||||||
|
|
@ -45,11 +45,12 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* common initialization routine for multiple constructors
|
* common initialization routine for multiple constructors
|
||||||
* @param stub
|
* @param stub Stub to use when constructing the output file.
|
||||||
* @param 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
|
* @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 {
|
try {
|
||||||
if ( stub.isCompressed() )
|
if ( stub.isCompressed() )
|
||||||
stream = new BlockCompressedOutputStream(file);
|
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);
|
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.
|
* Constructs an object which will redirect into a different file.
|
||||||
* @param stub Stub to use when synthesizing file / header info.
|
* @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) {
|
public VCFWriterStorage(VCFWriterStub stub, File tempFile) {
|
||||||
this.file = file;
|
this.file = tempFile;
|
||||||
this.writer = VCFWriterToFile(stub, file);
|
this.writer = vcfWriterToFile(stub, file, false);
|
||||||
writer.writeHeader(stub.getVCFHeader());
|
writer.writeHeader(stub.getVCFHeader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -95,30 +97,10 @@ public class VCFWriterStorage implements Storage<VCFWriterStorage>, VCFWriter {
|
||||||
writer.close();
|
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) {
|
public void mergeInto(VCFWriterStorage target) {
|
||||||
try {
|
try {
|
||||||
//System.out.printf("merging %s%n", file);
|
//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() ) {
|
for ( VariantContext vc : source.iterator() ) {
|
||||||
target.writer.add(vc, vc.getReferenceBaseForIndel());
|
target.writer.add(vc, vc.getReferenceBaseForIndel());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue