FastaIterator.py - Iteration over fasta files¶
This module provides a simple iterator of Fasta formatted files. The difference to the biopython iterator is that the iterators in this module skip over comment lines starting with “#”.
Reference¶
-
class
FastaIterator.FastaRecord(title, sequence, fold=False)¶ Bases:
objecta fasta record.
-
title¶ the title of the sequence
- Type
string
-
sequence¶ the sequence
- Type
string
-
-
class
FastaIterator.FastaIterator(f, *args, **kwargs)¶ Bases:
objecta iterator of fasta formatted files.
- Yields
FastaRecord
-
FastaIterator.iterate(infile, comment='#', fold=False)¶ iterate over fasta data in infile
Lines before the first fasta record are ignored (starting with
>) as well as lines starting with the comment character.- Parameters
infile (File) – the input file
comment (char) – comment character
fold (int) – the number of bases before line split when writing out
- Yields
FastaRecord
-
FastaIterator.iterate_together(*args)¶ iterate synchronously over one or more fasta files.
The iteration finishes once any of the files is exhausted.
:param fasta-formatted files to be iterated upon:
- Yields
tuple – a tuple of
FastaRecordcorresponding to the current record in each file.