API reference
pydustmasker.DustMasker
Identify and mask low-complexity regions in nucleotide sequences using the SDUST algorithm from DustMasker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The nucleotide sequence to be processed. Characters other than 'A', 'C', 'G', 'T', 'a', 'c', 'g', 't' will be considered ambiguous bases. 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 a negative integer is passed to |
Methods:
mask
mask(hard: bool = False) -> str
Returns 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). By default, bases within low-complexity regions are converted to lowercase (i.e., soft-masking). |
False
|
pydustmasker.LongdustMasker
Identify and mask low-complexity regions in nucleotide sequences 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
|
|
float | 'auto' | None
|
GC content for bias correction. If None (default), assume a uniform base composition. If 'auto', compute GC from the input sequence. If a float between 0.0 and 1.0, use that value. |
None
|
|
int | None
|
Maximum allowable score drop for X-drop extension termination. During backward scanning, extension continues as long as (max_score - current_score) remains below (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. By default, 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 |
float | 'auto' | None
|
Option used for GC bias correction. Can be None (a uniform base composition was assumed), 'auto' (GC was computed from the input sequence), or a float between 0.0 and 1.0 (provided by the user). |
xdrop |
int | None
|
Extension X-drop length. |
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
Returns 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). By default, bases within low-complexity regions are converted to lowercase (i.e., soft-masking). |
False
|
pydustmasker.TantanMasker
Identify and mask low-complexity regions and short-period tandem repeats in nucleotide or protein sequences using the tantan algorithm.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
str
|
The nucleotide or protein sequence to be processed. When |
required |
|
bool
|
If True, treat the sequence as a protein sequence; otherwise, treat it as a nucleotide sequence. |
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 | None
|
Maximum repeat period (cycle length) to consider. If None (default), it
resolves to 50 for protein sequences and 100 for nucleotide sequences.
|
None
|
|
int
|
Cost of opening a gap within a repeat. |
0
|
|
int | 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 above which a position is considered part
of a repeat. Used by |
0.5
|
|
float
|
Minimum estimated copy number (tract length divided by consensus unit
length) 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
|
gap_open |
int
|
Cost of opening a gap within a repeat. |
gap_extend |
int | None
|
Cost of extending a gap by one more letter, or |
score_threshold |
float
|
Posterior probability threshold used to determine |
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) 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
Returns 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). By default, bases within low-complexity regions are converted to lowercase (i.e., soft-masking). |
False
|
repeat_units
repeat_units() -> tuple[tuple[str, int, int, float], ...]
Returns consensus tandem repeat units from an independent Viterbi
decode. Its tract boundaries can differ from intervals.
Returns:
| Type | Description |
|---|---|
tuple of (str, int, int, float)
|
One |