Package htsjdk.samtools
Class SAMSequenceDictionaryCodec
java.lang.Object
htsjdk.samtools.SAMSequenceDictionaryCodec
"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 Summary
-
Method Summary
Modifier and TypeMethodDescriptiondecode
(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 Details
-
SAMSequenceDictionaryCodec
-
-
Method Details
-
encodeSequenceRecord
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
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
ConvertSAMSequenceDictionary
from in-memory representation to text representation.- Parameters:
dictionary
- object to be converted to text.
-
setValidationStringency
-