~ubuntu-branches/ubuntu/lucid/bioperl/lucid

« back to all changes in this revision

Viewing changes to examples/blast/blast_seq.pl

  • Committer: Bazaar Package Importer
  • Author(s): Matt Hope
  • Date: 2004-04-18 14:24:11 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20040418142411-gr92uexquw4w8liq
Tags: 1.4-1
* New upstream release
* Examples and working code are installed by default to usr/bin,
  this has been moved to usr/share/doc/bioperl/bin

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/perl -w
2
 
 
3
 
# IMPORTANT NOTE:
4
 
#  After running this script, you will have a collection of
5
 
#  NCBI BLAST queue submission data files. These can be read by 
6
 
#  retrieve_blast.pl to fetch the actual BLAST reports from NCBI.
7
 
#  See comments in retrieve_blast.pl for usage details.
8
 
 
9
 
#---------------------------------------------------------------------------
10
 
# PROGRAM  : blast_seq.pl
11
 
# PURPOSE  : To submit a set of sequence for Blast analysis and parse the results.
12
 
# AUTHOR   : Steve Chervitz
13
 
# CREATED  : 15 May 1998
14
 
# REVISION : $Id: blast_seq.pl,v 1.7 2002/01/11 08:05:38 sac Exp $
15
 
# WEBSITE  : http://bio.perl.org/Projects/Blast/
16
 
# USAGE    : blast_seq.pl -h
17
 
# EXAMPLES : blast_seq.pl -eg
18
 
#
19
 
# INSTALLATION: 
20
 
#    Set the require ".../blast_config.pl" and require ".../seqtools.pl" 
21
 
#    to point to the proper location of these files on your system.
22
 
#    See blast_config.pl and seqtools.pl for additional steps.
23
 
#
24
 
# MODIFIED:
25
 
#
26
 
#   For all further modifications, refer to the cvs log.
27
 
#
28
 
#  sac, 3 Feb 1999: Added -wait argument to example to prevent timeout
29
 
#      while reading sequence data.
30
 
#  sac, 16 Jun 1998: Added installation comment, require statement comments.
31
 
#---------------------------------------------------------------------------
32
 
 
33
 
# Using files in the examples/blast distribution directory:
34
 
require "../seq/seqtools.pl";
35
 
require "blast_config.pl";
36
 
# Proper paths after you install them in your system:
37
 
#require "/home/steve/bin/bioperl/examples/seq/seqtools.pl";#$require "/home/steve/bin/bioperl/examples/blast/blast_config.pl";
38
 
 
39
 
use vars qw($ID $VERSION $DESC %runParam %blastParam 
40
 
            $opt_parse $opt_table $opt_compress );
41
 
 
42
 
# Command-line options to be imported into seqtools.pl.
43
 
# This allows us to set all params we need with one GetOptions() call.
44
 
@blast_opts = qw(prog=s vers=s db=s html! v=s b=s expect=s gap!
45
 
                 filt=s mat=s gap_c=s gap_e=s email=s word=s
46
 
                 parse! signif=s strict! stats! best!    
47
 
                 table=s compress! rem! loc! check_all! desc!
48
 
                 );
49
 
$ID      = 'blast_seq.pl';
50
 
$VERSION = 0.1;
51
 
$DESC    = "Run and parse a set of Blast reports given a set of Fasta formatted sequences";
52
 
 
53
 
#### Main #####
54
 
 
55
 
&init_seq(\&blast_seq_usage, @blast_opts);
56
 
 
57
 
&set_blast_params();
58
 
 
59
 
&load_ids();
60
 
 
61
 
&load_seqs(\&blast_seq);
62
 
 
63
 
&wrap_up_seq();
64
 
 
65
 
################
66
 
 
67
 
 
68
 
#---------------------
69
 
sub blast_seq_usage {
70
 
#---------------------
71
 
 
72
 
    &seq_usage;
73
 
 
74
 
    print STDERR <<"QQ_NOTE_QQ";
75
 
 
76
 
blast_seq.pl can take potentially many parameters since
77
 
it incorporates functionalities for both manipulating Fasta
78
 
sequence (seqtools.pl) and running/parsing Blast reports
79
 
(blast_config.pl). These parameters will be shown in three sets:
80
 
 
81
 
  (1) parameters for manipulating the sequence file.
82
 
  (2) parameters for running the Blast reports.
83
 
  (3) parameters for parsing the Blast reports.
84
 
 
85
 
To familiarize yourself with all of the options, it would be a
86
 
good idea to try using the seq and blast example scripts individually.
87
 
 
88
 
QQ_NOTE_QQ
89
 
 
90
 
    print STDERR "Hit <RETURN> to view parameters."; <STDIN>;
91
 
 
92
 
    &seq_params;
93
 
 
94
 
    print STDERR "Hit <RETURN> to view Blast run parameters."; <STDIN>;
95
 
 
96
 
    &blast_params;  # print both run and parse params.
97
 
    &blast_general_params;
98
 
 
99
 
}
100
 
 
101
 
 
102
 
#------------
103
 
sub examples {
104
 
#------------
105
 
<<"QQ_EG_QQ";
106
 
(Run this in the examples/blast/ directory of the distribution.)
107
 
 
108
 
  ./$ID seq/seqs.fasta -eid -prog blastp -db yeast -signif 1e-5 -table 2 -wait 300
109
 
 
110
 
(The wait argument is necessary to prevent a possible timeout while reading sequences.)
111
 
 
112
 
QQ_EG_QQ
113
 
}
114
 
 
115
 
#----------------
116
 
sub blast_seq {
117
 
#----------------
118
 
# This method will be called for each sequence in the indicated file.
119
 
# Each sequence is sent off for blast analysis and then the 
120
 
# resulting blast object is processed further.
121
 
 
122
 
    my $seq = shift;
123
 
 
124
 
    print STDERR "\nBLASTing sequence ${\$seq->id}\n";
125
 
 
126
 
    $runParam{-seqs} = [ $seq ];
127
 
    $blastParam{-run} = \%runParam;
128
 
 
129
 
    # Verifying the data structure:
130
 
 #   print STDERR "Sequence to be blasted:\n";
131
 
#    print STDERR $blastParam{-run}->{-seqs}->[0]->layout(); 
132
 
       
133
 
    my ($blast_obj);
134
 
    eval { 
135
 
        $blast_obj = &create_blast;
136
 
    };
137
 
    if($@) {
138
 
      print STDERR "\nTROUBLE Blasting:\n$@\n";
139
 
      return 0;
140
 
    }
141
 
 
142
 
    # We no longer can create Blast objects from NCBI submissions
143
 
    # since we get back queue information, not the actual BLAST
144
 
    # report. Hence, create_blast always fails, so there's
145
 
    # nothing to parse.
146
 
 
147
 
    return 0 unless ref($blast_obj);
148
 
 
149
 
    $opt_compress && $blast_obj->compress_file; 
150
 
    
151
 
    if($opt_parse) {
152
 
        if ($opt_table) {
153
 
            &print_table($blast_obj);
154
 
        } else {
155
 
            $blast_obj->display();
156
 
        }
157
 
    }
158
 
    $blast_obj->destroy;
159
 
    undef $blast_obj;
160
 
}    
161
 
 
162
 
 
163
 
 
164