Bio-SearchIO-hmmer

 view release on metacpan or  search on metacpan

t/SearchIO.t  view on Meta::CPAN

    my ( $hsp, $hit );

    if ( defined( $hit = $result->next_model ) ) {
        is( ref($hit), 'Bio::Search::Hit::HMMERHit',
            'Check for the correct hit reference type' );
        is( $hit->name, 'SEED', 'Check hit name' );
        is( $hit->description,
            '',
            'Check for hit description'
        );
        is( $hit->raw_score,          146.1,   'Check hit raw_score' );
        is( $hit->bits,               0,       'Check hit bits (0)' );
        float_is( $hit->significance, 6.3e-40, 'Check hit significance' );
        is( $hit->num_hsps,           1,       'Check num_hsps' );

        # Query and Hit lengths are usually unknown in HMMER,
        # but sometimes they can be deduced from domain data '[]'
        is( $hit->length,             77,      'Check hit length' );
        is( $hit->frac_aligned_query, undef );
        is( $hit->frac_aligned_hit,  '1.00' );

        is( $hit->matches('cons'), 55, 'Check hit total conserved residues' );
        is( $hit->matches('id'),   22, 'Check hit total identical residues' );
        is( sprintf( "%.3f", $hit->frac_identical('query') ), '0.310' );
        is( sprintf( "%.3f", $hit->frac_identical('hit') ),    0.286 );
        is( sprintf( "%.3f", $hit->frac_identical('total') ),  0.282 );
        is( sprintf( "%.3f", $hit->frac_conserved('query') ),  0.775 );
        is( sprintf( "%.3f", $hit->frac_conserved('hit') ),    0.714 );
        is( sprintf( "%.3f", $hit->frac_conserved('total') ),  0.705 );

        if ( defined( $hsp = $hit->next_domain ) ) {
            is( ref($hsp), 'Bio::Search::HSP::HMMERHSP',
                'Check for correct hsp reference type' );
            is( $hsp->query->seq_id(), 'roa1_drome', 'Check for query seq_id' );
            is( $hsp->hit->seq_id(),   'SEED',       'Check for hit seq_id' );

            is( $hsp->hit->start,   1,       'Check for hit hmmfrom value' );
            is( $hsp->hit->end,     77,      'Check for hit hmm to value' );
            is( $hsp->query->start, 33,      'Check for query alifrom value' );
            is( $hsp->query->end,   103,     'Check for query ali to value' );
            is( $hsp->score,        71.2,    'Check for hsp score' );
            is( $hsp->bits,         0,       'Check for hsp bits (0)' );
            float_is( $hsp->evalue, 2.2e-17, 'Check for hsp c-Evalue' );

            is( $hsp->length('query'), 71, 'Check for hsp query length' );
            is( $hsp->length('hit'),   77, 'Check for hsp hit length' );
            is( $hsp->length('total'), 78, 'Check for hsp total length' );
            is( $hsp->gaps('query'),   7,  'Check for hsp query gaps' );
            is( $hsp->gaps('hit'),     1,  'Check for hsp hit gaps' );
            is( $hsp->gaps('total'),   8,  'Check for hsp total gaps' );

            ($hit->length == 0) ?
                  is( $hsp->{HIT_LENGTH}, $hsp->hit->length, 'Check hit length consistency' )
                : is( $hsp->{HIT_LENGTH}, $hit->length,      'Check hit length consistency' );
            ($result->query_length == 0) ?
                  is( $hsp->{QUERY_LENGTH}, $hsp->query->length,   'Check query length consistency' )
                : is( $hsp->{QUERY_LENGTH}, $result->query_length, 'Check query length consistency' );

            is( $hsp->num_conserved, 55 );
            is( $hsp->num_identical, 22 );
            is( sprintf( "%.2f", $hsp->percent_identity ),         28.21 );
            is( sprintf( "%.3f", $hsp->frac_identical('query') ), '0.310' );
            is( sprintf( "%.3f", $hsp->frac_identical('hit') ),    0.286 );
            is( sprintf( "%.3f", $hsp->frac_identical('total') ),  0.282 );
            is( sprintf( "%.3f", $hsp->frac_conserved('query') ),  0.775 );
            is( sprintf( "%.3f", $hsp->frac_conserved('hit') ),    0.714 );
            is( sprintf( "%.3f", $hsp->frac_conserved('total') ),  0.705 );

            is( $hsp->query_string,
                'LFIGGLDYRTTDENLKAHFEKWGNIVDVVVMKD-----PRTKRSRGFGFITYSHSSMIDEAQK--SRpHKIDGRVVEP',
                'Check for query string'
            );
            is( $hsp->hit_string,
                'lfVgNLppdvteedLkdlFskfGpivsikivrDiiekpketgkskGfaFVeFeseedAekAlealnG-kelggrklrv',
                'Check for hit string'
            );
            is( $hsp->homology_string,
                'lf+g+L + +t+e Lk++F+k G iv++ +++D     + t++s+Gf+F+++  ++  + A +    +++++gr+++ ',
                'Check for homology string'
            );
            is( length( $hsp->homology_string ),
                length( $hsp->hit_string ),
                'Check if homology string and hit string have an equal length'
            );
            is( length( $hsp->query_string ),
                length( $hsp->homology_string ),
                'Check if query string and homology string have an equal length'
            );
            # This Hmmpfam don't have PP or CS strings, these are tests to check for side effects
            is( $hsp->posterior_string, '' );
            is( $hsp->consensus_string, '' );
        }
    }
    if ( defined( $hit = $result->next_model ) ) {
        is( ref($hit), 'Bio::Search::Hit::HMMERHit',
            'Check for the correct hit reference type' );
        is( $hit->name,              'SEED',    'Check hit name' );
        is( $hit->description,       '',        'Check for hit description' );
        is( $hit->raw_score,          146.1,    'Check hit raw_score' );
        is( $hit->bits,               0,        'Check hit bits (0)' );
        float_is( $hit->significance, 6.3e-040, 'Check hit significance' );
        is( $hit->num_hsps,           1,        'Check num_hsps' );

        # Query and Hit lengths are usually unknown in HMMER,
        # but sometimes they can be deduced from domain data '[]'
        is( $hit->length,             77,      'Check hit length' );
        is( $hit->frac_aligned_query, undef );
        is( $hit->frac_aligned_hit,  '1.00' );

        is( $hit->matches('cons'), 56, 'Check hit total conserved residues' );
        is( $hit->matches('id'),   33, 'Check hit total identical residues' );
        is( sprintf( "%.3f", $hit->frac_identical('query') ),  0.471 );
        is( sprintf( "%.3f", $hit->frac_identical('hit') ),    0.429 );
        is( sprintf( "%.3f", $hit->frac_identical('total') ),  0.429 );
        is( sprintf( "%.3f", $hit->frac_conserved('query') ), '0.800' );
        is( sprintf( "%.3f", $hit->frac_conserved('hit') ),    0.727 );
        is( sprintf( "%.3f", $hit->frac_conserved('total') ),  0.727 );

        if ( defined( $hsp = $hit->next_domain ) ) {
            is( ref($hsp), 'Bio::Search::HSP::HMMERHSP',
                'Check for correct hsp reference type' );
            is( $hsp->query->seq_id(), 'roa1_drome', 'Check for query seq_id' );
            is( $hsp->hit->seq_id(),   'SEED',       'Check for hit seq_id' );

            is( $hsp->hit->start,   1,       'Check for hit hmmfrom value' );
            is( $hsp->hit->end,     77,      'Check for hit hmm to value' );
            is( $hsp->query->start, 124,     'Check for query alifrom value' );
            is( $hsp->query->end,   193,     'Check for query ali to value' );
            is( $hsp->score,        75.5,    'Check for hsp score' );
            is( $hsp->bits,         0,       'Check for hsp bits (0)' );
            float_is( $hsp->evalue, 1.1e-18, 'Check for hsp c-Evalue' );

            is( $hsp->length('query'), 70, 'Check for hsp query length' );
            is( $hsp->length('hit'),   77, 'Check for hsp hit length' );
            is( $hsp->length('total'), 77, 'Check for hsp total length' );
            is( $hsp->gaps('query'),   7,  'Check for hsp query gaps' );
            is( $hsp->gaps('hit'),     0,  'Check for hsp hit gaps' );
            is( $hsp->gaps('total'),   7,  'Check for hsp total gaps' );

            ($hit->length == 0) ?
                  is( $hsp->{HIT_LENGTH}, $hsp->hit->length, 'Check hit length consistency' )
                : is( $hsp->{HIT_LENGTH}, $hit->length,      'Check hit length consistency' );
            ($result->query_length == 0) ?
                  is( $hsp->{QUERY_LENGTH}, $hsp->query->length,   'Check query length consistency' )
                : is( $hsp->{QUERY_LENGTH}, $result->query_length, 'Check query length consistency' );

            is( $hsp->num_conserved, 56 );
            is( $hsp->num_identical, 33 );
            is( sprintf( "%.2f", $hsp->percent_identity ),         42.86 );
            is( sprintf( "%.3f", $hsp->frac_identical('query') ),  0.471 );
            is( sprintf( "%.3f", $hsp->frac_identical('hit') ),    0.429 );
            is( sprintf( "%.3f", $hsp->frac_identical('total') ),  0.429 );
            is( sprintf( "%.3f", $hsp->frac_conserved('query') ), '0.800' );
            is( sprintf( "%.3f", $hsp->frac_conserved('hit') ),    0.727 );
            is( sprintf( "%.3f", $hsp->frac_conserved('total') ),  0.727);

            is( $hsp->query_string,
                'LFVGALKDDHDEQSIRDYFQHFGNIVDINIVID-----KETGKKRGFAFVEFDDYDPVDKVVL--KQHQLNGKMVDV',
                'Check for query string'
            );
            is( $hsp->hit_string,
                'lfVgNLppdvteedLkdlFskfGpivsikivrDiiekpketgkskGfaFVeFeseedAekAlealnGkelggrklrv',
                'Check for hit string'
            );
            is( $hsp->homology_string,
                'lfVg L  d +e+ ++d+F++fG iv+i+iv+D     ketgk +GfaFVeF++++ ++k +     ++l+g+ + v',
                'Check for homology string'
            );
            is( length( $hsp->homology_string ),
                length( $hsp->hit_string ),
                'Check if homology string and hit string have an equal length'
            );
            is( length( $hsp->query_string ),
                length( $hsp->homology_string ),
                'Check if query string and homology string have an equal length'
            );
        }
        last;
    }
}

