merge_criteria¶
Predicate functions consumed by FeatureDB.merge. Each has the
signature (acc: Feature, cur: Feature, components: list[Feature]) -> bool.
Merge predicates — pure functions consumed by FeatureDB.merge.
Signature: (acc: Feature, cur: Feature, components: list[Feature]) -> bool.
acc is the running accumulator; cur is the candidate to fold in;
components is the list of already-folded features. All callables return
True if the candidate should be merged into the accumulator.
Mirrors the legacy gffutils.merge_criteria module.
seqid ¶
Same sequence. Almost always wanted -- omitting it merges features on different chromosomes into one.
strand ¶
feature_type ¶
exact_coordinates_only ¶
overlap_end_inclusive ¶
cur starts within acc, or immediately after it.
"Immediately after" is the + 1: two features that abut with no gap are
adjacent, not overlapping, and merging them is normally what a caller
wants when collapsing exon runs.
Source code in python/gffbase/merge_criteria.py
overlap_start_inclusive ¶
overlap_any_inclusive ¶
overlap_end_threshold ¶
cur starts within the accumulator, allowing a gap of threshold.
Changed in 0.2.0. This and the two factories below are RANGE tests,
not distance tests. They used to compute
abs(acc.end - cur.start) <= threshold, which reads naturally but answers
a different question: it asks how far apart two boundaries are, and so
rejects a feature lying entirely inside the accumulator -- the most
unambiguous overlap there is.
Concretely, with acc = (1, 100), cur = (50, 200), threshold = 5, the
old form gave abs(100 - 50) = 50 <= 5 -> False, and these two plainly
overlapping features did not merge. This form gives 1 <= 50 <= 105 ->
True.
If you call merge or merge_all with one of these, the set of features
that merge has changed. Nothing else in the merge machinery did.
Source code in python/gffbase/merge_criteria.py
overlap_start_threshold ¶
cur ends within the accumulator, allowing a gap of threshold.
Source code in python/gffbase/merge_criteria.py
overlap_any_threshold ¶
Either end qualifies.