Class SAMSequenceDictionaryCodec

java.lang.Object
htsjdk.samtools.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 Details

    • SAMSequenceDictionaryCodec

      public SAMSequenceDictionaryCodec(Writer writer)
  • Method Details

    • 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.
    • encode

      public void encode(SAMSequenceDictionary dictionary)
      Convert SAMSequenceDictionary from in-memory representation to text representation.
      Parameters:
      dictionary - object to be converted to text.
    • setValidationStringency

      public void setValidationStringency(ValidationStringency validationStringency)