$searchio = Bio::SearchIO->new(
    -format => 'hmmer',
    -file   => test_input_file('hmmsearch.out')
);
while ( $result = $searchio->next_result ) {
    is( ref($result),
        'Bio::Search::Result::HMMERResult',
        'Check for the correct result reference type'
    );
    is( $result->algorithm,         'HMMSEARCH',        'Check algorithm' );
    is( $result->algorithm_version, '2.0',              'Check algorithm version' );
    is( $result->hmm_name,          'HMM [SEED]',       'Check hmm_name' );
    is( $result->sequence_file,     'HMM.dbtemp.29591', 'Check sequence_file' );
    is( $result->database_name,     'HMM.dbtemp.29591', 'Check database_name' );

    is( $result->query_name,        'SEED', 'Check query_name' );
    is( $result->query_length,       77,    'Check query_length' );
    is( $result->query_description, '',     'Check query_description' );
    is( $result->num_hits(),         1215,  'Check num_hits' );

    my $hit = $result->next_model;
    is( ref($hit), 'Bio::Search::Hit::HMMERHit',
        'Check for the correct hit reference type' );
    is( $hit->name, 'Q91581', 'Check hit name' );
    is( $hit->description,
        'Q91581 POLYADENYLATION FACTOR 64 KDA SUBUN',
        'Check for hit description'
    );

t/SearchIO.t  view on Meta::CPAN

    is( $result->num_hits(), 1, 'Check num_hits' );

    my $hit = $result->next_hit;
    is( ref($hit), 'Bio::Search::Hit::HMMERHit',
        'Check for the correct hit reference type' );
    is( $hit->name, 'Methylase_M', 'Check hit name' );
    is( $hit->description,
        'Type I restriction modification system, M',
        'Check for hit description'
    );
    is( $hit->raw_score,         -105.2,  'Check hit raw_score' );
    is( $hit->bits,               0,      'Check hit bits (0)' );
    float_is( $hit->significance, 0.0022, 'Check hit significance' );
    is( $hit->num_hsps,           1,      'Check num_hsps' );

    # Query and Hit lengths are usually unknown in HMMER,
    # but sometimes they can be deduced from domain data '[]'
    is( $hit->length,             279,    'Check hit length' );
    is( $hit->frac_aligned_query, undef );
    is( $hit->frac_aligned_hit,  '1.00' );

    is( $hit->matches('cons'), 133, 'Check hit total conserved residues' );
    is( $hit->matches('id'),   48,  'Check hit total identical residues' );
    is( sprintf( "%.3f", $hit->frac_identical('query') ), 0.238 );
    is( sprintf( "%.3f", $hit->frac_identical('hit') ),   0.172 );
    is( sprintf( "%.3f", $hit->frac_identical('total') ), 0.171 );
    is( sprintf( "%.3f", $hit->frac_conserved('query') ), 0.658 );
    is( sprintf( "%.3f", $hit->frac_conserved('hit') ),   0.477 );
    is( sprintf( "%.3f", $hit->frac_conserved('total') ), 0.475 );

    my $hsp = $hit->next_hsp;
    is( ref($hsp), 'Bio::Search::HSP::HMMERHSP',
        'Check for correct hsp reference type' );
    is( $hsp->query->seq_id(), 'gi|1522636|gb|AAC37060.1|', 'Check for query seq_id' );
    is( $hsp->hit->seq_id(),   'Methylase_M',               'Check for hit seq_id' );

    is( $hsp->hit->start,   1,      'Check for hit hmmfrom value' );
    is( $hsp->hit->end,     279,    'Check for hit hmm to value' );
    is( $hsp->query->start, 280,    'Check for query alifrom value' );
    is( $hsp->query->end,   481,    'Check for query ali to value' );
    is( $hsp->score,       -105.2,  'Check for hsp score' );
    is( $hsp->bits,         0,      'Check for hsp bits (0)' );
    float_is( $hsp->evalue, 0.0022, 'Check for hsp evalue' );

    is( $hsp->length('query'), 202, 'Check for hsp query length' );
    is( $hsp->length('hit'),   279, 'Check for hsp hit length' );
    is( $hsp->length('total'), 280, 'Check for hsp total length' );
    is( $hsp->gaps('query'),   78,  'Check for hsp query gaps' );
    is( $hsp->gaps('hit'),     1,   'Check for hsp hit gaps' );
    is( $hsp->gaps('total'),   79,  'Check for hsp total gaps' );

    ($hit->length == 0) ?
          is( $hsp->{HIT_LENGTH}, $hsp->hit->length, 'Check hit length consistency' )
        : is( $hsp->{HIT_LENGTH}, $hit->length,      'Check hit length consistency' );
    ($result->query_length == 0) ?
          is( $hsp->{QUERY_LENGTH}, $hsp->query->length,   'Check query length consistency' )
        : is( $hsp->{QUERY_LENGTH}, $result->query_length, 'Check query length consistency' );

    is( $hsp->num_conserved, 133 );
    is( $hsp->num_identical, 48 );
    is( sprintf( "%.2f", $hsp->percent_identity ),        17.14 );
    is( sprintf( "%.3f", $hsp->frac_identical('query') ), 0.238 );
    is( sprintf( "%.3f", $hsp->frac_identical('hit') ),   0.172 );
    is( sprintf( "%.3f", $hsp->frac_identical('total') ), 0.171 );
    is( sprintf( "%.3f", $hsp->frac_conserved('query') ), 0.658 );
    is( sprintf( "%.3f", $hsp->frac_conserved('hit') ),   0.477 );
    is( sprintf( "%.3f", $hsp->frac_conserved('total') ), 0.475 );

    is (length($hsp->homology_string), length($hsp->query_string));

    is( $hsp->hit_string,
        'lrnELentLWavADkLRGsmDaseYKdyVLGLlFlKYiSdkFlerrieieerktdtesepsldyakledqyeqlededlekedfyqkkGvFilPsqlFwdfikeaeknkldedigtdldkifseledqialgypaSeedfkGlfpdldfnsnkLgskaqarnetLtelidlfselelgtPmHNG-dfeelgikDlfGDaYEYLLgkFAeneGKsGGeFYTPqeVSkLiaeiLtigqpsegd...
        'Check for hiy string'
    );
    is( $hsp->query_string,
        'NTSELDKKKFAVLLMNR--------------LIFIKFLEDK------GIV---------PRDLLRRTYEDY---KKSNVLI-NYYDAY-L----KPLFYEVLNTPEDER--KENIRT-NPYYKDIPYL---N-G-------GLFRSNNV--PNELSFTIKDNEIIGEVINFLERYKFTLSTSEGsEEVELNP-DILGYVYEKLINILAEKGQKGLGAYYTPDEITSYIAKNT-IEPIVVE-...
        'Check for query string'
    );
    is( $hsp->homology_string,
        ' ++EL+++  av+   R              L+F K++ dk      +i+         p +   + +++y   ++   ++ ++y ++      + lF++++   e ++  ++++ + +    ++      + +       Glf ++++  ++ +s+   +ne ++e+i+ +++ +++     G++ +el   D++G +YE L+   Ae   K+ G +YTP e++  ia+ + i+  ++  ...
        'Check for homology string'
    );
    is( join( ' ', $hsp->seq_inds( 'query', 'nomatch', 1 ) ),
        '280 288 289 293-295 300 304 311 313-315 317 324-326 332 335 337 344-346 348 355 358-361 364-366 372 379 383-385 389 396 400 404-408 412 416 417 422 426 429-431 434-436 439 441 446 450 451 455 459 460 463 464 468 471 472 478',
        'Check for nomatch indices in query'
    );
    is( join( ' ', $hsp->seq_inds( 'hit', 'nomatch', 1 ) ),
        '1 9 10 14-16 18-31 35 39 42-47 51-59 61 63-65 67 72-74 77-79 82 86 89-94 96 103-105 107 110 111 116 118 120-123 126-131 133 135-141 145 150 151 154 158-160 164 171 175 179-183 187 191-193 198 202 205-207 210-212 215 217 222 226 227 231 233 2...
        'Check for nomatch indices in hit'
    );
    is( join( ' ', $hsp->seq_inds( 'query', 'gap', 1 ) ),
        '296 306 309 321 328 334 335 350 356 366-368 376 417 456 463 470 479',
        'Check for gap indices in query'
    );
    is( join( ' ', $hsp->seq_inds( 'hit', 'gap', 1 ) ),
        '', 'Check for gap indices in hit' );
}

