API reference
pydustmasker.DustMasker
Identify and mask low-complexity nucleotide regions using the SDUST algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The nucleotide sequence to be processed. ASCII characters other than 'A', 'C', 'G', 'T', 'a', 'c', 'g', and 't' are considered ambiguous bases. Non-ASCII characters are rejected. The minimum allowed sequence length is 4 bases. |
required |
|
int
|
The length of the window used by symmetric DUST algorithm. The minimum allowed value is 4. |
64
|
|
int
|
Score threshold for identifying low-complexity regions. Higher values result in fewer regions being masked. |
20
|
Attributes:
| Name | Type | Description |
|---|---|---|
sequence |
str
|
The nucleotide sequence that was provided as input. |
window_size |
int
|
The length of the window used by symmetric DUST algorithm. |
score_threshold |
int
|
Score threshold for identifying low-complexity regions. |
intervals |
tuple of tuples
|
A tuple of tuples representing the start and end positions of the low-complexity regions identified in the sequence. |
n_masked_bases |
int
|
The total number of bases that were masked. |
Methods:
| Name | Description |
|---|---|
mask |
Returns the sequence with low-complexity regions masked. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input parameters violate the following constraints:
|
TypeError
|
If the input parameters are not of the expected type. |
OverflowError
|
If |
Methods:
mask
mask(hard: bool = False) -> str
Return the sequence with low-complexity regions masked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
If True, low-complexity regions will be masked with 'N' (for nucleotide sequences) or 'X' (for protein sequences). Otherwise, residues within low-complexity regions are converted to lowercase (i.e., soft-masking). |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The masked sequence. |
pydustmasker.LongdustMasker
Identify and mask low-complexity nucleotide regions using the Longdust algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
Nucleotide sequence to process. ASCII characters other than 'A', 'C',
'G', 'T', 'a', 'c', 'g', and 't' are treated as ambiguous bases. Non-ASCII
characters are rejected. Must contain at least |
required |
|
int
|
Maximum sliding-window size. Larger windows can detect longer repeats
but use more memory. Must be in the range [ |
5000
|
|
float
|
Score threshold for identifying low-complexity regions. Higher values result in fewer regions being masked. Must be finite and greater than 0.0. |
0.6
|
|
int
|
The k-mer length used by the Longdust algorithm. Must be in the range [1, 12]. |
7
|
|
(None, 'auto')
|
GC content for bias correction. If None (default), assume a uniform base composition. If 'auto', compute the GC content from the unambiguous bases ('A', 'C', 'G', and 'T', case-insensitive) of the input sequence, or use 0.0 if there are none. If a float, it must be between 0.0 and 1.0. |
None
|
|
int or None
|
Maximum allowable score drop for X-drop extension termination. During backward scanning, extension continues while (max_score - current_score) does not exceed (score_threshold * xdrop). Once the score drops by more than this amount from the peak score observed during the scan, extension stops immediately. Lower values enforce stricter extensions and tighter boundaries, potentially truncating part of the low-complexity region, whereas higher values allow more permissive extensions and looser boundaries, which may include non-low-complexity regions. If set to None, X-drop is disabled. |
50
|
|
int
|
Minimum k-mer frequency to start a backward scan. Must be in [2, 65535]. Lower values are more sensitive but slower. |
3
|
|
bool
|
If True, use approximate mode for guaranteed O(L*w) time complexity. In this mode, only the first candidate starting position is examined during backward scanning, rather than checking all candidates to find the optimal one. |
False
|
|
bool
|
If True, only process the forward strand. Otherwise, both strands are processed. |
False
|
Attributes:
| Name | Type | Description |
|---|---|---|
sequence |
str
|
The nucleotide sequence that was provided as input. |
window_size |
int
|
The size of the sliding window used to scan for low-complexity regions. |
score_threshold |
float
|
Score threshold for determining low-complexity regions. |
kmer |
int
|
k-mer length. |
gc |
{None, 'auto'} or float
|
Option used for GC bias correction. Can be None (a uniform base composition was assumed), 'auto' (GC was computed from the unambiguous bases of the input sequence), or a float between 0.0 and 1.0 (provided by the user). |
xdrop |
int or None
|
Multiplier used to derive the X-drop extension threshold. |
min_start_cnt |
int
|
Minimum k-mer frequency to trigger backward scan. |
approx |
bool
|
Whether approximate mode was enabled. |
forward_only |
bool
|
Whether only the forward strand was processed. |
intervals |
tuple of tuples
|
A tuple of tuples representing the start and end positions of the low-complexity regions identified in the sequence. |
n_masked_bases |
int
|
The total number of bases that were masked. |
Methods:
| Name | Description |
|---|---|
mask |
Returns the sequence with low-complexity regions masked. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input parameters violate the following constraints:
|
TypeError
|
If the input parameters are not of the expected type. |
OverflowError
|
If an integer cannot be represented by its parameter type, including a
negative value or |
Methods:
mask
mask(hard: bool = False) -> str
Return the sequence with low-complexity regions masked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
If True, low-complexity regions will be masked with 'N' (for nucleotide sequences) or 'X' (for protein sequences). Otherwise, residues within low-complexity regions are converted to lowercase (i.e., soft-masking). |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The masked sequence. |
pydustmasker.TantanMasker
Identify and mask low-complexity and short-period tandem repeats using tantan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The nucleotide or protein sequence to be processed. When |
required |
|
bool
|
Determines whether the input is treated as a protein sequence (True) or as a nucleotide sequence (False). |
False
|
|
float
|
Probability of transitioning from the background state to a repeat state. Must be in the range [0.0, 1.0). |
0.005
|
|
float
|
Probability of ending a repeat (transitioning from a repeat state back to the background). Must be in the range [0.0, 1.0]. |
0.05
|
|
float
|
Probability decay from one period offset to the next. Must be in the range (0.0, 1.0] and be a normal finite number. |
0.9
|
|
int or None
|
Maximum repeat period (cycle length) to consider. If None (default), it resolves to 50 for protein sequences and 100 for nucleotide sequences. Must be in the range [1, 2147483647]. |
None
|
|
int
|
Cost of opening a gap within a repeat. |
0
|
|
int or None
|
Cost of extending a gap by one more letter. If None (default), gaps within repeats are disabled. If set, must be greater than 0. |
None
|
|
float
|
Posterior probability threshold at or above which a position is considered
part of a repeat. Used by |
0.5
|
|
float
|
Minimum copy-number estimate from the Viterbi path for a tandem repeat
tract to be reported by |
2.0
|
Attributes:
| Name | Type | Description |
|---|---|---|
sequence |
str
|
The sequence that was provided as input. |
protein |
bool
|
Whether the sequence was treated as a protein sequence. |
repeat_start |
float
|
Probability of a repeat starting per position. |
repeat_end |
float
|
Probability of a repeat ending per position. |
decay |
float
|
Probability decay per unit increase in repeat period. |
max_period |
int
|
Maximum tandem repeat period (in letters) considered. Resolved from None to 50 (protein) or 100 (nucleotide) when not provided explicitly. |
gap_open |
int
|
Cost of opening a gap within a repeat. |
gap_extend |
int or None
|
Cost of extending a gap by one more letter, or None if gaps within repeats are disabled. |
score_threshold |
float
|
Posterior probability threshold at or above which a position is considered
part of a repeat by |
min_copy_number |
float
|
Minimum copy number used to filter the tracts returned by |
intervals |
tuple of tuples
|
An immutable tuple of tuples representing the start and end positions of the tandem repeat regions identified in the sequence, based on per-position posterior probabilities. |
n_masked_bases |
int
|
The total number of bases/residues that were masked. |
probabilities |
tuple of float
|
The per-position posterior probability of being part of a tandem repeat,
one value per character of |
Methods:
| Name | Description |
|---|---|
mask |
Returns the sequence with tandem repeat regions masked. |
repeat_units |
Returns the consensus tandem repeat unit(s), optionally for a selected
period, identified via a Viterbi decode independent of |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input parameters violate the following constraints:
|
TypeError
|
If the input parameters are not of the expected type. |
OverflowError
|
If |
Methods:
mask
mask(hard: bool = False) -> str
Return the sequence with low-complexity regions masked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
bool
|
If True, low-complexity regions will be masked with 'N' (for nucleotide sequences) or 'X' (for protein sequences). Otherwise, residues within low-complexity regions are converted to lowercase (i.e., soft-masking). |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The masked sequence. |
repeat_units
repeat_units(period: int | None = None) -> tuple[tuple[str, int, int, float], ...]
Return consensus tandem repeat units from an independent Viterbi decode.
The decoded tract boundaries can differ from intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
int or None
|
Repeat period to select from the candidates on the decoded Viterbi
path. If None (default), the most frequent period in each tract is
selected.
Must be in the range [1, |
None
|
Returns:
| Type | Description |
|---|---|
tuple of (str, int, int, float)
|
One |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If |
OverflowError
|
If |