Package htsjdk.samtools

# 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<SAMSequenceRecord> 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 Summary

Constructors
Constructor
Description
`SAMSequenceDictionaryCodec(Writer writer)`

## Method Summary

Modifier and Type
Method
Description
`SAMSequenceDictionary`
`decode(LineReader reader, String source)`
Reads text SAM header and converts to a SAMSequenceDictionary object.
`void`
`encode(SAMSequenceDictionary dictionary)`
Convert `SAMSequenceDictionary` from in-memory representation to text representation.
`void`
`encodeHeaderLine(boolean keepExistingVersionNumber)`
Write Header line.
`void`
`encodeSequenceRecord(SAMSequenceRecord sequenceRecord)`
Write `SAMSequenceRecord`.
`void`
`setValidationStringency(ValidationStringency validationStringency)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SAMSequenceDictionaryCodec

public SAMSequenceDictionaryCodec(Writer writer)

## Method Details

### encodeSequenceRecord

public void encodeSequenceRecord(SAMSequenceRecord sequenceRecord)
Write `SAMSequenceRecord`.

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)