Skip to content

Commit 7aa0918

Browse files
committed
Fix handling of -ve bitscores in hmmsearch out hit
Fixes #24.
1 parent 2e58cbb commit 7aa0918

File tree

2 files changed

+43
-25
lines changed

2 files changed

+43
-25
lines changed

source/resolve_hits/file/detail/hmmsearch_parser.hpp

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ namespace cath {
8686
/// \brief The current alignment being parsed
8787
hmmsearch_aln the_aln;
8888

89+
/// \brief Whether a hit has already been skipped for having a negative bitscore
90+
bool skipped_for_negtv_bitscore = false;
91+
8992
public:
9093
explicit hmmsearch_parser(std::istream &);
9194
hmmsearch_parser(const std::istream &&) = delete;
@@ -275,33 +278,48 @@ namespace cath {
275278
);
276279

277280
const auto &summ = summaries[ summary_ctr ];
278-
const auto id_score_cat = cath_score_category_of_id( id_a, arg_apply_cath_policies );
279-
const bool apply_dc_cat = ( id_score_cat == cath_id_score_category::DC_TYPE );
280-
const residx_t &start = apply_dc_cat ? summ.ali_from : summ.env_from;
281-
const residx_t &stop = apply_dc_cat ? summ.ali_to : summ.env_to;
282-
283-
// If applying the CATH discontinuous policy, erase any segments after the first
284-
if ( apply_dc_cat ) {
285-
segs.erase(
286-
std::next( common::cbegin( segs ) ),
287-
common::cend ( segs )
281+
282+
if ( summ.bitscore <= 0 ) {
283+
if ( ! skipped_for_negtv_bitscore ) {
284+
BOOST_LOG_TRIVIAL( warning ) << "Skipping at least one hit (eg between \""
285+
<< query_id
286+
<< "\" and \""
287+
<< id_a
288+
<< "\" with bitscore "
289+
<< summ.bitscore
290+
<< ") for having a negative bitscore, which cannot currently be handled.";
291+
skipped_for_negtv_bitscore = true;
292+
}
293+
}
294+
else {
295+
const auto id_score_cat = cath_score_category_of_id( id_a, arg_apply_cath_policies );
296+
const bool apply_dc_cat = ( id_score_cat == cath_id_score_category::DC_TYPE );
297+
const residx_t &start = apply_dc_cat ? summ.ali_from : summ.env_from;
298+
const residx_t &stop = apply_dc_cat ? summ.ali_to : summ.env_to;
299+
300+
// If applying the CATH discontinuous policy, erase any segments after the first
301+
if ( apply_dc_cat ) {
302+
segs.erase(
303+
std::next( common::cbegin( segs ) ),
304+
common::cend ( segs )
305+
);
306+
}
307+
308+
// Overwrite the final start/stop with those parsed from the summary
309+
// (env_from/env_to normally; ali_from/ali_to when applying the CATH discontinuous policy)
310+
segs.front().set_start_arrow( arrow_before_res( start ) );
311+
segs.back ().set_stop_arrow ( arrow_after_res ( stop ) );
312+
313+
arg_read_and_process_mgr.add_hit(
314+
query_id,
315+
segs,
316+
std::move( id_a ),
317+
summ.bitscore / bitscore_divisor( arg_apply_cath_policies, id_score_cat, summ.evalues_are_susp ),
318+
hit_score_type::BITSCORE,
319+
std::move( alnd_rngs_opt )
288320
);
289321
}
290322

291-
// Overwrite the final start/stop with those parsed from the summary
292-
// (env_from/env_to normally; ali_from/ali_to when applying the CATH discontinuous policy)
293-
segs.front().set_start_arrow( arrow_before_res( start ) );
294-
segs.back ().set_stop_arrow ( arrow_after_res ( stop ) );
295-
296-
arg_read_and_process_mgr.add_hit(
297-
query_id,
298-
segs,
299-
std::move( id_a ),
300-
summ.bitscore / bitscore_divisor( arg_apply_cath_policies, id_score_cat, summ.evalues_are_susp ),
301-
hit_score_type::BITSCORE,
302-
std::move( alnd_rngs_opt )
303-
);
304-
305323
++summary_ctr;
306324
the_aln.reset();
307325
}

source/resolve_hits/file/hmmer_hmmsearch_domtblout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void cath::rslv::parse_domain_hits_table(read_and_process_mgr &arg_read_and_proc
122122
parse_double_from_field( indp_evalue_field_itrs.first, indp_evalue_field_itrs.second )
123123
);
124124

125-
if ( bitscore < 0 ) {
125+
if ( bitscore <= 0 ) {
126126
if ( ! skipped_for_negtv_bitscore ) {
127127
BOOST_LOG_TRIVIAL( warning ) << "Skipping at least one hit (eg between \""
128128
<< target_id_str_ref

0 commit comments

Comments
 (0)