using HMMER

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

using HMMER

fayroz
i need your help, i am a new perl user and want to use bioperl modules to run
HMMER program ( HMMsearch) i have" model.hmm" and a "fasta file" to see which of
them are similar with the model
i write this code but there is a problems

#!/usr/local/bin/perl W
use Bio::AlignIO;
use Bio::SearchIO;
use Bio::SeqIO ;
use Bio::Tools::Run::Hmmer;

# run hmmsearch (similar for hmmpfam)
my $factory = Bio::Tools::Run::Hmmer->new(-hmm => 'h6_avian.hmm',-informat =>
'fasta');
my $seq = Bio::SeqIO->new('-file'=> "one_seq.fa", '-format'=>'Fasta');

# Pass the factory a Bio::Seq object or a file name, returns a Bio::SearchIO
my $searchio = $factory->hmmsearch($seq);

while (my $result = $searchio->next_result){
while(my $hit = $result->next_hit){
while (my $hsp = $hit->next_hsp){
print join("\t", ( $result->query_name,
$hsp->query->start,
$hsp->query->end,
$hit->name,
$hsp->hit->start,
$hsp->hit->end,
$hsp->score,
$hsp->evalue,
$hsp->seq_str,
)), "\n";
}
}
}


exceptions:
MSG: Unknown kind of input 'Bio::SeqIO::fasta=HASH(0x329a504)'
STACK Bio::Tools::Run::Hmmer::_setinput
D:/Perl/site/lib/Bio/Tools/Run/Hmmer.pm:381
STACK Bio::Tools::Run::Hmmer::hmmsearch
D:/Perl/site/lib/Bio/Tools/Run/Hmmer.pm:352
 STACK toplevel test_bioperl.pl:12
thank you

fayroz 


     

_______________________________________________
Bioperl-l mailing list
[hidden email]
http://lists.open-bio.org/mailman/listinfo/bioperl-l
Reply | Threaded
Open this post in threaded view
|

Re: using HMMER

Roy Chaudhuri-3
Hi Fayroz,

Your $seq variable contains a Bio::SeqIO object (a biological
filehandle), not a Bio::Seq (sequence object).

You need to change that line to:
my $seqio = Bio::SeqIO->new(-file=>'one_seq.fa', -format=>'fasta');
my $seq=$seqio->next_seq;

If you have multiple sequences in the file, then you will need to loop
over them:
while (my $seq=$seqio->next_seq) {
# Code to run Hmmer goes here
}

Also, I don't think you need to specify -informat for your
Bio::Tools::Run::Hmmer object, since you're passing it a sequence
object, not a filename.

Hope this helps.
Roy.

On 08/08/2010 09:24, fayroz wrote:

> i need your help, i am a new perl user and want to use bioperl modules to run
> HMMER program ( HMMsearch) i have" model.hmm" and a "fasta file" to see which of
> them are similar with the model
> i write this code but there is a problems
>
> #!/usr/local/bin/perl W
> use Bio::AlignIO;
> use Bio::SearchIO;
> use Bio::SeqIO ;
> use Bio::Tools::Run::Hmmer;
>
> # run hmmsearch (similar for hmmpfam)
> my $factory = Bio::Tools::Run::Hmmer->new(-hmm =>  'h6_avian.hmm',-informat =>
> 'fasta');
> my $seq = Bio::SeqIO->new('-file'=>  "one_seq.fa", '-format'=>'Fasta');
>
> # Pass the factory a Bio::Seq object or a file name, returns a Bio::SearchIO
> my $searchio = $factory->hmmsearch($seq);
>
> while (my $result = $searchio->next_result){
> while(my $hit = $result->next_hit){
> while (my $hsp = $hit->next_hsp){
> print join("\t", ( $result->query_name,
> $hsp->query->start,
> $hsp->query->end,
> $hit->name,
> $hsp->hit->start,
> $hsp->hit->end,
> $hsp->score,
> $hsp->evalue,
> $hsp->seq_str,
> )), "\n";
> }
> }
> }
>
>
> exceptions:
> MSG: Unknown kind of input 'Bio::SeqIO::fasta=HASH(0x329a504)'
> STACK Bio::Tools::Run::Hmmer::_setinput
> D:/Perl/site/lib/Bio/Tools/Run/Hmmer.pm:381
> STACK Bio::Tools::Run::Hmmer::hmmsearch
> D:/Perl/site/lib/Bio/Tools/Run/Hmmer.pm:352
>   STACK toplevel test_bioperl.pl:12
> thank you
>
> fayroz
>
>
>
>
> _______________________________________________
> Bioperl-l mailing list
> [hidden email]
> http://lists.open-bio.org/mailman/listinfo/bioperl-l

