[Bioperl-l] RE:Segmentation fault
Jason Stajich
jason at cgt.duhs.duke.edu
Mon Apr 12 13:15:53 EDT 2004
I really have no idea what you are doing....
If you want to initialize a SearchIO parser to read in HMMER output
results you do
my $in = Bio::SearchIO(-file => 'hmmerresultfile.out',
-format => 'hmmer');
# an loop through each result (a single result per query sequence)
while( my $result = $in->next_result ) {
# print the query name
# for hmmpfam this will be each sequence in the input set
# for hmmsearch this will be the name of the HMM file you
# used to search
print $result->query_name, "\n";
# now print all the hits (for HMMPFAM this will be the Pfam domains
# for hmmsearch this will be the sequences in the db that had good
# alignments
while ( my $hit = $result->next_hit ) {
# print the name, indented with a tab
print "\t", $hit->name, "\n";
}
}
This is all covered in the HOWTO. Did you try the example code in there?
-jason
On Mon, 12 Apr 2004, stephan rosecker wrote:
> > If $result->query_name() is indeed the right call to make in
> > the inner loop (according to the Bio::SearchIO documentation,
> > $result is an object with the Bio::Search::Hit::HitI interface,
> > which from what I can see contains no query_name() method), then
> > I would suggest that you try your program with a newer version
> > of Perl. I believe the latest version is 5.8.3.
>
> Hi,
> like i wrote a'm not a perl guru so please correct me.
> $result is a "pointer" to my current seq object.
> ($result = $in->next_result)
> $hit is a "pointer" to my current hit object.
> (my $hit = $result->next_hit)
> So "$result->query_name" has to be visible inside my while-loop.
> (I want only the seq object that contains hit's)
>
> old code:
> ----------------------------------------------
> while( my $result = $in->next_result )
> {
> while( my $hit = $result->next_hit )
> {
> print $result->query_name."\n";
> wait;
> last;
> }
> }
> ----------------------------------------------
>
> After i read your mail i rewrote the code and
> it shoud be more conform... but also sementation fault:-( .
>
> new code:
> ----------------------------------------------
>
> use Bio::Search::Result::HMMERResult;
> my $result = new Bio::Search::Result::HMMERResult
> ( -hmm_name => 'pfam',
> -sequence_file => 'uniprot_sprot.dat',
> -hits => \@hits);
> # I'm not realy understand the args here -
> # pfam for hmmpfam ?
> # -sequence_file = source hmmpfam file ?
>
> use Bio::SearchIO;
> my $in = new Bio::SearchIO(-format => 'hmmer',
> -file => 'uniprot_sprot_hmmer.out');
> while( my $result = $in->next_result ) {
> $result->num_hits(), " hits\n";
> if ($result->num_hits()>0)
> {print $result->query_name."\n";}
> }
>
> greets,
> stephan
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioperl-l
>
--
Jason Stajich
Duke University
jason at cgt.mc.duke.edu
More information about the Bioperl-l
mailing list