def collapseRegions(s, stranded=False, names=False, verbose=False):
if stranded:<EOL><INDENT>return (__collapse_stranded(s, set("<STR_LIT:+>"), names, verbose) +<EOL>__collapse_stranded(s, set("<STR_LIT:->"), names, verbose))<EOL><DEDENT>else:<EOL><INDENT>return __collapse_stranded(s, set(["<STR_LIT:+>", "<STR_LIT:->"]), names, verbose)<EOL><DEDENT>
Get the union of a set of genomic intervals.

given a list of genomic intervals with chromosome, start and end field,
collapse into a set of non-overlapping intervals. Intervals must be sorted by
chromosome and then start coordinate.

:note: O(n) time, O(n) space
:return:  list of intervals that define the collapsed regions. Note that
          these are all new objects, no existing object from s is returned
          or altered. Returned regions will all have name "X" and score 0
:param s:        list of genomic regions to collapse
:param stranded: if True, regions on positive and negative strands are
                 collapsed separately. Otherwise, strand is ignored and all
                 output regions are on positive strand.
:raise GenomicIntervalError: if the input regions are not correctly sorted
                             (chromosome then start)