Class SAMSequenceDictionaryCodec


  • public class SAMSequenceDictionaryCodec
    extends Object
    "On the fly" codec SAMSequenceDictionaryCodec. Encodes each sequence and directly writes it to the Dictionary file. To use this class you should provide BufferedWriter to it, and so you should close it as you stop using this class. You can work with this class as shown below. Example of using this class: List dict = ...; //open BufferedReader and close in try-with-resources try(BufferedWriter writer = new BufferedWriter(new FileWriter("path/to/file"))) { SAMSequenceDictionaryCodec codec = new SAMSequenceDictionaryCodec(writer); //we have list of sequences, so encode header line and after that encode each sequence codec.encodeHeaderLine(false); dict.forEach(codec::encodeSequenceRecord); } or SAMSequenceDictionary dict = ...; //open BufferedReader and close in try-with-resources try(BufferedWriter writer = new BufferedWriter(new FileWriter("path/to/file"))) { SAMSequenceDictionaryCodec codec = new SAMSequenceDictionaryCodec(writer); //we have complete SAMSequenceDictionary, so just encode it. codec.encode(dict); }
    • Constructor Detail

      • SAMSequenceDictionaryCodec

        public SAMSequenceDictionaryCodec​(BufferedWriter writer)
    • Method Detail

      • encodeSequenceRecord

        public void encodeSequenceRecord​(SAMSequenceRecord sequenceRecord)
        Parameters:
        sequenceRecord - object to be converted to text.
      • encodeHeaderLine

        public void encodeHeaderLine​(boolean keepExistingVersionNumber)
        Write Header line.
        Parameters:
        keepExistingVersionNumber - boolean flag to keep existing version number.
      • decode

        public SAMSequenceDictionary decode​(LineReader reader,
                                            String source)
        Reads text SAM header and converts to a SAMSequenceDictionary object.
        Parameters:
        reader - Where to get header text from.
        source - Name of the input file, for error messages. May be null.
        Returns:
        complete SAMSequenceDictionary object.
      • setValidationStringency

        public void setValidationStringency​(ValidationStringency validationStringency)