Class VariantContextWriterBuilder
java.lang.Object
htsjdk.variant.variantcontext.writer.VariantContextWriterBuilder
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionstatic final EnumSet<VariantContextWriterBuilder.OutputType>
static final EnumSet<VariantContextWriterBuilder.OutputType>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Validate and build theVariantContextWriter
.build
(OpenOption... openOptions) Validate and build theVariantContextWriter
.Do not pass anIndexCreator
to the nextVariantContextWriter
created by this builder.Remove all options from the set ofOptions
for theVariantContextWriterBuilder
.Attempts to determine the type of file/data to write based on the File path being written to.Attempts to determine the type of file/data to write based on the File path being written to.modifyOption
(Options option, boolean setIt) Set or unset option depending on the boolean givensetBuffer
(int bufferSize) Set a buffer size for the file output stream passed to the nextVariantContextWriter
created by this builder.Create an MD5 digest file for the nextVariantContextWriter
created by this builder.setCreateMD5
(boolean createMD5) Choose whether to also create an MD5 digest file for the nextVariantContextWriter
created by this builder.static void
setDefaultOption
(Options option) Add one option to the set of defaultOptions
that will be used as the initial set of options for all VariantContextWriterBuilders created after this call.setIndexCreator
(IndexCreator idxCreator) Set an IndexCreator for the nextVariantContextWriter
created by this builder.Add one option to the set ofOptions
for theVariantContextWriterBuilder
, if it's not already present.setOptions
(EnumSet<Options> options) Replace the set ofOptions
for theVariantContextWriterBuilder
with a new set.setOutputBCFStream
(OutputStream outStream) Set the output BCF stream for the nextVariantContextWriter
created by this builder.setOutputFile
(File outFile) Set the output file for the nextVariantContextWriter
created by this builder.setOutputFile
(String outFile) Set the output file for the nextVariantContextWriter
created by this builder.Set the output file type for the nextVariantContextWriter
created by this builder.setOutputPath
(Path outPath) Set the output file for the nextVariantContextWriter
created by this builder.setOutputStream
(OutputStream outStream) Set the output stream (VCF, by default) for the nextVariantContextWriter
created by this builder.setOutputVCFStream
(OutputStream outStream) Set the output VCF stream for the nextVariantContextWriter
created by this builder.Set the reference dictionary to be used byVariantContextWriter
s created by this builder.Do not use buffering in the nextVariantContextWriter
created by this builder.Don't create an MD5 digest file for the nextVariantContextWriter
created by this builder.static void
unsetDefaultOption
(Options option) Remove an option from the set of defaultOptions
that will be used as the initial set of options for all VariantContextWriterBuilders created after this call.unsetOption
(Options option) Remove one option from the set ofOptions
for theVariantContextWriterBuilder
, if it's present.
-
Field Details
-
DEFAULT_OPTIONS
-
NO_OPTIONS
-
FILE_TYPES
-
STREAM_TYPES
-
options
-
-
Constructor Details
-
VariantContextWriterBuilder
public VariantContextWriterBuilder()Default constructor. AddsUSE_ASYNC_IO
to the Options if it is present in Defaults.
-
-
Method Details
-
setReferenceDictionary
Set the reference dictionary to be used byVariantContextWriter
s created by this builder.- Parameters:
refDict
- the reference dictionary- Returns:
- this
VariantContextWriterBuilder
-
setOutputFile
Set the output file for the nextVariantContextWriter
created by this builder. Determines file type implicitly from the filename.- Parameters:
outFile
- the file theVariantContextWriter
will write to- Returns:
- this
VariantContextWriterBuilder
-
setOutputPath
Set the output file for the nextVariantContextWriter
created by this builder. Determines file type implicitly from the filename.- Parameters:
outPath
- the file theVariantContextWriter
will write to- Returns:
- this
VariantContextWriterBuilder
-
setOutputFile
Set the output file for the nextVariantContextWriter
created by this builder. Determines file type implicitly from the filename.- Parameters:
outFile
- the file theVariantContextWriter
will write to- Returns:
- this
VariantContextWriterBuilder
-
setOutputFileType
public VariantContextWriterBuilder setOutputFileType(VariantContextWriterBuilder.OutputType outType) Set the output file type for the nextVariantContextWriter
created by this builder.- Parameters:
outType
- the type of file theVariantContextWriter
will write to- Returns:
- this
VariantContextWriterBuilder
-
setOutputVCFStream
Set the output VCF stream for the nextVariantContextWriter
created by this builder. If buffered writing is desired, caller must provide some kind of bufferedOutputStream
.- Parameters:
outStream
- the output stream to write to- Returns:
- this
VariantContextWriterBuilder
-
setOutputBCFStream
Set the output BCF stream for the nextVariantContextWriter
created by this builder. If buffered writing is desired, caller must provide some kind of bufferedOutputStream
.- Parameters:
outStream
- the output stream to write to- Returns:
- this
VariantContextWriterBuilder
-
setOutputStream
Set the output stream (VCF, by default) for the nextVariantContextWriter
created by this builder. If buffered writing is desired, caller must provide some kind of bufferedOutputStream
.- Parameters:
outStream
- the output stream to write to- Returns:
- this VariantContextWriterBuilder
-
setIndexCreator
Set an IndexCreator for the nextVariantContextWriter
created by this builder.- Parameters:
idxCreator
- theIndexCreator
to use- Returns:
- this
VariantContextWriterBuilder
-
clearIndexCreator
Do not pass anIndexCreator
to the nextVariantContextWriter
created by this builder.- Returns:
- this
VariantContextWriterBuilder
-
setBuffer
Set a buffer size for the file output stream passed to the nextVariantContextWriter
created by this builder. Set to 0 for no buffering. Does not affect OutputStreams passed directly toVariantContextWriterBuilder
.- Parameters:
bufferSize
- the buffer size to use- Returns:
- this
VariantContextWriterBuilder
-
unsetBuffering
Do not use buffering in the nextVariantContextWriter
created by this builder. Does not affectOutputStream
s passed directly toVariantContextWriterBuilder
.- Returns:
- this
VariantContextWriterBuilder
-
setCreateMD5
Choose whether to also create an MD5 digest file for the nextVariantContextWriter
created by this builder.- Parameters:
createMD5
- boolean,true
to create an MD5 digest- Returns:
- this
VariantContextWriterBuilder
-
setCreateMD5
Create an MD5 digest file for the nextVariantContextWriter
created by this builder.- Returns:
- this
VariantContextWriterBuilder
-
unsetCreateMD5
Don't create an MD5 digest file for the nextVariantContextWriter
created by this builder.- Returns:
- this
VariantContextWriterBuilder
-
setOptions
Replace the set ofOptions
for theVariantContextWriterBuilder
with a new set.- Parameters:
options
- the complete set of options to use- Returns:
- this
VariantContextWriterBuilder
-
setOption
Add one option to the set ofOptions
for theVariantContextWriterBuilder
, if it's not already present.- Parameters:
option
- the option to set- Returns:
- this
VariantContextWriterBuilder
-
unsetOption
Remove one option from the set ofOptions
for theVariantContextWriterBuilder
, if it's present.- Parameters:
option
- the option to unset- Returns:
- this
VariantContextWriterBuilder
-
modifyOption
Set or unset option depending on the boolean given- Parameters:
option
- the option to modifysetIt
- true to set the option, false to unset it.- Returns:
- this
VariantContextWriterBuilder
-
setDefaultOption
Add one option to the set of defaultOptions
that will be used as the initial set of options for all VariantContextWriterBuilders created after this call.- Parameters:
option
- the option to set
-
unsetDefaultOption
Remove an option from the set of defaultOptions
that will be used as the initial set of options for all VariantContextWriterBuilders created after this call.- Parameters:
option
- the option to unset
-
clearOptions
Remove all options from the set ofOptions
for theVariantContextWriterBuilder
.- Returns:
- this VariantContextWriterBuilder
-
build
Validate and build theVariantContextWriter
.- Returns:
- the
VariantContextWriter
as specified by previous method calls. - Throws:
RuntimeIOException
- if the writer is configured to write to a file, and the corresponding path does not exist.IllegalArgumentException
- if no output file or stream is specified.IllegalArgumentException
- ifOptions.INDEX_ON_THE_FLY
is specified and no reference dictionary is provided.IllegalArgumentException
- ifOptions.INDEX_ON_THE_FLY
is specified and a stream output is specified.
-
build
Validate and build theVariantContextWriter
.- Parameters:
openOptions
- options to use when opening the underlying output stream.- Returns:
- the
VariantContextWriter
as specified by previous method calls, optionally applying the specified OpenOptions. - Throws:
RuntimeIOException
- if the writer is configured to write to a file, and the corresponding path does not exist.IllegalArgumentException
- if no output file or stream is specified.IllegalArgumentException
- ifOptions.INDEX_ON_THE_FLY
is specified and no reference dictionary is provided.IllegalArgumentException
- ifOptions.INDEX_ON_THE_FLY
is specified and a stream output is specified.
-
determineOutputTypeFromFile
Attempts to determine the type of file/data to write based on the File path being written to. Will attempt to determine using the logical filename; if that fails it will attempt to resolve any symlinks and try again. If that fails, and the output file exists but is neither a file or directory then VCF_STREAM is returned.- Parameters:
file
- A file whoseVariantContextWriterBuilder.OutputType
we want to infer- Returns:
- The file's
VariantContextWriterBuilder.OutputType
. Nevernull
.
-
determineOutputTypeFromFile
Attempts to determine the type of file/data to write based on the File path being written to. Will attempt to determine using the logical filename; if that fails it will attempt to resolve any symlinks and try again. If that fails, and the output file exists but is neither a file or directory then VCF_STREAM is returned.- Parameters:
path
- A file whoseVariantContextWriterBuilder.OutputType
we want to infer- Returns:
- The file's
VariantContextWriterBuilder.OutputType
. Nevernull
.
-