~ubuntu-branches/ubuntu/raring/bioperl/raring

« back to all changes in this revision

Viewing changes to examples/searchio/blast_example.pl

  • Committer: Bazaar Package Importer
  • Author(s): Charles Plessy
  • Date: 2008-03-18 14:44:57 UTC
  • mfrom: (4 hardy)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20080318144457-1jjoztrvqwf0gruk
* debian/control:
  - Removed MIA Matt Hope (dopey) from the Uploaders field.
    Thank you for your work, Matt. I hope you are doing well.
  - Downgraded some recommended package to the 'Suggests' priority,
    according to the following discussion on Upstream's mail list.
    http://bioperl.org/pipermail/bioperl-l/2008-March/027379.html
    (Closes: #448890)
* debian/copyright converted to machine-readable format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
# For example, $hsp->get_aln will return a Bio::SimpleAlign object,
5
5
# not the alignment in a printable form.
6
6
# This script was used to create the table in the SearchIO HOWTO,
7
 
# found at www.bioperl.org/HOWTOs.
 
7
# found at http://bioperl.open-bio.org/wiki/HOWTO:SearchIO
8
8
# Brian Osborne
9
9
 
10
10
use strict;
14
14
 
15
15
my $file = shift or die "Usage: $0 <BLAST-report-file>\n";
16
16
my $in = new Bio::SearchIO(-format => 'blast',
17
 
                           -file   => $file # comment out this line to read STDIN
18
 
                          );
 
17
                           # comment out the next line to read STDIN
 
18
                           -file   => $file );
 
19
 
