string_fasta_parser(astr,
template=None,
dogaps=False)
| source code
|
Given astr (string of fasta), returns an iterator that iterates
over the fasta file. It will yield dictionaries keyed
according to the fields in template . These
dictionaries will all also include a sequence keyed by
"sequence". Yielding dictionaries allows for flexibility in the
types of fasta files parsed.
This function will do its best to remove unneeded whitespace,
including line breaks.
Beyond simple extra whitespace, the `astr` should be properly
formatted fasta text.
- Parameters:
astr (str) - fasta text
template (FastaTemplate) - instance of FastaTemplate class--choose from
TEMPLATES or define your own.
dogaps - a bool specifying whether to keep "-" in
the sequence after parsing the file
-
if
False , then gaps are ignored
-
handy if processing an alignment
|