0
|
1 #Remote-blast "factory object" creation and blast-parameter initialization
|
|
2
|
|
3 use Bio::Tools::Run::RemoteBlast;
|
|
4 use strict;
|
|
5 my $prog = 'blastp';
|
|
6 my $db = 'swissprot';
|
|
7 my $e_val= '1e-10';
|
|
8 my ($input,$output)=@ARGV;
|
|
9 my @params = ( '-prog' => $prog,
|
|
10 '-data' => $db,
|
|
11 '-expect' => $e_val,
|
|
12 '-readmethod' => 'SearchIO' );
|
|
13
|
|
14 my $factory = Bio::Tools::Run::RemoteBlast->new(@params);
|
|
15
|
|
16 #change a paramter
|
|
17 # $Bio::Tools::Run::RemoteBlast::HEADER{'ENTREZ_QUERY'} = 'Homo sapiens [ORGN]';
|
|
18
|
|
19 #remove a parameter
|
|
20 # delete $Bio::Tools::Run::RemoteBlast::HEADER{'FILTER'};
|
|
21
|
|
22 my $v = 1;
|
|
23 #$v is just to turn on and off the messages
|
|
24
|
|
25 my $str = Bio::SeqIO->new(-file=>$input , '-format' => 'fasta' );
|
|
26
|
|
27 while (my $input = $str->next_seq()){
|
|
28 #Blast a sequence against a database:
|
|
29
|
|
30 #Alternatively, you could pass in a file with many
|
|
31 #sequences rather than loop through sequence one at a time
|
|
32 #Remove the loop starting 'while (my $input = $str->next_seq())'
|
|
33 #and swap the two lines below for an example of that.
|
|
34 my $r = $factory->submit_blast($input);
|
|
35 #my $r = $factory->submit_blast('amino.fa');
|
|
36
|
|
37 print STDERR "waiting..." if( $v > 0 );
|
|
38 while ( my @rids = $factory->each_rid ) {
|
|
39 foreach my $rid ( @rids ) {
|
|
40 my $rc = $factory->retrieve_blast($rid);
|
|
41 if( !ref($rc) ) {
|
|
42 if( $rc < 0 ) {
|
|
43 $factory->remove_rid($rid);
|
|
44 }
|
|
45 print STDERR "." if ( $v > 0 );
|
|
46 sleep 5;
|
|
47 } else {
|
|
48 my $result = $rc->next_result();
|
|
49 #save the output
|
|
50 # my $filename = $result->query_name()."\.out";
|
|
51 my $filename="";
|
|
52 $factory->save_output($output);
|
|
53 $factory->remove_rid($rid);
|
|
54 #print "\nQuery Name: ", $result->query_name(), "\n";
|
|
55 #while ( my $hit = $result->next_hit ) {
|
|
56 # next unless ( $v > 0);
|
|
57 # print "\nhit name is ", $hit->name, "\n";
|
|
58 # while( my $hsp = $hit->next_hsp ) {
|
|
59 # print "HSP Len is ", $hsp->length('total'), " ",
|
|
60 # " E-value is ", $hsp->evalue, " Bit score ",
|
|
61 # $hsp->score, " \t",
|
|
62 # " Query loc: ",$hsp->query->start, " ",
|
|
63 # $hsp->query->end," ",
|
|
64 # " Sbject loc: ",$hsp->hit->start, " ",
|
|
65 # $hsp->hit->end,"\n";
|
|
66 # }
|
|
67 #}
|
|
68 }
|
|
69 }
|
|
70 }
|
|
71 }
|
|
72
|
|
73 # This example shows how to change a CGI parameter:
|
|
74 # $Bio::Tools::Run::RemoteBlast::HEADER{'MATRIX_NAME'} = 'BLOSUM25';
|
|
75
|
|
76 # And this is how to delete a CGI parameter:
|
|
77 # delete $Bio::Tools::Run::RemoteBlast::HEADER{'FILTER'};
|