19
20
while ( my $result = $in->next_result ) {
20
 
   print "Result\talgorithm\t" . $result->algorithm . "\n";
 
21
   my @stats =  $result->available_statistics;
 
22
   my @params = $result->available_parameters;
 
23
   print "Result\tavailable_statistics\t@stats\n";
 
24
   print "Result\tavailable_parameters\t@params\n";
 
25
   print "Result\talgorithm\t" .         $result->algorithm . "\n";
21
26
   print "Result\talgorithm_version\t" . $result->algorithm_version . "\n";
22
 
   print "Result\tquery_name\t" . $result->query_name . "\n";
23
 
   print "Result\tquery_accession\t" . $result->query_accession . "\n";
24
 
   print "Result\tquery_length\t" . $result->query_length . "\n";
 
27
   print "Result\tquery_name\t" .        $result->query_name . "\n";
 
28
   print "Result\tquery_accession\t" .   $result->query_accession . "\n";
 
29
   print "Result\tquery_length\t" .      $result->query_length . "\n";
25
30
   print "Result\tquery_description\t" . $result->query_description . "\n";
26
 
   print "Result\tdatabase_name\t" . $result->database_name . "\n";
27
 
   print "Result\tdatabase_letters\t" . $result->database_letters . "\n";
28
 
   print "Result\tdatabase_entries\t" . $result->database_entries . "\n";
29
 
   my @stats = $result->available_statistics;
30
 
   print "Result\tavailable_statistics\t@stats\n";
31
 
   my @params = $result->available_parameters;
32
 
   print "Result\tavailable_parameters\t@params\n";
33
 
   print "Result\tnum_hits\t" . $result->num_hits . "\n";
34
 
   print "Result\thits\t" . $result->hits . "\n";
 
31
   print "Result\tdatabase_name\t" .     $result->database_name . "\n";
 
32
   print "Result\tdatabase_letters\t" .  $result->database_letters . "\n";
 
33
   print "Result\tdatabase_entries\t" .  $result->database_entries . "\n";
 
34
   print "Result\tnum_hits\t" .          $result->num_hits . "\n";
 
35
   print "Result\thits\t" .              $result->hits . "\n";
35
36
   while ( my $hit = $result->next_hit ) {
36
 
      print "Hit\tname\t" . $hit->name . "\n";
37
 
      print "Hit\taccession\t" . $hit->accession . "\n";
38
 
      print "Hit\tdescription\t" . $hit->description . "\n";
39
 
      print "Hit\tlength\t" . $hit->length . "\n";
40
 
      #print "Hit\tlength('hit')\t" . $hit->length('hit') . "\n";
41
 
      #print "Hit\tlength('query')\t" . $hit->length('query') . "\n";
42
 
      print "Hit\talgorithm\t" . $hit->algorithm . "\n";
43
 
      print "Hit\traw_score\t" . $hit->raw_score . "\n";
44
 
      print "Hit\tsignificance\t" . $hit->significance . "\n";
45
 
      print "Hit\tbits\t" . $hit->bits . "\n"; 
46
 
      print "Hit\thsps\t" . $hit->hsps . "\n";
47
 
      print "Hit\tnum_hsps\t" . $hit->num_hsps . "\n";
48
 
      print "Hit\tambiguous_aln\t" . $hit->ambiguous_aln . "\n";
49
 
      print "Hit\toverlap\t" . $hit->overlap . "\n";
50
 
      print "Hit\tn\t" . $hit->n . "\n"; 
51
 
      print "Hit\tlogical_length\t" . $hit->logical_length . "\n";
52
 
      print "Hit\tlength_aln\t" . $hit->length_aln . "\n";
53
 
      print "Hit\tgaps\t" . $hit->gaps . "\n";
54
 
      my ($id) = $hit->matches('id');
 
37
      my $id =         $hit->matches('id');
 
38
      my $cons =       $hit->matches('cons');
 
39
      my @accs =       $hit->each_accession_number;
 
40
      my @qidentical = $hit->seq_inds('query','identical');
 
41
      my @qconserved = $hit->seq_inds('query','conserved');
 
42
      my @hidentical = $hit->seq_inds('hit','identical');
 
43
      my @hconserved = $hit->seq_inds('hit','conserved');
 
44
      print "Hit\tseq_inds('query','identical')\t@qidentical\n";
 
45
      print "Hit\tseq_inds('query','conserved')\t@qconserved\n";
 
46
      print "Hit\tseq_inds('hit','identical')\t@hidentical\n";
 
47
      print "Hit\tseq_inds('hit','conserved')\t@hconserved\n";
 
48
      print "Hit\teach_accession_number\t@accs\n";
55
49
      print "Hit\tmatches('id')\t" . $id . "\n";
56
 
      my ($cons) = $hit->matches('cons');
57
50
      print "Hit\tmatches('cons')\t" . $cons . "\n";
58
 
      print "Hit\tfrac_identical\t" . $hit->frac_identical . "\n";
59
 
      print "Hit\tfrac_conserved\t" . $hit->frac_conserved . "\n";
60
 
      print "Hit\tfrac_aligned_query\t" . $hit->frac_aligned_query . "\n";
61
 
      print "Hit\tfrac_aligned_hit\t" . $hit->frac_aligned_hit . "\n";
62
 
      #print "Hit\tfrac_aligned_sbjct\t" . $hit->frac_aligned_sbjct . "\n";
 
51
      print "Hit\tname\t" .                $hit->name . "\n";
 
52
      print "Hit\taccession\t" .           $hit->accession . "\n";
 
53
      print "Hit\tdescription\t" .         $hit->description . "\n";
 
54
      print "Hit\tlength\t" .              $hit->length . "\n";
 
55
      print "Hit\talgorithm\t" .           $hit->algorithm . "\n";
 
56
      print "Hit\traw_score\t" .           $hit->raw_score . "\n";
 
57
      print "Hit\tsignificance\t" .        $hit->significance . "\n";
 
58
      print "Hit\tbits\t" .                $hit->bits . "\n";
 
59
      print "Hit\thsps\t" .                $hit->hsps . "\n";
 
60
      print "Hit\tnum_hsps\t" .            $hit->num_hsps . "\n";
 
61
      print "Hit\tambiguous_aln\t" .       $hit->ambiguous_aln . "\n";
 
62
      print "Hit\toverlap\t" .             $hit->overlap . "\n";
 
63
      print "Hit\tn\t" .                   $hit->n . "\n"; 
 
64
      print "Hit\tlogical_length\t" .      $hit->logical_length . "\n";
 
65
      print "Hit\tlength_aln\t" .          $hit->length_aln . "\n";
 
66
      print "Hit\tgaps\t" .                $hit->gaps . "\n";
 
67
      print "Hit\tfrac_identical\t" .      $hit->frac_identical . "\n";
 
68
      print "Hit\tfrac_conserved\t" .      $hit->frac_conserved . "\n";
 
69
      print "Hit\tfrac_aligned_query\t" .  $hit->frac_aligned_query . "\n";
 
70
      print "Hit\tfrac_aligned_hit\t" .    $hit->frac_aligned_hit . "\n";
63
71
      print "Hit\tnum_unaligned_sbjct\t" . $hit->num_unaligned_sbjct . "\n";
64
 
      print "Hit\tnum_unaligned_hit\t" . $hit->num_unaligned_hit . "\n";
 
72
      print "Hit\tnum_unaligned_hit\t" .   $hit->num_unaligned_hit . "\n";
65
73
      print "Hit\tnum_unaligned_query\t" . $hit->num_unaligned_query . "\n";
66
 
      my (@residues) = $hit->seq_inds('query','identical');
67
 
      print "Hit\tseq_inds('query','identical')\t@residues\n";
68
 
      @residues = $hit->seq_inds('query','conserved');
69
 
      print "Hit\tseq_inds('query','conserved')\t@residues\n";
70
 
      @residues = $hit->seq_inds('hit','identical');
71
 
      print "Hit\tseq_inds('hit','identical')\t@residues\n";
72
 
      @residues = $hit->seq_inds('hit','conserved');
73
 
      print "Hit\tseq_inds('hit','conserved')\t@residues\n";
74
 
      print "Hit\tstrand\t" . $hit->strand . "\n";
75
 
      print "Hit\tframe\t" . $hit->frame . "\n";
76
 
      print "Hit\trank\t" . $hit->rank . "\n";
77
 
      print "Hit\tlocus\t" . $hit->locus . "\n";
78
 
      my @accs = $hit->each_accession_number;
79
 
      print "Hit\teach_accession_number\t@accs\n";
 
74
      print "Hit\tstrand\t" .              $hit->strand . "\n";
 
75
      print "Hit\tframe\t" .               $hit->frame . "\n";
 
76
      print "Hit\trank\t" .                $hit->rank . "\n";
 
77
      print "Hit\tlocus\t" .               $hit->locus . "\n";
80
78
      while ( my $hsp = $hit->next_hsp ) {
81
 
         print "HSP\talgorithm\t" . $hsp->algorithm . "\n";
82
 
         print "HSP\tevalue\t" . $hsp->evalue . "\n";
83
 
         print "HSP\tfrac_identical\t" . $hsp->frac_identical . "\n";
84
 
         print "HSP\tfrac_conserved\t" . $hsp->frac_conserved . "\n";
85
 
         print "HSP\tgaps\t" . $hsp->gaps     . "\n";
86
 
         print "HSP\tquery_string\t" . $hsp->query_string . "\n";
87
 
         print "HSP\thit_string\t" . $hsp->hit_string . "\n";
88
 
         print "HSP\thomology_string\t" . $hsp->homology_string . "\n";
89
 
         print "HSP\tlength('total')\t" . $hsp->length('total') . "\n";
90
 
         print "HSP\tlength('hit')\t" . $hsp->length('hit') . "\n";
91
 
         print "HSP\tlength('query')\t" . $hsp->length('query') . "\n";
92
 
         print "HSP\thsp_length\t" . $hsp->hsp_length . "\n";
93
 
         print "HSP\tframe\t" . $hsp->frame . "\n";
94
 
         print "HSP\tnum_conserved\t" . $hsp->num_conserved . "\n";
95
 
         print "HSP\tnum_identical\t" . $hsp->num_identical . "\n";
96
 
         print "HSP\trank\t" . $hsp->rank . "\n";
97
 
         my (@residues) = $hsp->seq_inds('query','identical');
98
 
         print "HSP\tseq_inds('query','identical')\t@residues\n";
99
 
         @residues = $hsp->seq_inds('query','conserved');
100
 
         print "HSP\tseq_inds('query','conserved')\t@residues\n";
101
 
         @residues = $hsp->seq_inds('hit','identical');
102
 
         print "HSP\tseq_inds('hit','identical')\t@residues\n";
103
 
         @residues = $hsp->seq_inds('hit','conserved');
104
 
         print "HSP\tseq_inds('hit','conserved')\t@residues\n";
105
 
         print "HSP\tscore\t" . $hsp->score . "\n";
106
 
         print "HSP\tbits\t" . $hsp->bits . "\n";
107
 
         my @range = $hsp->range('hit');
108
 
         print "HSP\trange('hit')\t@range\n";
109
 
         @range = $hsp->range('query');
110
 
         print "HSP\trange('query')\t@range\n";
 
79
         my ($qid,$qcons) = $hsp->matches('hit');
 
80
         my ($id,$cons) = $hsp->matches('query');
 
81
         @qidentical = $hsp->seq_inds('query','identical');
 
82
         @qconserved = $hsp->seq_inds('query','conserved');
 
83
         @hidentical = $hsp->seq_inds('hit','identical');
 
84
         @hconserved = $hsp->seq_inds('hit','conserved');
 
85
         my @hrange =  $hsp->range('hit');
 
86
         my @qrange =  $hsp->range('query');
 
87
         my $aln =     $hsp->get_aln;
 
88
         my $alnIO = Bio::AlignIO->new(-format=>"clustalw");
 
89
         print "HSP\trange('hit')\t@hrange\n";
 
90
         print "HSP\trange('query')\t@qrange\n";
 
91
         print "HSP\tseq_inds('hit','identical')\t@hidentical\n";
 
92
         print "HSP\tseq_inds('query','conserved')\t@qconserved\n";
 
93
         print "HSP\tseq_inds('query','identical')\t@qidentical\n";
 
94
         print "HSP\tseq_inds('hit','conserved')\t@hconserved\n";
 
95
         print "HSP\tmatches('hit')\t" .   $qid . " " . $qcons . "\n";
 
96
         print "HSP\tmatches('query')\t" . $id . " " . $cons . "\n";
 
97
         print "HSP\talgorithm\t" .        $hsp->algorithm . "\n";
 
98
         print "HSP\tevalue\t" .           $hsp->evalue . "\n";
 
99
         print "HSP\tfrac_identical\t" .   $hsp->frac_identical . "\n";
 
100
         print "HSP\tfrac_conserved\t" .   $hsp->frac_conserved . "\n";
 
101
         print "HSP\tgaps\t" .             $hsp->gaps     . "\n";
 
102
         print "HSP\tquery_string\t" .     $hsp->query_string . "\n";
 
103
         print "HSP\thit_string\t" .       $hsp->hit_string . "\n";
 
104
         print "HSP\thomology_string\t" .  $hsp->homology_string . "\n";
 
105
         print "HSP\tlength('total')\t" .  $hsp->length('total') . "\n";
 
106
         print "HSP\tlength('hit')\t" .    $hsp->length('hit') . "\n";
 
107
         print "HSP\tlength('query')\t" .  $hsp->length('query') . "\n";
 
108
         print "HSP\thsp_length\t" .       $hsp->hsp_length . "\n";
 
109
         print "HSP\tframe\t" .            $hsp->frame . "\n";
 
110
         print "HSP\tnum_conserved\t" .    $hsp->num_conserved . "\n";
 
111
         print "HSP\tnum_identical\t" .    $hsp->num_identical . "\n";
 
112
         print "HSP\trank\t" .             $hsp->rank . "\n";
 
113
         print "HSP\tscore\t" .            $hsp->score . "\n";
 
114
         print "HSP\tbits\t" .             $hsp->bits . "\n";
111
115
         print "HSP\tpercent_identity\t" . $hsp->percent_identity . "\n";
112
 
         print "HSP\tstrand()\t" . $hsp->strand() . "\n";
113
 
         print "HSP\tstart('hit')\t" . $hsp->start('hit') . "\n";
114
 
         print "HSP\tstart('query')\t" . $hsp->start('query') . "\n";
115
 
         print "HSP\tend('hit')\t" . $hsp->end('hit') . "\n";
116
 
         print "HSP\tend('query')\t" . $hsp->end('query') . "\n";
117
 
         my ($id,$cons) = $hsp->matches('hit');
118
 
         print "HSP\tmatches('hit')\t" . $id . " " . $cons . "\n";
119
 
         ($id,$cons) = $hsp->matches('query');
120
 
         print "HSP\tmatches('query')\t" . $id . " " . $cons . "\n";
121
 
         # use AlignIO to get alignment as text...
122
 
         my $aln = $hsp->get_aln;
123
 
         my $alnIO = Bio::AlignIO->new(-format=>"clustalw");
 
116
         print "HSP\tstrand()\t" .         $hsp->strand() . "\n";
 
117
         print "HSP\tstart('hit')\t" .     $hsp->start('hit') . "\n";
 
118
         print "HSP\tstart('query')\t" .   $hsp->start('query') . "\n";
 
119
         print "HSP\tend('hit')\t" .       $hsp->end('hit') . "\n";
 
120
         print "HSP\tend('query')\t" .     $hsp->end('query') . "\n";
124
121
         print "HSP\talignment\n";
125
122
         print $alnIO->write_aln($aln),"\n\n";
126
123
      }