RnaTokenizer¶
RnaTokenizer is smart, it tokenizes raw RNA nucleotides into tokens, no matter if the input is in uppercase or lowercase, uses U (Uracil) or T (Thymine), and with or without special tokens.
By default, T is read as U; pass replace_T_with_U=False to disable this.
It also supports tokenization into nmers and codons, so you don’t have to write complex code to preprocess your data.
By default, RnaTokenizer uses the standard alphabet.
If nmers is greater than 1, or codon is set to True, it will instead use the streamline alphabet.
multimolecule.tokenisers.RnaTokenizer
¶
Bases: Tokenizer
Tokenizer for RNA sequences.
参数:
| 名称 | 类型 | 描述 | 默认 |
|---|---|---|---|
|
Alphabet | str | List[str] | None
|
alphabet to use for tokenization.
|
None
|
|
int
|
Size of kmer to tokenize. |
1
|
|
bool
|
Whether to tokenize into codons. |
False
|
|
bool
|
Whether to replace T with U. |
True
|
|
bool
|
Whether to convert input to uppercase. |
True
|
示例:
源代码位于: multimolecule/tokenisers/rna/tokenization_rna.py
MultiMolecule provides a set of predefined alphabets for tokenization.
Standard Alphabet¶
The standard alphabet is an extended version of the IUPAC alphabet.
This extension includes two additional nucleotide symbols to the IUPAC alphabet, I and X,
and five sequence symbols, |, ., *, -, and ?.
I: Inosine; a non-canonical nucleotide, the product of adenine deamination, for example by adenosine deaminases acting on tRNAs (ADATs).X: Unknown or other nucleotide; a nucleotide that cannot be mapped to any other symbol of the alphabet. It differs fromN, which represents any one ofA,C,G, andU.|: Chain separator.-: Gap; a deleted position in an aligned sequence..: Gap in an insertion column of an alignment.*: Stop (terminator).?: Missing data; the content of an aligned position is not known. It differs from-, which states that the position is deleted.
T is not a symbol of the RNA alphabets: RnaTokenizer reads T as U by default (replace_T_with_U=True).
In automatic word embedding conversion, an ambiguity symbol (N, R, Y, S, W, K, M, B, D, H, V) or X
that is absent from the original vocabulary is initialized as the mean of the nucleotides it represents; X uses A, C, G, and U.
| Code | Represents |
|---|---|
| A | Adenine |
| C | Cytosine |
| G | Guanine |
| U | Uracil |
| N | Any (A, C, G, or U) |
| R | A or G |
| Y | C or U |
| S | C or G |
| W | A or U |
| K | G or U |
| M | A or C |
| B | C, G, or U |
| D | A, G, or U |
| H | A, C, or U |
| V | A, C, or G |
| I | Inosine |
| X | Unknown or other |
| | | Chain separator |
| . | Gap (insertion column) |
| * | Stop |
| - | Gap |
| ? | Missing data |
IUPAC Alphabet¶
IUPAC nucleotide code is a standard nucleotide code proposed by the International Union of Pure and Applied Chemistry (IUPAC) to represent RNA sequences.
It consists of 10 symbols that represent ambiguity in the nucleotide sequence and 1 symbol that represents a gap in addition to the streamline alphabet.
| Code | Represents |
|---|---|
| A | Adenine |
| C | Cytosine |
| G | Guanine |
| U | Uracil |
| R | A or G |
| Y | C or U |
| S | G or C |
| W | A or U |
| K | G or U |
| M | A or C |
| B | C, G, or U |
| D | A, G, or U |
| H | A, C, or U |
| V | A, C, or G |
| N | A, C, G, or U |
| . | Gap |
In the IUPAC alphabet, . represents a gap.
Streamline Alphabet¶
The streamline alphabet includes one additional symbol to the nucleobase alphabet, N to represent any nucleobase.
| Code | Nucleotide |
|---|---|
| A | Adenine |
| C | Cytosine |
| G | Guanine |
| U | Uracil |
| N | Any |
Nucleobase Alphabet¶
The nucleobase alphabet is a minimal version of the RNA alphabet that includes only the four canonical nucleotides A, C, G, and U.
| Code | Nucleotide |
|---|---|
| A | Adenine |
| C | Cytosine |
| G | Guanine |
| U | Uracil |