Skip to content

Commit b73ac2d

Browse files
authored
Merge pull request #212 from h-2/bits2
Bits2
2 parents fc636ea + 391e939 commit b73ac2d

File tree

3 files changed

+58
-21
lines changed

3 files changed

+58
-21
lines changed

src/search_algo.hpp

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1736,7 +1736,7 @@ computeBlastMatch(typename TBlastRecord::TBlastMatch & bm,
17361736
computeBitScore(bm, context(lH.gH.outfile));
17371737

17381738
computeEValueThreadSafe(bm, record.qLength, context(lH.gH.outfile));
1739-
if (bm.eValue > lH.options.eCutOff)
1739+
if (bm.eValue > lH.options.maxEValue)
17401740
return EVALUE;
17411741

17421742
_setFrames(bm, m, lH);
@@ -2431,17 +2431,28 @@ iterateMatchesFullSimd(TLocalHolder & lH)
24312431
{
24322432
TBlastMatch & bm = *it;
24332433

2434-
computeEValueThreadSafe(bm,
2435-
qIsTranslated(TGlobalHolder::blastProgram)
2436-
? lH.gH.untransQrySeqLengths[bm._n_qId]
2437-
: length(lH.gH.qrySeqs[_untrueQryId(bm, lH)]),
2438-
context(lH.gH.outfile));
2434+
if (lH.options.minBitScore > 0)
2435+
{
2436+
seqan::computeBitScore(bm, seqan::context(lH.gH.outfile));
2437+
2438+
if (bm.bitScore < lH.options.minBitScore)
2439+
{
2440+
++lH.stats.hitsFailedExtendBitScoreTest;
2441+
it = blastMatches.erase(it);
2442+
continue;
2443+
}
2444+
}
24392445

2440-
if (bm.eValue > lH.options.eCutOff)
2446+
if (lH.options.maxEValue < 100)
24412447
{
2442-
++lH.stats.hitsFailedExtendEValueTest;
2443-
it = blastMatches.erase(it);
2444-
continue;
2448+
computeEValueThreadSafe(bm, bm.qLength, seqan::context(lH.gH.outfile));
2449+
2450+
if (bm.eValue > lH.options.maxEValue)
2451+
{
2452+
++lH.stats.hitsFailedExtendEValueTest;
2453+
it = blastMatches.erase(it);
2454+
continue;
2455+
}
24452456
}
24462457

24472458
++it;
@@ -2484,9 +2495,12 @@ iterateMatchesFullSimd(TLocalHolder & lH)
24842495
continue;
24852496
}
24862497

2487-
computeBitScore(bm, context(lH.gH.outfile));
2498+
// not computed previously
2499+
if (lH.options.minBitScore == 0)
2500+
seqan::computeBitScore(bm, seqan::context(lH.gH.outfile));
24882501

2489-
// evalue computed previously
2502+
if (lH.options.maxEValue == 100)
2503+
computeEValueThreadSafe(bm, bm.qLength, seqan::context(lH.gH.outfile));
24902504

24912505
++it;
24922506
}
@@ -2597,9 +2611,16 @@ iterateMatchesFullSerial(TLocalHolder & lH)
25972611
-band,
25982612
+band);
25992613

2600-
computeEValueThreadSafe(bm, record.qLength, context(lH.gH.outfile));
2614+
computeBitScore(bm, context(lH.gH.outfile));
2615+
if (bm.bitScore < lH.options.minBitScore)
2616+
{
2617+
++lH.stats.hitsFailedExtendBitScoreTest;
2618+
record.matches.pop_back();
2619+
continue;
2620+
}
26012621

2602-
if (bm.eValue > lH.options.eCutOff)
2622+
computeEValueThreadSafe(bm, record.qLength, context(lH.gH.outfile));
2623+
if (bm.eValue > lH.options.maxEValue)
26032624
{
26042625
++lH.stats.hitsFailedExtendEValueTest;
26052626
record.matches.pop_back();
@@ -2624,7 +2645,6 @@ iterateMatchesFullSerial(TLocalHolder & lH)
26242645
continue;
26252646
}
26262647

2627-
computeBitScore(bm, context(lH.gH.outfile));
26282648

26292649
if (lH.options.hasSTaxIds)
26302650
bm.sTaxIds = lH.gH.sTaxIds[bm._n_sId];

src/search_datastructures.hpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ struct StatsHolder
111111

112112
// post-extension
113113
uint64_t hitsFailedExtendPercentIdentTest;
114+
uint64_t hitsFailedExtendBitScoreTest;
114115
uint64_t hitsFailedExtendEValueTest;
115116
uint64_t hitsAbundant;
116117
uint64_t hitsDuplicate;
@@ -150,6 +151,7 @@ struct StatsHolder
150151
hitsPutativeAbundant = 0;
151152

