1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
"""
Merge criteria used by FeatureDB merge() and merge_all()
"""
from gffutils.feature import Feature
def seqid(acc, cur, components):
return cur.seqid == acc.seqid
def strand(acc, cur, components):
return acc.strand == cur.strand
def feature_type(acc, cur, components):
return acc.featuretype == cur.featuretype
def exact_coordinates_only(acc, cur, components):
return cur.start == acc.start and cur.stop == acc.end
def overlap_end_inclusive(acc, cur, components):
return acc.start <= cur.start <= acc.end + 1
def overlap_start_inclusive(acc, cur, components):
return acc.start <= cur.end + 1 <= acc.end + 1
def overlap_any_inclusive(acc, cur, components):
return (
acc.start <= cur.start <= acc.end + 1 or acc.start <= cur.end + 1 <= acc.end + 1
)
def overlap_end_threshold(threshold):
def partial(acc, cur, components):
return acc.start <= cur.start <= acc.end + threshold
return partial
def overlap_start_threshold(threshold):
def partial(acc, cur, components):
return acc.start - threshold <= cur.end + 1 <= acc.end + 1
return partial
def overlap_any_threshold(threshold):
def partial(acc, cur, components):
return (
acc.start - threshold <= cur.end + 1 <= acc.end + 1
or acc.start <= cur.start <= acc.end + threshold
)
return partial
|