_______________________________________________
Bioperl-l mailing list
[hidden email]
http://lists.open-bio.org/mailman/listinfo/bioperl-l
Reply | Threaded
Open this post in threaded view
|

Re: using HMMER

Fields, Christopher J
might also want to check whether you are using hmmer2 vs hmmer3.  not sure if the wrapper works for hmmer3.

chris

On Aug 11, 2010, at 9:32 AM, Roy Chaudhuri wrote:

> Hi Fayroz,
>
> Your $seq variable contains a Bio::SeqIO object (a biological filehandle), not a Bio::Seq (sequence object).
>
> You need to change that line to:
> my $seqio = Bio::SeqIO->new(-file=>'one_seq.fa', -format=>'fasta');
> my $seq=$seqio->next_seq;
>
> If you have multiple sequences in the file, then you will need to loop over them:
> while (my $seq=$seqio->next_seq) {
> # Code to run Hmmer goes here
> }
>
> Also, I don't think you need to specify -informat for your Bio::Tools::Run::Hmmer object, since you're passing it a sequence object, not a filename.
>
> Hope this helps.
> Roy.
>
> On 08/08/2010 09:24, fayroz wrote:
>> i need your help, i am a new perl user and want to use bioperl modules to run
>> HMMER program ( HMMsearch) i have" model.hmm" and a "fasta file" to see which of
>> them are similar with the model
>> i write this code but there is a problems
>>
>> #!/usr/local/bin/perl W
>> use Bio::AlignIO;
>> use Bio::SearchIO;
>> use Bio::SeqIO ;
>> use Bio::Tools::Run::Hmmer;
>>
>> # run hmmsearch (similar for hmmpfam)
>> my $factory = Bio::Tools::Run::Hmmer->new(-hmm =>  'h6_avian.hmm',-informat =>
>> 'fasta');
>> my $seq = Bio::SeqIO->new('-file'=>  "one_seq.fa", '-format'=>'Fasta');
>>
>> # Pass the factory a Bio::Seq object or a file name, returns a Bio::SearchIO
>> my $searchio = $factory->hmmsearch($seq);
>>
>> while (my $result = $searchio->next_result){
>> while(my $hit = $result->next_hit){
>> while (my $hsp = $hit->next_hsp){
>> print join("\t", ( $result->query_name,
>> $hsp->query->start,
>> $hsp->query->end,
>> $hit->name,
>> $hsp->hit->start,
>> $hsp->hit->end,
>> $hsp->score,
>> $hsp->evalue,
>> $hsp->seq_str,
>> )), "\n";
>> }
>> }
>> }
>>
>>
>> exceptions:
>> MSG: Unknown kind of input 'Bio::SeqIO::fasta=HASH(0x329a504)'
>> STACK Bio::Tools::Run::Hmmer::_setinput
>> D:/Perl/site/lib/Bio/Tools/Run/Hmmer.pm:381
>> STACK Bio::Tools::Run::Hmmer::hmmsearch
>> D:/Perl/site/lib/Bio/Tools/Run/Hmmer.pm:352
>>  STACK toplevel test_bioperl.pl:12
>> thank you
>>
>> fayroz
>>
>>
>>
>>
>> _______________________________________________
>> Bioperl-l mailing list
>> [hidden email]
>> http://lists.open-bio.org/mailman/listinfo/bioperl-l
>
> _______________________________________________
> Bioperl-l mailing list
> [hidden email]
> http://lists.open-bio.org/mailman/listinfo/bioperl-l


