[Bioperl-l] Bio::AlignIO->add_new ORDER?
Jason Stajich
jason.stajich at gmail.com
Mon Apr 9 19:57:52 UTC 2012
You cannot use
order=1, it would have to be order => 1 as you are passing in a hash not an assignment. However, I think the rearrange function that parses arguments prefers a leading '-' so it should be -order => 1. Same thing for -seq=>$seq not seq=$seq
Did you try using exactly what is in the perldoc?
Title : add_seq
Usage : $myalign->add_seq($newseq);
$myalign->add_seq(-SEQ=>$newseq, -ORDER=>5);
Function : Adds another sequence to the alignment. *Does not* align
it - just adds it to the hashes.
If -ORDER is specified, the sequence is inserted at the
the position spec'd by -ORDER, and existing sequences
are pushed down the storage array.
Returns : nothing
Args : A Bio::LocatableSeq object
Positive integer for the sequence position (optional)
Also - I am not sure what version of the code you are using, that line error you report is not in the current code so you may have to print out what is on those lines or consider upgrading to latest version of the code.
On Apr 5, 2012, at 2:29 PM, Khalfan, Mohammed wrote:
> 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.
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
Jason Stajich
jason.stajich at gmail.com
jason at bioperl.org
More information about the Bioperl-l
mailing list