[Bioperl-l] problem with Bio::SearchIO::Writer

lidaof lidaof at gmail.com
Fri Jan 12 04:18:47 UTC 2007


Hi Dave,

i use this two code for the test file the Bio::SearchIO HOW-TO pages
provided

with the code i provied,the content of out:
[lidaof at lidaofbox blast]$ more out
gi|20521485|dbj|AP004641.2 gb|443893|124775 2e-022

with the code you provided,the conten of out:
[lidaof at lidaofbox blast]$ more out
BLASTX 2.2.4 [Aug-26-2002]

Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer,
Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997),
"Gapped BLAST and PSI-BLAST: a new generation of protein database search
programs", Nucleic Acids Res. 25:3389-3402.

Query= gi|20521485|dbj|AP004641.2 Oryza sativa (japonica
cultivar-group) genomic DNA, chromosome 1, BAC clone:B1147B04,
3785 bases, 977CE9AF checksum.
(3,059 letters)

Database: test.fa
5 sequences; 1,291 total letters

Score E
Sequences producing significant alignments: (bits) value
gb|443893|124775 LaForas sequence 92 2e-022


>gb|443893|124775 LaForas sequence
Length = 331

Score = 92.0 bits (227), Expect = 2e-022
Identities = 46/52 (88%), Positives = 48/52 (92%), Gaps = 2/52 (3%)
Frame = +1

Query: 2896 DMGRCSSGCNRYPEPMTPDTMIKLYREKEGLGAYIWMPTPDMSTEGRVQMLP 3051
D+ + SSGCNRYPEPMTPDTMIKLYRE EGL AYIWMPTPDMSTEGRVQMLP
Sbjct: 197 DIVQNSSGCNRYPEPMTPDTMIKLYRE-EGL-AYIWMPTPDMSTEGRVQMLP 246


Database: test.fa
Posted date: Feb 12, 2003 9:51 AM
Number of letters in database: 5
Number of sequences in database: 1,291

Matrix: BLOSUM62
Gap Penalties Existence: 11, Extension: 1
expect: 10.0
allowgaps: yes
Search Statistics
A: 40
Hits_to_DB: 7,140
S1: 32
S1_bits: 17.6
T: 12
X1: 16
X1_bits: 7.3
X2: 38
X2_bits: 14.6
X3: 64
X3_bits: 24.7
dbentries: 5
dbletters: 1,291
decayconst: 0.1

so the second just like the input file
the first is exactly i wanted,but without use of
Bio::SearchIO::Writer::TextResultWriter
can i got the result like the first one by using
Bio::SearchIO::Writer::TextResultWriter?

Thanks!

Li

On 1/12/07, lidaof <lidaof at gmail.com> wrote:
>
> Hi Dave,
>
> Thank you for the patience on my problem
> and now i have some understanding on that issue
> Thank you!
> my last mail alse have " bcc bioperl-l at lists.open-bio.org"
> and i have joined in this great list:)
>
> Li
>
> On 1/12/07, David Messina <dmessina at wustl.edu> wrote:
> >
> > Hi Li,
> >
> > Please reply also to the list so that the whole thread can be archived.
> >
> >
> > I dug a little deeper into the Bio::SearchIO::Writer::TextResultWriter
> > documentation and found (in the description section) that you can pass a
> > subroutine to do your filtering. So your code can be shortened to:
> >
> >
> > #!/usr/bin/perl -w
> >
> > use strict;
> > use warnings;
> > use Bio::SearchIO;
> > use Bio::SearchIO::Writer::TextResultWriter;
> >
> > my $usage = "
> > signifablast - filter blast reports for significance and write out a new
> > report
> >
> > Usage: signifablast <file of blast report(s)>
> > ";
> > @ARGV == 1 or die $usage;
> >
> > # create a SearchIO object for reading in the file of blast report(s)
> > my $in = Bio::SearchIO->new( -format => 'blast', -file => "$ARGV[0]" );
> >
> > # create a TextResultWriter object
> > my $writer = Bio::SearchIO::Writer::TextResultWriter->new(
> >     -filters => { 'HIT' => \&hit_filter } );
> >
> > # create a SearchIO object to store our filtered hits and write them to
> > 'out'
> > my $out = Bio::SearchIO->new( -writer => $writer, -file => '>out' );
> >
> > # write out our new (text) blast report
> > $out->write_result($in->next_result);
> >
> >
> >
> > # E-value filter
> > sub hit_filter {
> >     my $hit = shift;
> >
> >     # set E value cutoff
> >     my $e = 1e-10;
> >
> >     # &hit_filter must return true to keep the hit and false to discard
> > the hit
> >     return $hit->significance < $e;
> > }
> >
> >
> >
> >
> >
> >
> > Dave
> >
> >
> >
> >
> >
> > On Jan 11, 2007, at 6:50 AM, lidaof wrote:
> >
> > Hi,Dave and Chris,
> >
> > sorry for disturbing again
> > in the code i paste below:
> >
> > #!/usr/bin/perl -w
> >
> > use strict;
> > use warnings;
> > use Bio::SearchIO;
> > #use Bio::SearchIO::Writer::TextResultWriter;
> >
> > my $in = new Bio::SearchIO (-format => 'blast', -file => "$ARGV[0]");
> >
> > $cutoff = 1e-10;
> > open OP,">out";
> > while(my $result = $in->next_result){
> > my $resultname = $result->query_name();
> > while(my $hit = $result->next_hit){
> > my $name = $hit->name();
> > my $e = $hit->significance();
> > if($e < $cutoff){
> > print OP "$resultname\t$name\t$e\n";
> > next;
> > }
> > }
> > }
> >
> > i use a filehandle "OP" for file output
> > i want to use  Bio::SearchIO::Writer::TextResultWriter but actually i
> > didn't use it
> > that is the place you are not sure in your last mail
> > and i will spend some time on reading the website of bioperl and this
> > mailing list
> >
> > Thanks for your kindness:)
> >
> > Li
> >
> >
> >
> >
>
>
>
> --
> Li




-- 
Li



More information about the Bioperl-l mailing list