$searchio = Bio::SearchIO->new(
    -format => 'hmmer',
    -file   => test_input_file('cysprot1b.hmmsearch')
);

while ( $result = $searchio->next_result ) {
    is( ref($result),
        'Bio::Search::Result::HMMERResult',
        'Check for the correct result reference type'
    );
    is( $result->algorithm,         'HMMSEARCH', 'Check algorithm' );
    is( $result->algorithm_version, '2.2g',      'Check algorithm version' );
    is( $result->hmm_name,
        'Peptidase_C1.hmm [Peptidase_C1]',
        'Check hmm_name'
    );
    is( $result->database_name,   'cysprot1b.fa', 'Check database_name' );
    is( $result->sequence_file,   'cysprot1b.fa', 'Check sequence_file' );

    is( $result->query_name,      'Peptidase_C1', 'Check query_name' );
    is( $result->query_length,     337,           'Check query_length' );
    is( $result->query_accession, 'PF00112',      'Check query_accession' );
    is( $result->query_description,

t/SearchIO.t  view on Meta::CPAN

    is( $result->num_hits(), 4, 'Check num_hits' );

    my $hit = $result->next_hit;
    is( ref($hit), 'Bio::Search::Hit::HMMERHit',
        'Check for the correct hit reference type' );
    is( $hit->name, 'CATL_RAT', 'Check hit name' );
    is( $hit->description,
        '',
        'Check for hit description'
    );
    is( $hit->raw_score,          449.4,  'Check hit raw_score' );
    is( $hit->bits,               0,      'Check hit bits (0)' );
    float_is( $hit->significance, 2e-135, 'Check hit significance' );
    is( $hit->num_hsps,           1,      'Check num_hsps' );

    # Query and Hit lengths are usually unknown in HMMER,
    # but sometimes they can be deduced from domain data '[]'
    is( $hit->length,              0,     'Check hit length absence' );
    is( $hit->frac_aligned_query, '1.00' );
    is( $hit->frac_aligned_hit,    undef );

    is( $hit->matches('cons'), 204, 'Check hit total conserved residues' );
    is( $hit->matches('id'),   131, 'Check hit total identical residues' );
    is( sprintf( "%.3f", $hit->frac_identical('query') ), 0.389 );
    is( sprintf( "%.3f", $hit->frac_identical('hit') ),   0.598 );
    is( sprintf( "%.3f", $hit->frac_identical('total') ), 0.389 );
    is( sprintf( "%.3f", $hit->frac_conserved('query') ), 0.605 );
    is( sprintf( "%.3f", $hit->frac_conserved('hit') ),   0.932 );
    is( sprintf( "%.3f", $hit->frac_conserved('total') ), 0.605 );

    my $hsp = $hit->next_hsp;
    is( ref($hsp), 'Bio::Search::HSP::HMMERHSP',
        'Check for correct hsp reference type' );
    is( $hsp->query->seq_id(), 'Peptidase_C1', 'Check for query seq_id' );
    is( $hsp->hit->seq_id(),   'CATL_RAT',     'Check for hit seq_id' );

    is( $hsp->hit->start,       114,           'Check for hit hmmfrom value' );
    is( $hsp->hit->end,         332,           'Check for hit hmm to value' );
    is( $hsp->query->start,     1,             'Check for query alifrom value' );
    is( $hsp->query->end,       337,           'Check for query ali to value' );
    is( $hsp->score,            449.4,         'Check for hsp score' );
    is( $hsp->bits,             0,             'Check for hsp bits (0)' );
    float_is( $hsp->evalue,     2e-135,        'Check for hsp evalue' );

    is( $hsp->length('query'), 337, 'Check for hsp query length' );
    is( $hsp->length('hit'),   219, 'Check for hsp hit length' );
    is( $hsp->length('total'), 337, 'Check for hsp total length' );
    is( $hsp->gaps('query'),   0,   'Check for hsp query gaps' );
    is( $hsp->gaps('hit'),     118, 'Check for hsp hit gaps' );
    is( $hsp->gaps('total'),   118, 'Check for hsp total gaps' );

    ($hit->length == 0) ?
          is( $hsp->{HIT_LENGTH}, $hsp->hit->length, 'Check hit length consistency' )
        : is( $hsp->{HIT_LENGTH}, $hit->length,      'Check hit length consistency' );
    ($result->query_length == 0) ?
          is( $hsp->{QUERY_LENGTH}, $hsp->query->length,   'Check query length consistency' )
        : is( $hsp->{QUERY_LENGTH}, $result->query_length, 'Check query length consistency' );

    is( $hsp->num_conserved, 204 );
    is( $hsp->num_identical, 131 );
    is( sprintf( "%.2f", $hsp->percent_identity ),        38.87 );
    is( sprintf( "%.3f", $hsp->frac_identical('query') ), 0.389 );
    is( sprintf( "%.3f", $hsp->frac_identical('hit') ),   0.598 );
    is( sprintf( "%.3f", $hsp->frac_identical('total') ), 0.389 );
    is( sprintf( "%.3f", $hsp->frac_conserved('query') ), 0.605 );
    is( sprintf( "%.3f", $hsp->frac_conserved('hit') ),   0.932 );
    is( sprintf( "%.3f", $hsp->frac_conserved('total') ), 0.605 );

    is (length($hsp->homology_string), length($hsp->query_string));

    is( $hsp->hit_string,
        'IPKTVDWRE-KG-CVTPVKNQG-QCGSCWAFSASGCLEGQMFLKT------GKLISLSEQNLVDCSH-DQGNQ------GCNG-GLMDFAFQYIKE-----NGGLDSEESY-----PYE----AKD-------------------GSCKYR-AEYAV-----ANDTGFVDIPQQ-----EKALMKAVATVGPISVAMDASHPS---LQFYSSG-------IYYEP---NCSSK---DLDHG...
        'Check for hiy string'
    );
    is( $hsp->homology_string,
        '+P+++DWRe kg  VtpVK+QG qCGSCWAFSa g lEg+ ++kt      gkl+sLSEQ+LvDC++ d gn+      GCnG Glmd Af+Yik+     NgGl++E++Y     PY+    +kd                   g+Cky+  + ++     a+++g++d+p++     E+al+ka+a++GP+sVa+das+ s    q+Y+sG       +Y+++    C+++   +LdH+...
        'Check for homology string'
    );
    is( $hsp->query_string,
        'lPesfDWReWkggaVtpVKdQGiqCGSCWAFSavgalEgryciktgtkawggklvsLSEQqLvDCdgedygnngesCGyGCnGGGlmdnAfeYikkeqIsnNgGlvtEsdYekgCkPYtdfPCgkdggndtyypCpgkaydpndTgtCkynckknskypktyakikgygdvpynvsTydEealqkalaknGPvsVaidasedskgDFqlYksGendvgyGvYkhtsageCggtpfteLdHA...
        'Check for query string'
    );
    # Hmmsearch2 don't have PP or CS strings, these are tests to check for side effects
    is( $hsp->posterior_string, '' );
    is( $hsp->consensus_string, '' );

    $hit = $result->next_hit;
    is( $hit->name,              'CATL_HUMAN', 'Check hit name' );
    is( $hit->description,       '',           'Check for hit description' );
    is( $hit->raw_score,          444.5,       'Check hit raw_score' );
    is( $hit->bits,               0,           'Check hit bits (0)' );
    float_is( $hit->significance, 6.1e-134,    'Check hit significance' );
}

# test for bug 2632 - CS lines are captured without breaking the parser
$searchio = Bio::SearchIO->new(
    -format => 'hmmer',
    -file   => test_input_file('hmmpfam_cs.out')
);
if (defined ($result = $searchio->next_result) ) {
    my $hit = $result->next_hit;
    my $hsp = $hit->next_hsp;

    is ($hsp->seq_str,                  $hsp->query_string);
    is (length($hsp->seq_str),          length($hsp->query_string));
    is (length($hsp->homology_string),  length($hsp->query_string));
    is (length($hsp->consensus_string), length($hsp->query_string));

    is( $hsp->consensus_string,
        'EEEEEEEEETSSHSBHHHHHHHHHHHHHGGGGSSCSTTSSCECEEEEEEECTCCCHHHHHHHCT----S GC-EEEEEEE-SSHHHHHHHHHHHHHHHHHTT-EEEEEEE--B-GGGS-HHHHHC--EEEEEEEE-TT--HHHHHHCEEEEECHSCHHHHTHHH.    BEEEEEESSEEEEEECC-GGGHHHHBHGGGSTTEEBSEEEEEECESSSSSCTGGGSSCEEECCCTTCEEEEE...
        'Check for consensus structure string'
    );
    is( $hsp->seq_str,
        'CGV-GFIADVNNVANHKIVVQALEALTCMEHRGACSADRDSGDGAGITTAIPWNLFQKSLQNQNIKFEQnDSVGVGMLFLPAHKLKES--KLIIETVLKEENLEIIGWRLVPTVQEVLGKQAYLNKPHVEQVFCKSSNLSKDRLEQQLFLVRKKIEKYIGINGKDwaheFYICSLSCYTIVYKGMMRSAVLGQFYQDLYHSEYTSSFAIYHRRFSTNTMPKWPLAQPMR---------FVS...
        'Check for hsp seq_str'
    );
    is( $hsp->query_string,
        'CGV-GFIADVNNVANHKIVVQALEALTCMEHRGACSADRDSGDGAGITTAIPWNLFQKSLQNQNIKFEQnDSVGVGMLFLPAHKLKES--KLIIETVLKEENLEIIGWRLVPTVQEVLGKQAYLNKPHVEQVFCKSSNLSKDRLEQQLFLVRKKIEKYIGINGKDwaheFYICSLSCYTIVYKGMMRSAVLGQFYQDLYHSEYTSSFAIYHRRFSTNTMPKWPLAQPMR---------FVS...
        'Check for query string'
    );
    is( $hsp->hit_string,

t/SearchIO.t  view on Meta::CPAN

            'BA000019.orf1.fasta',
            'Check sequence_file'
        );
        is( $result->query_name,        'BA000019.orf1', 'Check query_name' );
        is( $result->query_length,       198,            'Check query_length' );
        is( $result->query_accession,   '',              'Check query_accession' );
        is( $result->query_description, '',              'Check query_description' );
        # 1 hit above and 6 below inclusion threshold
        is( $result->num_hits(), 7, 'Check num_hits' );

        my ( $hsp, $hit );
        if ( $hit = $result->next_model ) {
            is( ref($hit), 'Bio::Search::Hit::HMMERHit',
                'Check for the correct hit reference type' );
            is( $hit->name, 'Peripla_BP_2', 'Check hit name' );
            is( $hit->description,
                'Periplasmic binding protein',
                'Check for hit description'
            );
            is( $hit->raw_score,          105.2, 'Check hit raw_score' );
            is( $hit->bits,               0,     'Check hit bits (0)' );
            float_is( $hit->significance, 6e-30, 'Check hit significance' );
            is( $hit->num_hsps,           1,     'Check num_hsps' );

            # Hit length is usually unknown for HMMSCAN and HMMSEARCH but not for NHMMER.
            # When is not known, sometimes it can be deduced from domain data '[]'
            is( $hit->length,             0,     'Check hit length absence' );
            is( $hit->frac_aligned_query, 0.87 );
            is( $hit->frac_aligned_hit,   undef );

            if ( defined( $hsp = $hit->next_domain ) ) {
                is( ref($hsp), 'Bio::Search::HSP::HMMERHSP',
                    'Check for correct hsp reference type' );
                is( $hsp->hit->seq_id(),   'Peripla_BP_2',  'Check for hit seq_id' );
                is( $hsp->query->seq_id(), 'BA000019.orf1', 'Check for query seq_id' );

                is( $hsp->hit->start,   59,      'Check for hit hmmfrom value' );
                is( $hsp->hit->end,     236,     'Check for hit hmm to value' );
                is( $hsp->query->start, 2,       'Check for query alifrom value' );
                is( $hsp->query->end,   173,     'Check for query ali to value' );
                is( $hsp->score,       '105.0',  'Check for hsp score' );
                is( $hsp->bits,         0,       'Check for hsp bits (0)' );
                float_is( $hsp->evalue, 1.5e-33, 'Check for hsp c-Evalue' );

                is( $hsp->length('query'), 172, 'Check for hsp query length' );
                is( $hsp->length('hit'),   178, 'Check for hsp hit length' );
                is( $hsp->length('total'), 180, 'Check for hsp total length' );
                is( $hsp->gaps('query'),   8,   'Check for hsp query gaps' );
                is( $hsp->gaps('hit'),     2,   'Check for hsp hit gaps' );
                is( $hsp->gaps('total'),   10,  'Check for hsp total gaps' );

                ($hit->length == 0) ?
                      is( $hsp->{HIT_LENGTH}, $hsp->hit->length, 'Check hit length consistency' )
                    : is( $hsp->{HIT_LENGTH}, $hit->length,      'Check hit length consistency' );
                ($result->query_length == 0) ?
                      is( $hsp->{QUERY_LENGTH}, $hsp->query->length,   'Check query length consistency' )
                    : is( $hsp->{QUERY_LENGTH}, $result->query_length, 'Check query length consistency' );

                is( $hsp->num_conserved, 140 );
                is( $hsp->num_identical, 50 );
                is( sprintf( "%.2f", $hsp->percent_identity ),        27.78 );
                is( sprintf( "%.3f", $hsp->frac_identical('query') ), 0.291 );
                is( sprintf( "%.3f", $hsp->frac_identical('hit') ),   0.281 );
                is( sprintf( "%.3f", $hsp->frac_identical('total') ), 0.278 );
                is( sprintf( "%.3f", $hsp->frac_conserved('query') ), 0.814 );
                is( sprintf( "%.3f", $hsp->frac_conserved('hit') ),   0.787 );
                is( sprintf( "%.3f", $hsp->frac_conserved('total') ), 0.778 );

                is (length($hsp->homology_string), length($hsp->query_string));

                is( $hsp->query_string,
                    'LKPDLIIGREYQ---KNIYNQLSNFAPTVLVDWGSF-TSFQDNFRYIAQVLNEEEQGKLVLQQYQKRIRDLQDRMGERlQKIEVSVIGFSGQSIKSLNR-DAVFNQVLDDAGIKRIsIQKNQQERYLEISIENLNKYDADVLFVINE---SKEQLYPDLKNPLWHHLRAVKKQQVYVVNQ',
                    'Check for query string'
                );
                is( $hsp->hit_string,
                    'lkPDlvivsafgalvseieellelgipvvavessstaeslleqirllgellgeedeaeelvaelesridavkaridsl-kpktvlvfgyadegikvvfgsgswvgdlldaaggeni-iaeakgseseeisaEqilaadpdviivsgrgedtktgveelkenplwaelpAvkngrvyllds',
                    'Check for hit string'
                );
                is( $hsp->homology_string,
                    'lkPDl+i+ +++   ++i+++l++ +p+v v+  s+  s+++ +r ++++l+ee++++ + +++++ri+++++r  +  ++ +v+v+g+++ +ik+++  +  ++++ld+ag++ i i++++++ + eis+E+++++d+dv++v       k+ +   ++nplw +l+Avk+++vy++++',
                    'Check for homology string'
                );
                is( $hsp->posterior_string,
                    '8***********...********************9.*****************************************999999999999997777776.5678999999****99777777*************************...77777777899***************9976',
                    'Check for posterior probability string'
                );
            }
        }
    }
    # Check for errors in HSP caused by the existence of 2 hits with the same ID
    elsif ($counter == 2) {
        is( $result->algorithm,         'HMMSCAN', 'Check algorithm' );
        is( $result->algorithm_version, '3.0',     'Check algorithm version' );
        is( $result->hmm_name,
            '/data/biodata/HMMerDB/Pfam.hmm',
            'Check hmm_name'
        );
        is( $result->sequence_file,
            'BA000019.orf1.fasta',
            'Check sequence_file'
        );
        is( $result->query_name,        'lcl|Test_ID.1|P1', 'Check query_name' );
        is( $result->query_length,       463,               'Check query_length' );
        is( $result->query_description, '281521..282909',   'Check query_description' );
        is( $result->num_hits(),         2,                 'Check num_hits' );

        my ( $hsp, $hit );
        my $hit_counter = 0;
        while ( $hit = $result->next_model ) {
            $hit_counter++;
            if ($hit_counter == 1) {
                is( ref($hit), 'Bio::Search::Hit::HMMERHit',
                    'Check for the correct hit reference type' );
                is( $hit->name,        'IS4.original', 'Check hit name' );
                is( $hit->description, '',             'Check for hit description' );
                is( $hit->num_hsps,     1,             'Check num_hsps' );
                if ( defined( $hsp = $hit->next_domain ) ) {
                    is( ref($hsp), 'Bio::Search::HSP::HMMERHSP',
                        'Check for correct hsp reference type' );
                    is( $hsp->hit->seq_id(),   'IS4.original',     'Check for hit seq_id' );
                    is( $hsp->query->seq_id(), 'lcl|Test_ID.1|P1', 'Check for query seq_id' );

t/SearchIO.t  view on Meta::CPAN

        );
        is( $result->algorithm,         'HMMSEARCH',             'Check algorithm' );
        is( $result->algorithm_version, '3.0',                   'Check algorithm version' );
        is( $result->hmm_name,          'Pfam-A.hmm',            'Check hmm_name' );
        is( $result->sequence_file,     'test_seqs.seq_raw.txt', 'Check sequence_file' );

        is( $result->query_name,      'DUF4229',   'Check query_name' );
        is( $result->query_length,     69,         'Check query_length' );
        is( $result->query_accession, 'PF14012.1', 'Check query_accession' );
        is( $result->query_description,
            'Protein of unknown function (DUF4229)',
            'Check query_description'
        );
        is( $result->num_hits(), 1, 'Check num_hits' );

        my ( $hsp, $hit );
        if ( $hit = $result->next_model ) {
            is( ref($hit), 'Bio::Search::Hit::HMMERHit',
                'Check for the correct hit reference type' );
            is( $hit->name, 'lcl|Protein_ID1.3|M3', 'Check hit name' );
            is( $hit->description,
                'complement(48376..51420)',
                'Check for hit description'
            );
            is( $hit->raw_score,         -17.8, 'Check hit raw_score' );
            is( $hit->bits,               0,    'Check hit bits (0)' );
            float_is( $hit->significance, 3,    'Check hit significance' );
            is( $hit->num_hsps,           5,    'Check num_hsps' );

            # Check first HSP
            if ( defined( $hsp = $hit->next_domain ) ) {
                is( ref($hsp), 'Bio::Search::HSP::HMMERHSP',
                    'Check for correct hsp reference type' );
                is( $hsp->hit->seq_id(),   'lcl|Protein_ID1.3|M3', 'Check for hit seq_id' );
                is( $hsp->query->seq_id(), 'DUF4229',              'Check for query seq_id' );

                is( $hsp->hit->start,   305, 'Check for hit alifrom value' );
                is( $hsp->hit->end,     311, 'Check for hit ali to value' );
                is( $hsp->query->start, 34,  'Check for query hmmfrom value' );
                is( $hsp->query->end,   40,  'Check for query hmm to value' );
                is( $hsp->score,       -4.3, 'Check for hsp score' );
                is( $hsp->bits,         0,   'Check for hsp bits (0)' );
                float_is( $hsp->evalue, 1,   'Check for hsp c-Evalue' );

                is( $hsp->length('query'), 7, 'Check for hsp query length' );
                is( $hsp->length('hit'),   7, 'Check for hsp hit length' );
                is( $hsp->length('total'), 7, 'Check for hsp total length' );
                is( $hsp->gaps('query'),   0, 'Check for hsp query gaps' );
                is( $hsp->gaps('hit'),     0, 'Check for hsp hit gaps' );
                is( $hsp->gaps('total'),   0, 'Check for hsp total gaps' );

                ($hit->length == 0) ?
                      is( $hsp->{HIT_LENGTH}, $hsp->hit->length, 'Check hit length consistency' )
                    : is( $hsp->{HIT_LENGTH}, $hit->length,      'Check hit length consistency' );
                ($result->query_length == 0) ?
                      is( $hsp->{QUERY_LENGTH}, $hsp->query->length,   'Check query length consistency' )
                    : is( $hsp->{QUERY_LENGTH}, $result->query_length, 'Check query length consistency' );

                is( $hsp->num_conserved, 6 );
                is( $hsp->num_identical, 4 );
                is( sprintf( "%.2f", $hsp->percent_identity ),        57.14 );
                is( sprintf( "%.3f", $hsp->frac_identical('query') ), 0.571 );
                is( sprintf( "%.3f", $hsp->frac_identical('hit') ),   0.571 );
                is( sprintf( "%.3f", $hsp->frac_identical('total') ), 0.571 );
                is( sprintf( "%.3f", $hsp->frac_conserved('query') ), 0.857 );
                is( sprintf( "%.3f", $hsp->frac_conserved('hit') ),   0.857 );
                is( sprintf( "%.3f", $hsp->frac_conserved('total') ), 0.857 );

                is (length($hsp->homology_string), length($hsp->query_string));

                is( $hsp->consensus_string,
                    '',
                    'Check for consensus structure string'
                );
                is( $hsp->query_string,
                    'laallAl',
                    'Check for query string'
                );
                is( $hsp->hit_string,
                    'LAILSAI',
                    'Check for hit string'
                );
                is( $hsp->homology_string,
                    'la+l A+',
                    'Check for homology string'
                );
                is( $hsp->posterior_string,
                    '3333332',
                    'Check for posterior probability string'
                );
            }
        }
    }
    elsif ($counter == 3) {
        is( ref($result),
            'Bio::Search::Result::HMMERResult',
            'Check for the correct result reference type'
        );
        is( $result->algorithm,         'HMMSEARCH',             'Check algorithm' );
        is( $result->algorithm_version, '3.0',                   'Check algorithm version' );
        is( $result->hmm_name,          'Pfam-A.hmm',            'Check hmm_name' );
        is( $result->sequence_file,     'test_seqs.seq_raw.txt', 'Check sequence_file' );

        is( $result->query_name,      'ACR_tran',   'Check query_name' );
        is( $result->query_length,     1021,        'Check query_length' );
        is( $result->query_accession, 'PF00873.14', 'Check query_accession' );
        is( $result->query_description,
            'AcrB/AcrD/AcrF family',
            'Check query_description'
        );
        is( $result->num_hits(), 1, 'Check num_hits' );

        my ( $hsp, $hit );
        if ( $hit = $result->next_model ) {
            is( ref($hit), 'Bio::Search::Hit::HMMERHit',
                'Check for the correct hit reference type' );
            is( $hit->name, 'lcl|Protein_ID1.3|M3', 'Check hit name' );
            is( $hit->description,
                'complement(48376..51420)',
                'Check for hit description'
            );
            is( $hit->raw_score,          616.9,    'Check hit raw_score' );
            is( $hit->bits,               0,        'Check hit bits (0)' );
            float_is( $hit->significance, 9.3e-189, 'Check hit significance' );
            is( $hit->num_hsps,           1,        'Check num_hsps' );

            # Hit length is usually unknown for HMMSCAN and HMMSEARCH but not for NHMMER.
            # When is not known, sometimes it can be deduced from domain data '[]'
            is( $hit->length,             0,        'Check hit length absence' );
            is( $hit->frac_aligned_query, 0.93 );
            is( $hit->frac_aligned_hit,   undef );

            if ( defined( $hsp = $hit->next_domain ) ) {
                is( ref($hsp), 'Bio::Search::HSP::HMMERHSP',
                    'Check for correct hsp reference type' );
                is( $hsp->hit->seq_id(),   'lcl|Protein_ID1.3|M3', 'Check for hit seq_id' );
                is( $hsp->query->seq_id(), 'ACR_tran',             'Check for query seq_id' );

                is( $hsp->hit->start,   11,       'Check for hit alifrom value' );
                is( $hsp->hit->end,     1000,     'Check for hit ali to value' );
                is( $hsp->query->start, 71,       'Check for query hmmfrom value' );
                is( $hsp->query->end,   1021,     'Check for query hmm to value' );
                is( $hsp->score,        616.6,    'Check for hsp score' );
                is( $hsp->bits,         0,        'Check for hsp bits (0)' );
                float_is( $hsp->evalue, 3.9e-189, 'Check for hsp c-Evalue' );

                is( $hsp->length('query'), 951,  'Check for hsp query length' );
                is( $hsp->length('hit'),   990,  'Check for hsp hit length' );
                is( $hsp->length('total'), 1003, 'Check for hsp total length' );
                is( $hsp->gaps('query'),   52,   'Check for hsp query gaps' );
                is( $hsp->gaps('hit'),     13,   'Check for hsp hit gaps' );
                is( $hsp->gaps('total'),   65,   'Check for hsp total gaps' );

                ($hit->length == 0) ?
                      is( $hsp->{HIT_LENGTH}, $hsp->hit->length, 'Check hit length consistency' )
                    : is( $hsp->{HIT_LENGTH}, $hit->length,      'Check hit length consistency' );
                ($result->query_length == 0) ?
                      is( $hsp->{QUERY_LENGTH}, $hsp->query->length,   'Check query length consistency' )
                    : is( $hsp->{QUERY_LENGTH}, $result->query_length, 'Check query length consistency' );

                is( $hsp->num_conserved, 690 );
                is( $hsp->num_identical, 262 );
                is( sprintf( "%.2f", $hsp->percent_identity ),        26.12 );
                is( sprintf( "%.3f", $hsp->frac_identical('query') ), 0.275 );
                is( sprintf( "%.3f", $hsp->frac_identical('hit') ),   0.265 );
                is( sprintf( "%.3f", $hsp->frac_identical('total') ), 0.261 );
                is( sprintf( "%.3f", $hsp->frac_conserved('query') ), 0.726 );
                is( sprintf( "%.3f", $hsp->frac_conserved('hit') ),   0.697 );
                is( sprintf( "%.3f", $hsp->frac_conserved('total') ), 0.688 );

                is (length($hsp->homology_string), length($hsp->query_string));

                is( $hsp->consensus_string,
                    'S-TTEEEEEEEETTSEEEEEEEESTTS-HHHHHHHHHHHHHHHGGGS-HHHHHH-EEEEEEECCECEEEEEEESSSTS-HHHHHHHHHHCTHHHHHTSTTEEEEEESS.--EEEEEEE-HHHHHCTT--HHHHHHHHHHHSSB-EEEECTT-SB-EEEE-SB---SCCHHCT-EEEETTSEEEEHHHCEEEEEEESSSS-EEEETTCEEEEEEEEEETTSBHHHHHHHH...
                    'Check for consensus structure string'
                );
                is( $hsp->query_string,
                    'gldglkyvsSqSseglssitvtFedgtdidiArqqvqnrlqeaknkLPeevqepgiskiktssseilvlavtskdgsltktdlrdlaesnikdqlsrveGVgdvqliGgsekavriwldpqklaklgltltdvvsalkeqnvqvaaGqlegqqeelliraqgrlqsaediekiivksqdgskvrlrDvAkvelgaeeeriaatlngkpavllavkklpganaievvkav...
                    'Check for query string'
                );
                is( $hsp->hit_string,
                    'TVNDIEHIESQSLFGYGIVKIFFQPDVDIRTANAQVTAISQTVLKQMPPGITPPLILNYNAATVPILQLALSSK--VLSEDRIFDLGQNFIRPQLATVRGSAVPSPYGGKVRQIQIDLDPQAMQSKRVSPDDVARALSQQNLVLSPGTEKIGSFEYNVKINDSPDEFTLLNNLPIKNVGGVTIFIHDVAHVRDGFPPQINVVRDDGRRSVLMTILKNGATSTLDIIQGT...
                    'Check for hit string'
                );
                is( $hsp->homology_string,
                    ' ++ +++++SqS  g   + + F+ + di  A+ qv++  q + +++P ++++p i   +++  +il+la++sk   l++  + dl ++ i++ql+ v G +    +Gg+ ++++i ldpq++++ +++++dv++al++qn   + G+ +  + e+++++++   +   ++++ +k+  g  + ++DvA+v +g   + ++++ +g   vl+++ k     ++++++  ...
                    'Check for homology string'
                );
                is( $hsp->posterior_string,
                    '578899********************************************************************..*********************************************************************************************************************************************************...
                    'Check for posterior probability string'
                );
            }
        }
    }
}

$searchio = Bio::SearchIO->new(
    -format  => 'hmmer',
    -file    => test_input_file('hmmscan_multi_domain.out'),
    -verbose => 1
);

my @multi_hits = (
    [   'PPC',
        'Bacterial pre-peptidase C-terminal domain',
        '111.0', 3.1e-32, 6,
        [   [ 4,  59, 117,  183,  0.5,  0.16 ],
            [ 12, 58, 347,  388,  -0.6, 0.36 ],
            [ 1,  69, 470,  549,  71.3, 1.3e-23 ],
            [ 15, 25, 582,  603,  -3.2, 2 ],
            [ 13, 36, 987,  1019, -1.1, 0.5 ],
            [ 1,  69, 1087, 1168, 54.4, 2.4e-18 ]
        ]
    ],
    [   'HemolysinCabind',
        'Hemolysin-type calcium-binding repeat (2 copies)',
        '47.9', 4.7e-13, 3,
        [   [ 2, 13, 1214, 1225, 5.9,  0.0026 ],
            [ 1, 18, 1231, 1248, 10.8, 6.8e-5 ],
            [ 4, 18, 1243, 1257, 11.4, 4.3e-05 ]
        ]
    ]

t/SearchIO.t  view on Meta::CPAN

        'Check hmm_name'
    );
    is( $result->sequence_file,
        'tmp.fa',
        'Check sequence_file'
    );
    is( $result->query_name,        'A_HA_H7_CDS_nucleotide', 'Check query_name' );
    is( $result->query_length,       1683,                    'Check query_length' );
    is( $result->query_accession,   '',                       'Check query_accession' );
    is( $result->query_description, '',                       'Check query_description' );
    is( $result->num_hits(),         2,                       'Check num_hits' );

    my $hit = $result->next_hit;
    is( ref($hit), 'Bio::Search::Hit::HMMERHit',
        'Check for the correct hit reference type' );
    is( $hit->name,              'seq1',                'Check nhmmer hit name' );
    is( $hit->description,       'Description of seq1', 'Check nhmmer hit description' );
    is( $hit->score,              148.2,                'Check nhmmer hit score' );
    is( $hit->bits,               0,                    'Check nhmmer hit bits (0)' );
    float_is( $hit->significance, 3.2e-48,              'Check nhmmer hit significance' );
    is( $hit->num_hsps,           1,                    'Check num_hsps' );

    # Hit length is usually unknown for HMMSCAN and HMMSEARCH but not for NHMMER.
    # When is not known, sometimes it can be deduced from domain data '[]'
    is( $hit->length,             151,                  'Check nhmmer hit length' );
    is( $hit->frac_aligned_query, 0.09 );
    is( $hit->frac_aligned_hit,  '1.00' );

    my $hsp = $hit->next_hsp;
    is( ref($hsp), 'Bio::Search::HSP::HMMERHSP',
        'Check for correct hsp reference type' );
    is( $hsp->hit->seq_id(),   'seq1',                   'Check for nhmmer hit seq_id' );
    is( $hsp->query->seq_id(), 'A_HA_H7_CDS_nucleotide', 'Check for nhmmer query seq_id' );

    is( $hsp->start('hit'),       1,       'Check nhmmer hsp hit start' );
    is( $hsp->end('hit'),         151,     'Check nhmmer hsp hit end' );
    is( $hsp->start('query'),     258,     'Check nhmmer hsp query start' );
    is( $hsp->end('query'),       411,     'Check nhmmer hsp query end' );
    is( $hsp->strand('hit'),      1,       'Check nhmmer hsp hit strand' );
    is( $hsp->strand('query'),    1,       'Check nhmmer hsp query strand' );
    is( $hsp->score,              148.2,   'Check nhmmer hsp score' );
    is( $hsp->bits,               0,       'Check nhmmer hsp bits (0)' );
    float_is( $hsp->significance, 3.2e-48, 'Check nhmmer hsp evalue' );

    is( $hsp->length('query'), 154, 'Check for hsp query length' );
    is( $hsp->length('hit'),   151, 'Check for hsp hit length' );
    is( $hsp->length('total'), 154, 'Check for hsp total length' );
    is( $hsp->gaps('query'),   0,   'Check for hsp query gaps' );
    is( $hsp->gaps('hit'),     3,   'Check for hsp hit gaps' );
    is( $hsp->gaps('total'),   3,   'Check for hsp total gaps' );

    ($hit->length == 0) ?
          is( $hsp->{HIT_LENGTH}, $hsp->hit->length, 'Check hit length consistency' )
        : is( $hsp->{HIT_LENGTH}, $hit->length,      'Check hit length consistency' );
    ($result->query_length == 0) ?
          is( $hsp->{QUERY_LENGTH}, $hsp->query->length,   'Check query length consistency' )
        : is( $hsp->{QUERY_LENGTH}, $result->query_length, 'Check query length consistency' );

    is( $hsp->num_conserved, 151 );
    is( $hsp->num_identical, 146 );
    is( sprintf( "%.2f", $hsp->percent_identity ),        94.81 );
    is( sprintf( "%.3f", $hsp->frac_identical('query') ), 0.948 );
    is( sprintf( "%.3f", $hsp->frac_identical('hit') ),   0.967 );
    is( sprintf( "%.3f", $hsp->frac_identical('total') ), 0.948 );
    is( sprintf( "%.3f", $hsp->frac_conserved('query') ), 0.981 );
    is( sprintf( "%.3f", $hsp->frac_conserved('hit') ),  '1.000' );
    is( sprintf( "%.3f", $hsp->frac_conserved('total') ), 0.981 );

    is( $hsp->consensus_string,
        '',
        'Check for consensus structure string'
    );
    is( $hsp->query_string,
        'attcctagaattttcagctgatttaattattgagaggcgagaaggaagtaatgatgtctgttatcctgggaaattcgtaaatgaagaagctctgaggcaaattctcagggggtcaggcggaattgacaaggagacaatgggattcacatatagc',
        'Check for nhmmer query string'
    );
    is( $hsp->homology_string,
        'attcctagaattttcagc+gatttaattattgagaggcgagaaggaagt   gatgtctgttatcctgggaaattcgt+aatgaagaagctctgaggcaaattctcaggg+gtcaggcggaattgacaaggagacaatgggattcac+ta+agc',
        'Check for nhmmer homology string'
    );
    is( $hsp->hit_string,
        'ATTCCTAGAATTTTCAGCCGATTTAATTATTGAGAGGCGAGAAGGAAGT---GATGTCTGTTATCCTGGGAAATTCGTGAATGAAGAAGCTCTGAGGCAAATTCTCAGGGAGTCAGGCGGAATTGACAAGGAGACAATGGGATTCACCTACAGC',
        'Check for nhmmer hit string'
    );
    is( $hsp->posterior_string,
       '689*******************************************777...***************************************************************************************************986',
        'Check for nhmmer posterior probability string'
    );
    is( length( $hsp->homology_string ),
        length( $hsp->hit_string ),
        'Check if nhmmer homology string and hit string have an equal length'
    );
    is( length( $hsp->query_string ),
        length( $hsp->homology_string ),
        'Check if nhmmer query string and homology string have an equal length'
    );

    $hit = $result->next_hit;
    is( $hit->name,              'seq2',                'Check nhmmer hit name' );
    is( $hit->description,       'Description of seq2', 'Check nhmmer hit description' );
    is( $hit->score,              38.6,                 'Check nhmmer hit score' );
    is( $hit->bits,               0,                    'Check nhmmer hit bits (0)' );
    float_is( $hit->significance, 3.9e-15,              'Check nhmmer hit significance' );
    is( $hit->length,             60,                   'Check nhmmer hit length' );

    $hsp = $hit->next_hsp;
    is( $hsp->hit->seq_id(),   'seq2',                   'Check for nhmmer hit seq_id' );
    is( $hsp->query->seq_id(), 'A_HA_H7_CDS_nucleotide', 'Check for nhmmer query seq_id' );

    is( $hsp->start('query'),     34,      'Check nhmmer hsp query start' );
    is( $hsp->end('query'),       92,      'Check nhmmer hsp query end' );
    is( $hsp->start('hit'),       1,       'Check nhmmer hsp hit start' );
    is( $hsp->end('hit'),         59,      'Check nhmmer hsp hit end' );
    is( $hsp->strand('hit'),     -1,       'Check nhmmer hsp hit strand' );
    is( $hsp->strand('query'),    1,       'Check nhmmer hsp query strand' );
    is( $hsp->score,              38.6,    'Check nhmmer hsp score' );
    is( $hsp->bits,               0,       'Check nhmmer hsp bits (0)' );
    float_is( $hsp->significance, 3.9e-15, 'Check nhmmer hsp evalue' );

    is( $hsp->length('query'), 59, 'Check for hsp query length' );
    is( $hsp->length('hit'),   59, 'Check for hsp hit length' );



( run in 1.591 second using v1.01-cache-2.11-cpan-39bf76dae61 )