Class FastaReferenceWriterBuilder
FastaReferenceWriter
You can set each of the four outputs (fasta, dictionary and index, both gzi and fai) to a file or a stream.
by default if you provide a file to the fasta an accompanying set of indexes and dictionary will be created.
This behaviour can be controlled by setMakeDictOutput(boolean)
and setMakeFaiOutput(boolean)
and setMakeGziOutput(boolean)
The default bases-per-line is 60.
Setting a file or an output stream for any of the four outputs (fasta, fai, gzi or dict) will invalidate the other output type (i.e. setting a file output will invalidate a previous stream and vice-versa).
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Create theFastaReferenceWriter
.protected static int
checkBasesPerLine
(int value) boolean
setBasesPerLine
(int basesPerLine) Sets the number of bases each line of the fasta file will have.setDictFile
(Path dictFile) Set the output dictionary file to write to.setDictOutput
(OutputStream dictOutput) Set the output stream for writing the dictionary.setEmitMd5
(boolean emitMd5) setFastaFile
(Path fastaFile) Set the output fasta file to write to.setFastaOutput
(OutputStream fastaOutput) Set the output stream for writing the reference.setGziIndexFile
(Path gziIndexFile) Set the output gzi index file to write to.setGziIndexOutput
(OutputStream gziIndexOutput) Set the output stream for writing the index.setIndexFile
(Path faiIndexFile) Set the output fai index file to write to.setIndexOutput
(OutputStream faiIndexOutput) Set the output stream for writing the index.setMakeDictOutput
(boolean makeDictOutput) Sets whether to automatically generate an dictionary file from the name of the fasta-file (assuming it is given as a file).setMakeFaiOutput
(boolean makeFaiOutput) Sets whether to automatically generate an index file from the name of the fasta-file (assuming it is given as a file).setMakeGziOutput
(boolean makeGziOutput) Sets whether to automatically generate a gzi index file using an index file name derived from the name of the fasta-file (assuming the fasta file is a valid bgzipped file).
-
Constructor Details
-
FastaReferenceWriterBuilder
public FastaReferenceWriterBuilder()
-
-
Method Details
-
checkBasesPerLine
protected static int checkBasesPerLine(int value) -
setFastaFile
Set the output fasta file to write to. Will automatically write a blockCompressed output for files ending with ".gz" extension. If the index file and output stream are both null and makeFaiOutput is true (default), a default index file will be created as well. If the gzi index file and output stream are both null and makeGziOutput is true (default), a default gzi index file will be created if the output is block compressed. If the dictionary file and output stream are both null and makeDictOutput is true (default), a default dictionary file will be created as well. You can only provide a compressed stream to the fastaOutput, and only in the case that an index isn't written.- Parameters:
fastaFile
- aPath
to the output fasta file.- Returns:
- this builder
-
setMakeFaiOutput
Sets whether to automatically generate an index file from the name of the fasta-file (assuming it is given as a file). This can only happen if both the index file and output stream have not been provided.- Parameters:
makeFaiOutput
- a boolean flag- Returns:
- this builder
-
setMakeDictOutput
Sets whether to automatically generate an dictionary file from the name of the fasta-file (assuming it is given as a file). This can only happen if both the dictionary file and output stream have not been provided.- Parameters:
makeDictOutput
- a boolean flag- Returns:
- this builder
-
setMakeGziOutput
Sets whether to automatically generate a gzi index file using an index file name derived from the name of the fasta-file (assuming the fasta file is a valid bgzipped file). This can only happen if neither an index file nor an index output stream are provided.- Parameters:
makeGziOutput
- a boolean flag- Returns:
- this builder
-
setBasesPerLine
Sets the number of bases each line of the fasta file will have. the default is 60- Parameters:
basesPerLine
- integer (must be positive, validated onbuild()
) indicating the number of bases per line in the output- Returns:
- this builder
-
setIndexFile
Set the output fai index file to write to. -
setGziIndexFile
Set the output gzi index file to write to. -
setDictFile
Set the output dictionary file to write to. -
setFastaOutput
Set the output stream for writing the reference. Doesn't support compressed streams.NOTE: If you would like to output a BlockCompressed fasta file it is recommended you use
setFastaFile(Path)
as that codepath will handle generation of a gzi index automatically.- Parameters:
fastaOutput
- aOutputStream
for the output fasta file.- Returns:
- this builder
-
setIndexOutput
Set the output stream for writing the index.- Parameters:
faiIndexOutput
- aOutputStream
for the output index. Doesn't support compressed streams.- Returns:
- this builder
-
setGziIndexOutput
Set the output stream for writing the index.- Parameters:
gziIndexOutput
- aOutputStream
for the gzi output index. Doesn't support compressed streams.- Returns:
- this builder
-
setDictOutput
Set the output stream for writing the dictionary.- Parameters:
dictOutput
- aOutputStream
for the output dictionary. Doesn't support compressed streams.- Returns:
- this builder
-
build
Create theFastaReferenceWriter
. This is were all the validations happen:- -One of fastaFile and fastaOutput must be non-null.
- -the number of bases-per-line must be positive
- Returns:
- a
FastaReferenceWriter
- Throws:
IOException
- if trouble opening files
-
getEmitMd5
public boolean getEmitMd5()- Returns:
- whether the reference builder will emit M5 tag in the header lines
-
setEmitMd5
- Parameters:
emitMd5
- whether the reference builder will emit the M5 tag in the header line * (and populate it with the md5 digest of the sequence)- Returns:
- this builder
-