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: Listdict = ...; //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(BufferedWriter writer)
-
Method Summary
All Methods Instance Methods Concrete Methods 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)
ConvertSAMSequenceDictionary
from in-memory representation to text representation.void
encodeHeaderLine(boolean keepExistingVersionNumber)
Write Header line.void
encodeSequenceRecord(SAMSequenceRecord sequenceRecord)
WriteSAMSequenceRecord
.void
setValidationStringency(ValidationStringency validationStringency)
-
-
-
Constructor Detail
-
SAMSequenceDictionaryCodec
public SAMSequenceDictionaryCodec(BufferedWriter writer)
-
-
Method Detail
-
encodeSequenceRecord
public void encodeSequenceRecord(SAMSequenceRecord sequenceRecord)
WriteSAMSequenceRecord
.- 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)
ConvertSAMSequenceDictionary
from in-memory representation to text representation.- Parameters:
dictionary
- object to be converted to text.
-
setValidationStringency
public void setValidationStringency(ValidationStringency validationStringency)
-
-