#!/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 $destination : $!\n"; print OUT @out; close OUT;