smftools.informatics.sequence_encoding#
Functions
|
Decode integer-encoded bases into characters using constant mappings. |
|
Encode a base sequence into integer values using constant mappings. |
|
Encode integer Phred quality scores as a FASTQ Phred+33 quality string. |
- smftools.informatics.sequence_encoding.encode_sequence_to_int(sequence, *, base_to_int=mappingproxy({'A': 0, 'C': 1, 'G': 2, 'T': 3, 'N': 4, 'PAD': 5}), unknown_base='N')#
Encode a base sequence into integer values using constant mappings.
- Parameters:
sequence (
Union[str,Iterable[str]]) -- Sequence string or iterable of base characters.base_to_int (
Mapping[str,int] (default:mappingproxy({'A': 0, 'C': 1, 'G': 2, 'T': 3, 'N': 4, 'PAD': 5}))) -- Mapping of base characters to integer encodings.unknown_base (
str(default:'N')) -- Base to use when a character is not in the encoding map.
- Returns:
Integer-encoded sequence array.
- Return type:
np.ndarray
- Raises:
ValueError -- If an unknown base is encountered and
unknown_baseis not mapped.
- smftools.informatics.sequence_encoding.decode_int_sequence(encoded_sequence, *, int_to_base=mappingproxy({0: 'A', 1: 'C', 2: 'G', 3: 'T', 4: 'N', 5: 'PAD'}), unknown_base='N')#
Decode integer-encoded bases into characters using constant mappings.
- Parameters:
encoded_sequence (
Union[Iterable[int],ndarray]) -- Iterable of integer-encoded bases.int_to_base (
Mapping[int,str] (default:mappingproxy({0: 'A', 1: 'C', 2: 'G', 3: 'T', 4: 'N', 5: 'PAD'}))) -- Mapping of integer encodings to base characters.unknown_base (
str(default:'N')) -- Base to use when an integer is not in the decoding map.
- Returns:
Decoded base characters.
- Return type:
- Raises:
ValueError -- If
unknown_baseis not available for fallback.
- smftools.informatics.sequence_encoding.phred_to_fastq_quality_string(quality_scores)#
Encode integer Phred quality scores as a FASTQ Phred+33 quality string.
Values are clamped to
[0, 93], the printable-ASCII range for Phred+33 encoding. This also maps the ragged store's-1missing-quality sentinel (seeragged_store.alignment_to_ragged_record) to Phred 0 ("!").