Skip to main content

Crate mafft_io

Crate mafft_io 

Source
Expand description

I/O routines for MAFFT: FASTA, Clustal, PHYLIP, hat2, and localhom formats.

FASTA reading/writing delegates to noodles-fasta. The other formats are MAFFT-specific or simple enough that we implement them directly.

Structs§

Hat2Matrix
MAFFT’s hat2 distance matrix format.
IllegalResidue
The first residue seqcheck would reject, in reading order.

Enums§

IoError

Functions§

apply_case_convention
Apply C MAFFT’s residue-case convention to an already-parsed set: lowercase for DNA/RNA, uppercase for everything else.
compute_clustal_marks
Compute CLUSTAL-format conservation marks per column.
detect_seq_type
Detect whether sequences are DNA/RNA or protein by ATGC frequency.
detect_seq_type_with_limit
find_illegal_residue
Scan set the way C seqcheck does and return the first residue that is not in the alphabet for set.seq_type, or None when every residue is legal. Gap characters (-) are part of both alphabets, so a gapped input passes.
normalize_residues
Apply the FASTA reader’s residue filter to residues that are already in memory, so an in-memory caller ends up with exactly the bytes a FASTA round trip would have produced — and fails exactly where the reader would.
read_fasta
Read a FASTA file from a path into a SequenceSet.
read_fasta_casepreserve
Read a FASTA file preserving case and non-standard residues — used by --anysymbol/--preservecase. Strips only newline, space and carriage return (matching C MAFFT’s readData_pointer_casepreservecharfilter, io.c:1329-1352); any other character — digits, tabs, punctuation, lowercase — is kept verbatim so the post-alignment restore pass can put the originals back.
read_fasta_from_reader
Read FASTA from any buffered reader.
read_fasta_from_reader_casepreserve
Like read_fasta_from_reader but preserves case and non-standard residues (see read_fasta_casepreserve).
read_hat2
Read a hat2 distance matrix.
read_localhom_table
Read a local homology table (hat3 format).
residues_are_normalized
true when normalize_residues would return raw unchanged, i.e. the residues already look like they came out of the FASTA reader. Lets a caller holding borrowed data skip the copy when nothing needs to change. Residues the reader would reject are not “unchanged”.
residues_follow_case_convention
true when apply_case_convention would leave data unchanged for a set of type seq_type: no uppercase letters for nucleotides, no lowercase letters otherwise.
seqcheck_alphabet
The alphabet seqcheck tests set against — mafft_scoring’s DNA alphabet for nucleotide sets, its protein alphabet otherwise.
write_clustal
Write an alignment in Clustal format.
write_clustal_full
Write an alignment in Clustal format with an optional header comment (e.g. the alignment-mode label FFT-NS-2).
write_fasta
Write a SequenceSet as FASTA to a file path.
write_fasta_to_writer
Write a SequenceSet as FASTA to any writer.
write_fasta_to_writer_with_width
Write FASTA with a custom line width. Pass 0 for unlimited (single line).
write_hat2
Write a hat2 distance matrix.
write_localhom_table
Write a local homology table (hat3 format).
write_phylip
Write an alignment in interleaved PHYLIP format.