def jaccardIndex(s1, s2, stranded=False):
def count(s):<EOL><INDENT>"""<STR_LIT>"""<EOL>tot = <NUM_LIT:0><EOL>for r in s:<EOL><INDENT>tot += len(r)<EOL><DEDENT>return tot<EOL><DEDENT>if stranded:<EOL><INDENT>raise GenomicIntervalError("<STR_LIT>" +<EOL>"<STR_LIT>")<EOL><DEDENT>s1 = collapseRegions(s1)<EOL>s2 = collapseRegions(s2)<EOL>intersection = regionsIntersection(s1, s2)<EOL>c_i = count(intersection)<EOL>return c_i / float(count(s1) + count(s2) - c_i)<EOL>
Compute the Jaccard index for two collections of genomic intervals

:param s1: the first set of genomic intervals
:param s2: the second set of genomic intervals
:param stranded: if True, treat regions on different strands as not
                 intersecting each other, even if they occupy the same
                 genomic region.
:return: Jaccard index