Class FastaReferenceWriterBuilder


  • public class FastaReferenceWriterBuilder
    extends Object
    Buider for a 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 Detail

      • FastaReferenceWriterBuilder

        public FastaReferenceWriterBuilder()
    • Method Detail

      • checkBasesPerLine

        protected static int checkBasesPerLine​(int value)
      • setFastaFile

        public FastaReferenceWriterBuilder setFastaFile​(Path fastaFile)
        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 - a Path to the output fasta file.
        Returns:
        this builder
      • setMakeFaiOutput

        public FastaReferenceWriterBuilder 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). 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

        public FastaReferenceWriterBuilder 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). 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

        public FastaReferenceWriterBuilder 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). 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

        public FastaReferenceWriterBuilder setBasesPerLine​(int basesPerLine)
        Sets the number of bases each line of the fasta file will have. the default is 60
        Parameters:
        basesPerLine - integer (must be positive, validated on build()) indicating the number of bases per line in the output
        Returns:
        this builder
      • setFastaOutput

        public FastaReferenceWriterBuilder setFastaOutput​(OutputStream fastaOutput)
        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 - a OutputStream for the output fasta file.
        Returns:
        this builder
      • setIndexOutput

        public FastaReferenceWriterBuilder setIndexOutput​(OutputStream faiIndexOutput)
        Set the output stream for writing the index.
        Parameters:
        faiIndexOutput - a OutputStream for the output index. Doesn't support compressed streams.
        Returns:
        this builder
      • setGziIndexOutput

        public FastaReferenceWriterBuilder setGziIndexOutput​(OutputStream gziIndexOutput)
        Set the output stream for writing the index.
        Parameters:
        gziIndexOutput - a OutputStream for the gzi output index. Doesn't support compressed streams.
        Returns:
        this builder
      • setDictOutput

        public FastaReferenceWriterBuilder setDictOutput​(OutputStream dictOutput)
        Set the output stream for writing the dictionary.
        Parameters:
        dictOutput - a OutputStream for the output dictionary. Doesn't support compressed streams.
        Returns:
        this builder
Returns:
a FastaReferenceWriter
Throws:
IOException - if trouble opening files