[Bioperl-l] Simplealign question
Sendu Bala
bix at sendu.me.uk
Thu Mar 8 16:32:51 UTC 2007
Luba Pardo wrote:
> Hello all,
> I am trying to understand the objects of the Bio::SimpleAlign module. I read
> in the doc of the module that you get an array of Seq objects if you use the
> each_seq method.
> So, can you get back the sequences used in the alignment from the align
> object using the each_seq method? For example:
>
> # Extract sequences and check values for the alignment column $pos (this is
> part of the doc. example)
> foreach $seq ($aln->each_seq) {
>
> }
> what the $seq is? I printed and is a locatableseq object, but if it is a Seq
> object, should I be able to get the actual seq string? I tried something
> like
> ...
> my $seq_obj= Bio::Seq->new();
>
> my $x = $seq_obj->seq;
> but it does not print anything.
You just created a new Bio::Seq object and didn't supply any sequence to
it, so of course asking for the sequence isn't going to give you anything.
When you get a $seq from each_seq() in your foreach loop, $seq is
already a Bio::LocatableSeq as you already discovered (which inherits
from Bio::PrimarySeq) so you don't create a new one. You just use it via
the methods it has:
http://doc.bioperl.org/bioperl-live/Bio/PrimarySeq.html
foreach $seq ($aln->each_seq) {
print $seq->seq, "\n";
}
I think it will be very beneficial to you to go away and learn about
basic object oriented programming:
http://perldoc.perl.org/perlboot.html
http://perldoc.perl.org/perltoot.html
or even non-perl-specific resources.
More information about the Bioperl-l
mailing list