onlyIDleft has asked for the wisdom of the Perl Monks concerning the following question:

Exalted Monks!

I need your help with script troubleshooting. I am using a BioPerlmodule without really understanding Object Oriented Programming. My input file is at http://bit.ly/1LXIS26. And the script I am using to process it is below if you scroll down. The output it generates is missing information for the ID - 'Brdisv1ABR21023941m', not sure why. WIth other input files, sometimes no IDs are missing, but other times, exactly 1 ID is missing.

Furthermore, warning on STDOUT reads as below - not sure what it means!

--------------------- WARNING ---------------------

MSG: unrecognized line (2): CS -HHHHS-HHHHHHHHTTS-HHHHHHHTTT-HHHHHHHCT- HHH HH

What am I doing wrong with using the Bio::SearchIO BioPerl module, or something else? THANKS!

#!/usr/bin/perl # HMMER_parser.pl use strict; use warnings; # downloaded from https://metacpan.org/pod/Bio::SearchIO::hmmer use Bio::SearchIO; my $source = shift @ARGV; my @out; open(IN, '<', $source) or die "Can't read source file $source : $!\n"; my $in = Bio::SearchIO->new(-format => 'hmmer', -file => $source); while( my $result = $in->next_result ) { # this is a Bio::Search::Result::HMMERResult object print $result->query_name(), " for HMM ", $result->hmm_name(), "\n +"; while( my $hit = $result->next_hit ) { push @out, $hit->name(), "\t"; while( my $hsp = $hit->next_hsp ) { push @out, $hsp->length(), "\n"; } } } close IN; my @split_input_name=split('.out',$source,); my $destination = $split_input_name[0]."FBD_H2_Dom-only.IDsLens"; open(OUT, '>', $destination) or die "Can't read source file $destinati +on : $!\n"; print OUT @out; close OUT;

Replies are listed 'Best First'.
Re: Learning BioPerl/OOP and script troubleshooting help
by kcott (Archbishop) on Dec 07, 2015 at 06:35 UTC

    G'day onlyIDleft,

    A good place to start might be "perlootut - Object-Oriented Programming in Perl Tutorial".

    You might also like to follow the links from "Tutorials: Object Oriented Programming" here at PerlMonks. [Disclaimer: I haven't read any of these so I can't suggest what might be more appropriate for you.]

    I'm not a user of BioPerl. You'll probably get much better answers from others. The BioPerl page on CPAN looks like a reasonable starting point: I note it has links to tutorials (but I can't comment on how good or current they are).

    — Ken

Re: Learning BioPerl/OOP and script troubleshooting help
by Laurent_R (Canon) on Dec 07, 2015 at 07:34 UTC
    Hmm, I certainly do not want to dissuade you from leaning OOP, but, for most practical purposes, you can really use OO modules without having to know much about OOP (except for the user interface). It would be different, of course, if you wanted to expand Bioperl (say subclassing some methods, for example), in which case you would really need to understand more about the ins and outs of OOP.

    Having said that, I certainly would encourage you to learn OOP if you need it. It might even help you understanding and better using Bioperl.

      I see your point distinguishing the ability to use BioPerl Vs. adding to those modules and making new ones. I only intend to be an end-user.

Re: Learning BioPerl/OOP and script troubleshooting help
by toolic (Bishop) on Dec 07, 2015 at 16:17 UTC
    my @split_input_name=split('.out',$source,);
    That will probably give the wrong result if the basename of your file contains the string "out" (for example, if your file name is "stout.out"). You should escape the period because the 1st arg to split is a regular expressions, and . has special meaning. Consider using this instead:
    my @split_input_name = split(/\.out/, $source);
    See also File::Basename

      Thanks for that suggestion, duly noted. Any ideas about the source of my error and how to fix it?