MSAInput#

class biotite.application_v2.MSAInput(seqtype: Literal['nucleotide', 'protein'], sequences: list[Sequence], matrix: SubstitutionMatrix | None, original_sequences: list[Sequence])[source]#

Bases: object

The sequences and substitution matrix prepared for an MSA run.

Attributes:
seqtype{‘nucleotide’, ‘protein’}

The sequence type the software is run with. A mapped custom sequence type masquerades as 'protein'.

sequenceslist of Sequence

The sequences that are actually written to the input file. These may be mapped protein sequences.

matrixSubstitutionMatrix or None

The substitution matrix that is actually written to the input file, or None if no matrix is used.

original_sequenceslist of Sequence

The original input sequences, used to build the resulting Alignment.

static from_input(sequences: Sequence[Sequence], matrix: SubstitutionMatrix | None, supports_nucleotide: bool, supports_protein: bool, supports_custom_nucleotide_matrix: bool, supports_custom_protein_matrix: bool) → MSAInput#

Validate the input and determine how the sequences and substitution matrix are passed to the MSA software.

Sequences with an exotic alphabet are mapped onto protein sequences, if the software supports protein sequences with a custom substitution matrix.

Parameters:
sequencesiterable object of Sequence

The sequences to be aligned.

matrixSubstitutionMatrix or None

A custom substitution matrix.

supports_nucleotide, supports_proteinbool

Whether the software supports nucleotide or protein sequences, respectively.

supports_custom_nucleotide_matrix, supports_custom_protein_matrixbool

Whether the software supports custom substitution matrices for nucleotide or protein sequences, respectively.

Returns:
inputMSAInput

The prepared input.

read_fasta(file: IO[str]) → tuple[Alignment, ndarray]#

Read an MSA software’s FASTA output into an Alignment.

Parameters:
filefile object

The FASTA file written by the MSA software. The sequences must be identified by their input index.

Returns:
alignmentAlignment

The multiple sequence alignment.

orderndarray, dtype=int

The order of the sequences as intended by the MSA software.

write_fasta(file: IO[str]) → None#

Write the input sequences to a FASTA file, using their index as identifier.

Parameters:
filefile object

The file the sequences are written to.