classmethod Alignment.from_fasta_records(fasta_records, seq_constructor, validate=False)[source]

Initialize a SequenceCollection object


Deprecated in scikit-bio 0.2.0-dev from_fasta_records will be removed in scikit-bio 0.3.0. It is replaced by read, which is a more general method for deserializing FASTA-formatted files. read supports multiple file formats, automatic file format detection, etc. by taking advantage of scikit-bio’s I/O registry system. See for more details.


fasta_records : iterator of tuples

The records to load into a new SequenceCollection object. These should be tuples of (sequence_id, sequence).

seq_constructor : skbio.sequence.BiologicalSequence

validate : bool, optional

If True, runs the is_valid method after construction and raises SequenceCollectionError if is_valid == False.


SequenceCollection (or a derived class)

The new SequenceCollection object.



If validate == True and is_valid == False.


>>> from skbio.alignment import SequenceCollection
>>> from skbio.parse.sequences import parse_fasta
>>> from StringIO import StringIO
>>> from skbio.sequence import DNA
>>> fasta_f = StringIO('>seq1\nACCGT\n>seq2\nAACCGGT\n')
>>> s1 = SequenceCollection.from_fasta_records(
...     parse_fasta(fasta_f), DNA)
>>> s1
<SequenceCollection: n=2; mean +/- std length=6.00 +/- 1.00>
>>> records = [('seq1', 'ACCGT'), ('seq2', 'AACCGGT')]
>>> s1 = SequenceCollection.from_fasta_records(records, DNA)
>>> s1
<SequenceCollection: n=2; mean +/- std length=6.00 +/- 1.00>