[Bioperl-l] Output of a BLAST parse to text file

Adam Witney awitney at sgul.ac.uk
Tue Apr 10 05:11:51 EDT 2012


Hi Zac,

how do you want to sort the information? if its just on num_hsps... then you will have to store the results in an array or something and then sort that before printing your output

adam


On 1 Apr 2012, at 04:35, Zachariah Wylde wrote:

> Hi there,
> 
> I am very new to Bioperl, so excuse me if come across as simple! I need to
> write a bioperl script to extract information from BLAST results.
> The script needs to count how many  HSPs are on each mouse chromosome and
> be written to a tab-separated table. I have this so far, but do not
> understand how to
> sort the information. I would much, appreciate if you could help me??
> 
> Yours sincerely,
> 
> Zac Wylde
> 
> use strict;
> use warnings;
> use lib "C:/Program Files (x86)/BioPerl";
> use Bio::SearchIO;
> 
> my $infile = "Alignment_Ref_Seq.txt";
> open INFILE, $infile or die "Cannot open $infile: $!";
> 
> my $outfile = "assignment2.txt";
> open OUTFILE, ">$outfile" or die "Cannot open $outfile: $!";
> 
> 
> my $parser = new Bio::SearchIO(-format => 'blast', -file =>
> 'Alignment_Ref_Seq.txt');
> 
> 
> while (my $result = $parser->next_result){
> while (my $hit = $result->next_hit){
> while (my $hsp = $hit->next_hsp){
> if ($hit->description =~ /(mus musculus)|(mouse)/i){
> if ($hit->description =~ /chromosome (\w+)/){
> print "Hit = ", $hit->name, " \t",
> "chromosome = ", $1, " \t",
> "HSPs = ", $hit->num_hsps, "\n";
> }
> }
> }
> }
> }
> 
> close INFILE;
> close OUTFILE;
> 
> #unknown
> #chromosome from
> _______________________________________________
> 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