[Bioperl-l] ClustalW alignment and Bioperl::Run module

Kevin Brown Kevin.M.Brown at asu.edu
Mon Oct 2 23:44:50 UTC 2006


Well, for anyone that wants to know, I found a way to capture the output
of ClustalW to get at things like the score.

Copy STDOUT to another handle
open(OUTCOPY, ">&STDOUT") or die "Couldn't dup STDOUT: $!";

Change where STDOUT goes
open(STDOUT, ">log.test") or die "Couldn't open log.test: $!";

Run the alignment and its output will be captured by the STDOUT
redirection
$aln, $factory->align(\@seq);

Restore STDOUT to its normal location for the rest of the script
close STDOUT;
open(STDOUT, ">&OUTCOPY");

I guess I can understand why most of this is just dropped by the
ClustalW.pm module since there doesn't seem to be a way to hold it all
in a SimpleAlign object.

> -----Original Message-----
> From: bioperl-l-bounces at lists.open-bio.org 
> [mailto:bioperl-l-bounces at lists.open-bio.org] On Behalf Of Kevin Brown
> Sent: Thursday, September 28, 2006 2:48 PM
> To: bioperl-l at lists.open-bio.org
> Subject: [Bioperl-l] ClustalW alignment and Bioperl::Run module
> 
> I've gotten a very simple script to run using bioperl that creates an
> alignment using clustalw of two sequences.  I see that clustal outputs
> to stdout information like the score, but I don't see any way to store
> that or retrieve that from the alignment object that is 
> returned (unless
> I'm just blind).  What follows is my very basic script which used code
> found in the Wiki.
> 
> print $aln->score() spits out an error about using an uninitialized
> value.
> 
> 
> #!/usr/bin/perl -w
> 
> use strict;
> use Bio::SeqIO;
> use Bio::Perl;
> use Bio::AlignIO;
> use Getopt::Long qw(:config no_ignore_case bundling pass_through);
> use POSIX;
> use Bio::Tools::Run::Alignment::Clustalw;
> 
> my $fileName   = "";         # filename(s) to be parsed for 
> information
> my $output_dir = "";
> my $format     = 'fasta';    # default format for SeqIO module
> 
> GetOptions(
>                    'file=s'   => \$fileName,
>                    'output=s' => \$output_dir,
>                   );
> 
> # Parse the input file for the needed information
> # SeqIO supports several normal formats including <tab>, <fasta> and
> <excel>
> 
> my @files = split(/\|/, $fileName);
> my @seq_array;
> 
> my $stream_out =
>   Bio::AlignIO->new(-file => '>test.msf', -format => 'msf', -flush =>
> 0);
> 
> foreach my $fileName (@files)
> {
>         my $file = Bio::SeqIO->new(-format => $format, -file =>
> $fileName);
>         my $seq;
>         while ($seq = $file->next_seq())
>         {
>                 push(@seq_array, $seq);
>         }
> }
> 
> my @params  = ('ktuple' => 2, 'matrix' => 'BLOSUM');
> my $factory = Bio::Tools::Run::Alignment::Clustalw->new(@params);
> my $ktuple  = 3;
> $factory->ktuple($ktuple);    # change the parameter before executing
>     # where @seq_array is an array of {{PM|Bio::Seq}} objects
> 
> open my $out, ">seq.txt";
> 
> for (my $i = 1 ; $i <= $#seq_array ; $i++)
> {
>         my @seq = ($seq_array[0], $seq_array[$i]);
>         my $aln = $factory->align(\@seq);
>         $stream_out->write_aln($aln);
>         print $aln->score;
>         for my $seq ($aln->each_seq) {
>                 print $out $seq->display_id() ."\t". $seq->seq()."\n";
>         }
> }
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at lists.open-bio.org
> http://lists.open-bio.org/mailman/listinfo/bioperl-l
> 




More information about the Bioperl-l mailing list