[Bioperl-l] How do you add a consensus to AlignIO?
Jason Stajich
jason at cgt.duhs.duke.edu
Wed Aug 27 21:37:53 EDT 2003
On Thu, 28 Aug 2003, Wes Barris wrote:
> Hi,
>
> I am trying to write a bioperl clustalw to msf converter. I also want
> to add a consensus sequence to the alignment. Here is my code:
>
> #!/usr/local/bin/perl -w
> #
> use strict;
> use Bio::AlignIO;
> use Bio::SeqIO;
>
> my $usage = "Usage: $0 <infile.txt> <outfile.msf>\n";
> my $infile = shift or die $usage;
> my $outfile = shift or die $usage;
>
> my $instream = new Bio::AlignIO(-format=>'clustalw', -file=>$infile);
> my $outstream = new Bio::AlignIO(-format=>'msf', -file=>">$outfile");
> my $aln = $instream->next_aln();
Try:
my $consensus = new Bio::LocatableSeq(-seq=>$aln->consensus_string(),
-id=>'btcn1000');
>
> $aln->id('alignment.msf'); # set the alignment name
> $aln->set_displayname_flat(); # remove the /start-end from the names
> $aln->add_seq($consensus); # add the consensus sequence
>
> $outstream->write_aln($aln);
>
> When I run this, I get this error:
>
> wes at bioserver> clustaltomsf.pl j.aln j.msf
>
> ------------- EXCEPTION Bio::Seq -------------
> MSG: Unable to process non locatable sequences [
> STACK Bio::SimpleAlign::add_seq /usr/lib/perl5/site_perl/5.6.1/Bio/SimpleAlign.pm:245
> STACK toplevel clustaltomsf.pl:18
>
> ----------------------------------------------
>
> Can anyone tell me what I am doing wrong? What is a non locatable sequence?
> How do I make a locatable one?
>
--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu
More information about the Bioperl-l
mailing list