_______________________________________________
Bioperl-l mailing list
[hidden email]
http://lists.open-bio.org/mailman/listinfo/bioperl-l
Reply | Threaded
Open this post in threaded view
|

Re: using HMMER

Kai Blin
On Wed, 11 Aug 2010 10:07:36 -0500
Chris Fields <[hidden email]> wrote:

> might also want to check whether you are using hmmer2 vs hmmer3.  not sure if the wrapper works for hmmer3.

It might if you initialize it using
my $factory = Bio::Tools::Run::Hmmer->new(-hmm => 'model.hmm', -_READMETHOD => 'hmmer3');

at least for the programs that still exist with the same name in
hmmer3. It won't support hmmer3 using the default options, though.

If I have some spare time, I'll look into this, no promises on the
timeframe, though.

Cheers,
Kai

--
Dipl.-Inform. Kai Blin         [hidden email]
Institute for Microbiology and Infection Medicine
Division of Microbiology/Biotechnology
Eberhard-Karls-University of Tübingen
Auf der Morgenstelle 28                 Phone : ++49 7071 29-78841
D-72076 Tübingen                        Fax :   ++49 7071 29-5979
Deutschland
Homepage: http://www.mikrobio.uni-tuebingen.de/ag_wohlleben

_______________________________________________
Bioperl-l mailing list
[hidden email]
http://lists.open-bio.org/mailman/listinfo/bioperl-l
Reply | Threaded
Open this post in threaded view
|

Re: using HMMER

Fields, Christopher J
On Aug 12, 2010, at 7:09 AM, Kai Blin wrote:

> On Wed, 11 Aug 2010 10:07:36 -0500
> Chris Fields <[hidden email]> wrote:
>
>> might also want to check whether you are using hmmer2 vs hmmer3.  not sure if the wrapper works for hmmer3.
>
> It might if you initialize it using
> my $factory = Bio::Tools::Run::Hmmer->new(-hmm => 'model.hmm', -_READMETHOD => 'hmmer3');
>
> at least for the programs that still exist with the same name in
> hmmer3. It won't support hmmer3 using the default options, though.
>
> If I have some spare time, I'll look into this, no promises on the
> timeframe, though.
>
> Cheers,
> Kai
>
> --
> Dipl.-Inform. Kai Blin         [hidden email]
> Institute for Microbiology and Infection Medicine
> Division of Microbiology/Biotechnology
> Eberhard-Karls-University of Tübingen
> Auf der Morgenstelle 28                 Phone : ++49 7071 29-78841
> D-72076 Tübingen                        Fax :   ++49 7071 29-5979
> Deutschland
> Homepage: http://www.mikrobio.uni-tuebingen.de/ag_wohlleben

Would be nice to convert this over (at some point) to use Mark's CommandExts.  I'm thinking of doing this with Infernal, so if I get that running it wouldn't be terribly difficult to get hmmer3 working as well.

chris
_______________________________________________
Bioperl-l mailing list
[hidden email]
http://lists.open-bio.org/mailman/listinfo/bioperl-l
Reply | Threaded
Open this post in threaded view
|

Re: using HMMER

Fields, Christopher J
Fayroz,

Please keep responses on-list.

It seems you need to update your local bioperl, as 'hmmer3' is a recent addition, after 1.6.1.  It will be in 1.6.2 if I can get the time to make a release :>

chris

On Aug 12, 2010, at 10:58 AM, fayroz wrote:

