def buildAnnotatorSegmentsROI( tmpdir, roi_class, outfile, overlap = None ):

    tmpsegments = os.path.join( tmpdir, "segments" )
    to_cluster = True

    dbhandle = sqlite3.connect( PARAMS["database"] )

    if overlap:
            statement = '''
            SELECT roi.contig, roi.start, roi.end
            FROM regions_of_interest AS roi,
                 %(overlap)s_intervals AS i
            WHERE roi.class='%(roi_class)s' AND 
                  i.contig = roi.contig AND
                  min(roi.end, i.end) - max(roi.start, i.start) > 0
        '''
    else:
        statement = '''
            SELECT roi.contig, roi.start, roi.end
            FROM regions_of_interest AS roi
            WHERE class='%(roi_class)s'
        '''

    cc = dbhandle.cursor()
    cc.execute( statement % locals() )

    noutput = 0
    contigs = collections.defaultdict( list )
    for result in cc:
        contig, start, end = result
        contigs[contig].append( (start,end) )
        noutput += 1

    E.info("segments for roi_class `%s` and overlap `%s`: %i" % (roi_class, overlap, noutput))
        
    outs = open(tmpsegments, "w" )
    gff2annotator.outputSegments( outs, contigs,
                                  section = "segments" )
    outs.close()

    if noutput == 0:
        return None
    else:
        return tmpsegments

############################################################
############################################################
############################################################
##
############################################################
Update an instance in its cell.
dataset/ETHPy150Open CGATOxford/cgat/obsolete/pipeline_vitaminD_annotator.py/buildAnnotatorSegmentsROI--crossover with--dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/cells/manager.py/CellsManager.instance_update_from_api