Skip to content

Commit 8441f02

Browse files
rob-pclaude
andcommitted
feat(map): orphansRequireUnmappedMate orphan-emission policy
Add MappingConstraintPolicy.orphansRequireUnmappedMate. When set, joinReadsAndFilter only emits single-mate (orphan) mappings for a read whose mate produced no mappings at all, instead of reporting the union of both mates' orphans when a pair has no concordant mapping. Default false (union; unchanged behavior). Backs salmon's --orphansRequireUnmappedMate flag. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01B7JMur5DmDpECddErpi2JS
1 parent 17e1ccf commit 8441f02

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

include/Util.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ namespace pufferfish {
117117
bool noOrphans;
118118
bool noDiscordant;
119119
bool noDovetail;
120+
// When true, only emit single-mate (orphan) mappings for a read whose
121+
// mate is entirely unmapped; do not report orphans for both mates of a
122+
// pair that mapped to disjoint reference sets (salmon's
123+
// --orphansRequireUnmappedMate).
124+
bool orphansRequireUnmappedMate{false};
120125
// after merging chains for paired-end reads
121126
// only chains having this threshold score
122127
// *with respect to the best chain on the same target*

src/Util.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,17 @@ pufferfish::util::MergeResult joinReadsAndFilter(
316316
*/
317317
} // for (auto &clustItr : memClusters) [ over all transcripts]
318318
};
319-
orphanFiller(leftMemClusters, true);
320-
orphanFiller(rightMemClusters, false);
319+
// Under --orphansRequireUnmappedMate, only report orphans for a mate when
320+
// the *other* mate produced no mappings at all (it is truly unmapped), so
321+
// a read that mapped only alongside a mate mapping to a disjoint reference
322+
// set is not reported as an orphan. Default: report the union of both.
323+
bool reqUnmapped = mpol.orphansRequireUnmappedMate;
324+
if (!reqUnmapped || rightMemClusters.size() == 0) {
325+
orphanFiller(leftMemClusters, true);
326+
}
327+
if (!reqUnmapped || leftMemClusters.size() == 0) {
328+
orphanFiller(rightMemClusters, false);
329+
}
321330
}
322331
if (sameTxpCount == 0) {
323332
if (leftOrphan and !rightOrphan) {

0 commit comments

Comments
 (0)