> dear chris,
> from HMMER documentation i found this statement
> "The HMMER programs must either be in your path, or you must set the environment
> variable HMMERDIR to point to their location."
> is it will solve the problem?
> how can i do it please ? i work under windows7 platform
>
>
> when i appled this line with hmmer3
> my $factory = Bio::Tools::Run::Hmmer->new(-hmm => 'model.hmm', -_READMETHOD =>
> 'hmmer3');
>
> this output apper:
>
> Bio::SearchIO: hmmer3 cannot be found
>
> and when try with hmmer2 the same output apper:
>
> Exception
> ------------- EXCEPTION -------------
> MSG: Failed to load module Bio::SearchIO::hmmer3. Can't locate
> Bio\SearchIO\hmmer3.pm in @INC (@INC contains: D:\Perl\bin\ D:/Perl/site/lib
> D:/Perl/lib .) at D:/Perl/site/lib/Bio/Root/Root.pm line 439, <GEN0> line 1.
> STACK Bio::Root::Root::_load_module D:/Perl/site/lib/Bio/Root/Root.pm:441
> STACK (eval) D:/Perl/site/lib/Bio/SearchIO.pm:446
> STACK Bio::SearchIO::_load_format_module D:/Perl/site/lib/Bio/SearchIO.pm:445
> STACK Bio::SearchIO::new D:/Perl/site/lib/Bio/SearchIO.pm:189
> STACK Bio::Tools::Run::Hmmer::_run D:/Perl/site/lib/Bio/Tools/Run/Hmmer.pm:431
> STACK Bio::Tools::Run::Hmmer::hmmsearch
> D:/Perl/site/lib/Bio/Tools/Run/Hmmer.pm:353
> STACK toplevel C:\Users\Khaled\AppData\Local\Temp\dzprltmp.pl:13
> -------------------------------------
> For more information about the SearchIO system please see the SearchIO docs.
> This includes ways of checking for formats at compile time, not run time
> '--informat' is not recognized as an internal or external command,
> operable program or batch file.
> Can't call method "next_result" on an undefined value at
> C:\Users\Khaled\AppData\Local\Temp\dzprltmp.pl line 15, <GEN0> line 1.
>
>
>
> ----- Original Message ----
> From: Chris Fields <[hidden email]>
> To: Kai Blin <[hidden email]>
> Cc: fayroz <[hidden email]>; [hidden email]
> Sent: Thu, August 12, 2010 6:28:50 PM
> Subject: Re: [Bioperl-l] using HMMER
>
> On Aug 12, 2010, at 7:09 AM, Kai Blin wrote:
>
>> On Wed, 11 Aug 2010 10:07:36 -0500
>> Chris Fields <[hidden email]> wrote:
>>
>>> might also want to check whether you are using hmmer2 vs hmmer3.  not sure if
>>> the wrapper works for hmmer3.
>>
>> It might if you initialize it using
>> my $factory = Bio::Tools::Run::Hmmer->new(-hmm => 'model.hmm', -_READMETHOD =>
>> 'hmmer3');
>>
>> at least for the programs that still exist with the same name in
>> hmmer3. It won't support hmmer3 using the default options, though.
>>
>> If I have some spare time, I'll look into this, no promises on the
>> timeframe, though.
>>
>> Cheers,
>> Kai
>>
>> --
>> Dipl.-Inform. Kai Blin        [hidden email]
>> Institute for Microbiology and Infection Medicine
>> Division of Microbiology/Biotechnology
>> Eberhard-Karls-University of Tübingen
>> Auf der Morgenstelle 28                Phone : ++49 7071 29-78841
>> D-72076 Tübingen                        Fax :  ++49 7071 29-5979
>> Deutschland
>> Homepage: http://www.mikrobio.uni-tuebingen.de/ag_wohlleben
>
> Would be nice to convert this over (at some point) to use Mark's CommandExts.  
> I'm thinking of doing this with Infernal, so if I get that running it wouldn't
> be terribly difficult to get hmmer3 working as well.
>
> chris
>
>
>


_______________________________________________
Bioperl-l mailing list
[hidden email]
http://lists.open-bio.org/mailman/listinfo/bioperl-l