diff --git a/include/SalmonDefaults.hpp b/include/SalmonDefaults.hpp index e5573d9d5..0bfcf31d4 100644 --- a/include/SalmonDefaults.hpp +++ b/include/SalmonDefaults.hpp @@ -4,6 +4,7 @@ namespace salmon { namespace defaults { // general + constexpr const bool discardOrphansAln{false}; constexpr const bool discardOrphansQuasi{false}; constexpr const bool allowOrphansFMD{false}; constexpr const bool seqBiasCorrect{false}; diff --git a/include/SalmonOpts.hpp b/include/SalmonOpts.hpp index dcad63bb0..b1bbbfbc6 100644 --- a/include/SalmonOpts.hpp +++ b/include/SalmonOpts.hpp @@ -260,6 +260,7 @@ struct SalmonOpts { // for utility (may need to be cleaned up later) bool discardOrphansQuasi; + bool discardOrphansAln; double coverageThresh; std::vector unmatedReadFiles; std::vector mate1ReadFiles; diff --git a/src/ProgramOptionsGenerator.cpp b/src/ProgramOptionsGenerator.cpp index 590a63dba..411058448 100644 --- a/src/ProgramOptionsGenerator.cpp +++ b/src/ProgramOptionsGenerator.cpp @@ -199,6 +199,12 @@ namespace salmon { po::options_description alignin("\n" "alignment input options"); alignin.add_options() + ("discardOrphans", + po::bool_switch(&(sopt.discardOrphansAln))->default_value(salmon::defaults::discardOrphansAln), + "[Alignment-based mode only] : Discard orphan alignments in the input " + ". If this flag is passed, then only paired alignments will be " + "considered toward quantification estimates. The default behavior is " + "to consider orphan alignments if no valid paired mappings exist.") ("libType,l", po::value()->required(), "Format string describing the library type") ("alignments,a", po::value>()->multitoken()->required(), "input alignment (BAM) file(s).") diff --git a/src/SalmonQuantifyAlignments.cpp b/src/SalmonQuantifyAlignments.cpp index 35c99eaf4..4948de37b 100644 --- a/src/SalmonQuantifyAlignments.cpp +++ b/src/SalmonQuantifyAlignments.cpp @@ -163,6 +163,8 @@ void processMiniBatch(AlignmentLibraryT& alnLib, using salmon::math::logAdd; using salmon::math::logSub; + auto orphanProb = salmonOpts.discardOrphansAln ? LOG_0 : LOG_EPSILON; + // k-mers for sequence bias Mer leftMer; Mer rightMer; @@ -289,7 +291,10 @@ void processMiniBatch(AlignmentLibraryT& alnLib, // If we are expecting a paired-end library, and this is an orphan, // then logFragProb should be small if (isUnexpectedOrphan(aln, expectedLibraryFormat)) { - logFragProb = LOG_EPSILON; + logFragProb = orphanProb; + if (logFragProb == LOG_0) { + continue; + } } if (flen > 0.0 and aln->isPaired() and useFragLengthDist and