[Bioperl-l] Bio::AlignIO->add_new ORDER?

Khalfan, Mohammed mkhalfan at cshl.edu
Thu Apr 5 15:29:35 EDT 2012


Hi,

I am having a problem trying to add a new sequence to an alignment using the order parameter.

I would like to add the sequence to the first position (row) in the alignment, is this possible? Here is what my code looks like:

use Bio::AlignIO;
use Bio::LocatableSeq;
use Bio::SimpleAlign;

my $in = Bio::AlignIO->new( -file => $infile );     # $infile is the output from muscle

my $aln = $in->next_aln;

# build a consensus from the current alignment
my $consensus = $aln->consensus_string();

# make the consensus sequence obtained in the above step into a LocatableSeq object
my $consensus_obj = new Bio::LocatableSeq (
        -seq => $consensus,
        -id => 'Consensus',
        -start => 1,
        -end => length($consensus),
);

# add consensus sequence to alignment
$aln->add_seq($consensus_obj, 1);

## END CODE ##

I have tried
$aln->add_seq(seq=>$consensus_obj, order=1);
$aln->add_seq(SEQ=>$consensus_obj, ORDER=1);

But no luck, I cannot get the consensus listed as the first sequence in the alignment. Is this possible?

I can add it in like this successfully, but it adds it to the end, which is not what I need.
$aln->add_seq($consensus_obj);

These are the errors I get:

Using this syntax: $aln->add_seq($consensus_obj, 1);
I get this error:
Use of uninitialized value in subtraction (-) at /usr/lib/perl5/site_perl/5.8.8/Bio/SimpleAlign.pm line 327, <GEN0> line 132.

Using this syntax: $aln->add_seq(seq=>$consensus_obj, order=1);
I get this error:

------------- EXCEPTION: Bio::Root::Exception -------------
MSG: Unable to process non locatable sequences []
STACK: Error::throw
STACK: Bio::Root::Root::throw /usr/lib/perl5/site_perl/5.8.8/Bio/Root/Root.pm:368
STACK: Bio::SimpleAlign::add_seq /usr/lib/perl5/site_perl/5.8.8/Bio/SimpleAlign.pm:297
STACK: ./muscle_post_processor.pl:49
-----------------------------------------------------------

Any assistance would be much appreciated. Thank you.




More information about the Bioperl-l mailing list