Package Bio :: Package Align :: Module Generic :: Class Alignment
[hide private]
[frames] | no frames]

Class Alignment

source code

Known Subclasses:

Represent a set of alignments.

This is a base class to represent alignments, which can be subclassed to deal with an alignment in a specific format.

Instance Methods [hide private]
 
__init__(self, alphabet)
Initialize a new Alignment object.
source code
 
__iter__(self)
Iterate over alignment rows as SeqRecord objects
source code
 
add_sequence(self, descriptor, sequence, start=None, end=None, weight=1.0)
Add a sequence to the alignment.
source code
 
get_alignment_length(self)
Return the maximum length of the alignment.
source code
 
get_all_seqs(self)
Return all of the sequences involved in the alignment.
source code
 
get_column(self, col)
Returns a string containing a given column
source code
 
get_seq_by_num(self, number)
Retrieve a sequence by the number of the sequence in the consensus.
source code
Method Details [hide private]

__init__(self, alphabet)
(Constructor)

source code 

Initialize a new Alignment object.

Arguments: o alphabet - The alphabet to use for the sequence objects that are created. This alphabet must be a gapped type.

__iter__(self)

source code 
Iterate over alignment rows as SeqRecord objects

e.g.

for record in align :
    print record.id
    print record.seq

add_sequence(self, descriptor, sequence, start=None, end=None, weight=1.0)

source code 
Add a sequence to the alignment.

This doesn't do any kind of alignment, it just adds in the sequence
object, which is assumed to be prealigned with the existing
sequences.

Arguments:
o descriptor - The descriptive id of the sequence being added.
               This will be used as the resulting SeqRecord's
               .id property (and, for historical compatibility,
               also the .description property)
o sequence - A string with sequence info.
o start - You can explicitly set the start point of the sequence.
This is useful (at least) for BLAST alignments, which can just
be partial alignments of sequences.
o end - Specify the end of the sequence, which is important
for the same reason as the start.
o weight - The weight to place on the sequence in the alignment.
By default, all sequences have the same weight. (0.0 => no weight,
1.0 => highest weight)

get_alignment_length(self)

source code 

Return the maximum length of the alignment.

All objects in the alignment should (hopefully) have the same length. This function will go through and find this length by finding the maximum length of sequences in the alignment.

get_all_seqs(self)

source code 

Return all of the sequences involved in the alignment.

The return value is a list of SeqRecord objects.

get_seq_by_num(self, number)

source code 

Retrieve a sequence by the number of the sequence in the consensus.

Returns: o A Seq object for the requested sequence.

Raises: o IndexError - If the specified number is out of range.