152153
hitsFailedExtendPercentIdentTest = 0;
154+
hitsFailedExtendBitScoreTest = 0;
153155
hitsFailedExtendEValueTest = 0;
154156
hitsAbundant = 0;
155157
hitsDuplicate = 0;
@@ -183,6 +185,7 @@ struct StatsHolder
183185
hitsPutativeAbundant += rhs.hitsPutativeAbundant;
184186

185187
hitsFailedExtendPercentIdentTest += rhs.hitsFailedExtendPercentIdentTest;
188+
hitsFailedExtendBitScoreTest += rhs.hitsFailedExtendBitScoreTest;
186189
hitsFailedExtendEValueTest += rhs.hitsFailedExtendEValueTest;
187190
hitsAbundant += rhs.hitsAbundant;
188191
hitsDuplicate += rhs.hitsDuplicate;
@@ -253,12 +256,15 @@ void printStats(StatsHolder const & stats, LambdaOptions const & options)
253256
std::cout << "\n - failed pre-extend test " << R
254257
<< stats.hitsFailedPreExtendTest << RR
255258
<< (rem -= stats.hitsFailedPreExtendTest);
256-
std::cout << "\n - failed %-identity test " << R
257-
<< stats.hitsFailedExtendPercentIdentTest << RR
258-
<< (rem -= stats.hitsFailedExtendPercentIdentTest);
259259
std::cout << "\n - failed e-value test " << R
260260
<< stats.hitsFailedExtendEValueTest << RR
261261
<< (rem -= stats.hitsFailedExtendEValueTest);
262+
std::cout << "\n - failed bitScore test " << R
263+
<< stats.hitsFailedExtendBitScoreTest << RR
264+
<< (rem -= stats.hitsFailedExtendBitScoreTest);
265+
std::cout << "\n - failed %-identity test " << R
266+
<< stats.hitsFailedExtendPercentIdentTest << RR
267+
<< (rem -= stats.hitsFailedExtendPercentIdentTest);
262268
std::cout << "\n - duplicates " << R
263269
<< stats.hitsDuplicate << RR
264270
<< (rem -= stats.hitsDuplicate);

src/search_options.hpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ struct LambdaOptions : public SharedOptions
9696

9797
int xDropOff = 0;
9898
int band = -1;
99-
double eCutOff = 0;
99+
double minBitScore = 0;
100+
double maxEValue = 1e-04;
100101
int idCutOff = 0;
101102
unsigned long maxMatches = 500;
102103

@@ -247,6 +248,14 @@ parseCommandLine(LambdaOptions & options, int argc, char const ** argv)
247248
setMinValue(parser, "e-value", "0");
248249
setMaxValue(parser, "e-value", "100");
249250

251+
addOption(parser, ArgParseOption("", "bit-score",
252+
"Output only matches that score above this threshold.",
253+
ArgParseArgument::DOUBLE));
254+
setDefaultValue(parser, "bit-score", "0");
255+
setMinValue(parser, "bit-score", "0");
256+
setMaxValue(parser, "bit-score", "1000");
257+
258+
250259
addOption(parser, ArgParseOption("n", "num-matches",
251260
"Print at most this number of matches per query.",
252261
ArgParseArgument::INTEGER));
@@ -771,7 +780,8 @@ parseCommandLine(LambdaOptions & options, int argc, char const ** argv)
771780

772781
getOptionValue(options.seedDeltaIncreasesLength, parser, "seed-delta-increases-length");
773782

774-
getOptionValue(options.eCutOff, parser, "e-value");
783+
getOptionValue(options.maxEValue, parser, "e-value");
784+
getOptionValue(options.minBitScore, parser, "bit-score");
775785
getOptionValue(options.idCutOff, parser, "percent-identity");
776786

777787
getOptionValue(options.xDropOff, parser, "x-drop");
@@ -903,8 +913,9 @@ printOptions(LambdaOptions const & options)
903913
<< " db index type: " << _indexEnumToName(options.dbIndexType) << "\n"
904914
<< " OUTPUT (file)\n"
905915
<< " output file: " << options.output << "\n"
916+
<< " maximum e-value: " << options.maxEValue << "\n"
917+
<< " minimum bit-score: " << options.minBitScore << "\n"
906918
<< " minimum % identity: " << options.idCutOff << "\n"
907-
<< " maximum e-value: " << options.eCutOff << "\n"
908919
<< " max #matches per query: " << options.maxMatches << "\n"
909920
<< " include subj names in sam:" << options.samWithRefHeader << "\n"
910921
<< " include seq in sam/bam: " << options.samBamSeq << "\n"

0 commit comments

Comments
 (0)