augur.io.sequences
- augur.io.sequences.read_sequences(*paths, format='fasta')
Read sequences from one or more paths.
Automatically infer compression mode (e.g., gzip, etc.) and return a stream of sequence records in the requested format (e.g., “fasta”, “genbank”, etc.).
- Parameters
paths (list of str or Path-like objects) – One or more paths to sequence files of any type supported by BioPython.
format (str) – Format of input sequences matching any of those supported by BioPython (e.g., “fasta”, “genbank”, etc.).
- Yields
Bio.SeqRecord.SeqRecord – Sequence record from the given path(s).
- augur.io.sequences.write_records_to_fasta(records, fasta, seq_id_field='strain', seq_field='sequence')
Write sequences from dict records to a fasta file. Yields the records with the seq_field dropped so that they can be consumed downstream.
- Parameters
records (iterator[dict]) – Iterator that yields dict that contains sequences
fasta (str) – Path to FASTA file
seq_id_field (str, optional) – Field name for the sequence identifier
seq_field (str, optional) – Field name for the genomic sequence
- Yields
dict – A copy of the record with seq_field dropped
- Raises
AugurError: – When the sequence id field or sequence field does not exist in a record
- augur.io.sequences.write_sequences(sequences, path_or_buffer, format='fasta')
Write sequences to a given path in the given format.
Automatically infer compression mode (e.g., gzip, etc.) based on the path’s filename extension.
- Parameters
sequences (iterable of Bio.SeqRecord.SeqRecord objects) – A list-like collection of sequences to write
path_or_buffer (str or Path-like object or IO buffer) – A path to a file to write the given sequences in the given format.
format (str) – Format of input sequences matching any of those supported by BioPython (e.g., “fasta”, “genbank”, etc.)
- Returns
Number of sequences written out to the given path.
- Return type
int