nucleotides_to_matrices package¶
Submodules¶
nucleotides_to_matrices.cli module¶
Console script for nucleotides_to_matrices.
nucleotides_to_matrices.encodings module¶
Path, data, and lookup dictionaries for IUPAC code vector encodings
nucleotides_to_matrices.nucleotides_to_matrices module¶
Main module.
-
nucleotides_to_matrices.nucleotides_to_matrices.matrix_to_sequence(matrix: numpy.ndarray, type: str = 'dna') → str[source]¶ Convert a matrix of encoded nucleotides into a string.
Parameters: - matrix : numpy.ndarray
Matrix of encoded nucleotides to convert.
- type: {‘dna’, ‘rna’}, default ‘dna’
The type of nucleotides to convert to. May be either ‘dna’ or ‘rna’.
Returns: - sequence : string
The converted matrix as a string of nucleotide codes.
See also
sequence_to_matrix- Convert a string of nucleotide codes into a matrix.
Examples
>>> example_dna_sequence = 'GATTACAN' >>> dna_matrix = n2m.sequence_to_matrix(example_dna_sequence) >>> dna_matrix >>> array([[0, 0, 1, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]]) >>> dna_sequence = n2m.matrix_to_sequence(dna_matrix) >>> dna_sequence 'GATTACAN' >>> example_rna_sequence = 'GAUUACIN' >>> rna_matrix = n2m.sequence_to_matrix(example_rna_sequence) >>> rna_matrix >>> array([[0, 0, 1, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [1, 1, 1, 1]]) >>> rna_sequence = n2m.matrix_to_sequence(rna_matrix, type = 'rna') >>> rna_sequence 'GAUUACGN'
-
nucleotides_to_matrices.nucleotides_to_matrices.sequence_to_matrix(sequence: str) → numpy.ndarray[source]¶ Convert a string of nucleotide codes into a matrix.
Parameters: - sequence : str
String representing the nucleotides to convert.
Returns: - matrix : numpy.ndarray
The converted string of nucleotide codes as a matrix of integers.
See also
matrix_to_sequence- Converts a matrix into a string of nucleotide codes.
Examples
>>> import nucleotides_to_matrices as n2m >>> example_dna_sequence = 'GATTACAN' >>> n2m.sequence_to_matrix(example_dna_sequence) array([[0, 0, 1, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]]) >>> example_rna_sequence = 'GAUUACIN' >>> n2m.sequence_to_matrix(example_rna_sequence) array([[0, 0, 1, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [1, 1, 1, 1]])
Module contents¶
Top-level package for Nucleotides To Matrices.
-
nucleotides_to_matrices.sequence_to_matrix(sequence: str) → numpy.ndarray[source]¶ Convert a string of nucleotide codes into a matrix.
Parameters: - sequence : str
String representing the nucleotides to convert.
Returns: - matrix : numpy.ndarray
The converted string of nucleotide codes as a matrix of integers.
See also
matrix_to_sequence- Converts a matrix into a string of nucleotide codes.
Examples
>>> import nucleotides_to_matrices as n2m >>> example_dna_sequence = 'GATTACAN' >>> n2m.sequence_to_matrix(example_dna_sequence) array([[0, 0, 1, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]]) >>> example_rna_sequence = 'GAUUACIN' >>> n2m.sequence_to_matrix(example_rna_sequence) array([[0, 0, 1, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [1, 1, 1, 1]])
-
nucleotides_to_matrices.matrix_to_sequence(matrix: numpy.ndarray, type: str = 'dna') → str[source]¶ Convert a matrix of encoded nucleotides into a string.
Parameters: - matrix : numpy.ndarray
Matrix of encoded nucleotides to convert.
- type: {‘dna’, ‘rna’}, default ‘dna’
The type of nucleotides to convert to. May be either ‘dna’ or ‘rna’.
Returns: - sequence : string
The converted matrix as a string of nucleotide codes.
See also
sequence_to_matrix- Convert a string of nucleotide codes into a matrix.
Examples
>>> example_dna_sequence = 'GATTACAN' >>> dna_matrix = n2m.sequence_to_matrix(example_dna_sequence) >>> dna_matrix >>> array([[0, 0, 1, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0], [1, 0, 0, 0], [1, 1, 1, 1]]) >>> dna_sequence = n2m.matrix_to_sequence(dna_matrix) >>> dna_sequence 'GATTACAN' >>> example_rna_sequence = 'GAUUACIN' >>> rna_matrix = n2m.sequence_to_matrix(example_rna_sequence) >>> rna_matrix >>> array([[0, 0, 1, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0], [1, 1, 1, 1]]) >>> rna_sequence = n2m.matrix_to_sequence(rna_matrix, type = 'rna') >>> rna_sequence 'GAUUACGN'