示例#1
0
def makeAnnotatorGeneSets( infile, outfile, slice ):
    '''compute annotator overlap between sets.
    '''
    
    workspaces = ("genomic", "alignable", slice )

    track = infile[:-len(".gtf.gz")]

    infiles = ANNOTATOR_TRACKS

    related = getRelatedTracks( infile, infiles )

    if related:
        E.info("removing related tracks %s from %s" % \
                   ( related, infile ) )
        related = set(related)
        infiles = [x for x in TRACKS if x not in related ]
        
    tmpdir = tempfile.mkdtemp( dir = os.getcwd() )

    annotations = os.path.join( tmpdir, "annotations")
    PAnnotator.buildGeneSetAnnotations( infiles,
                                        annotations,
                                        slice )

    segments = PAnnotator.buildAnnotatorSlicedSegments( tmpdir, 
                                                        outfile, 
                                                        track, 
                                                        slice )

    if not segments:
        E.warn( "no segments for %s - no annotator results" % outfile )
        shutil.rmtree( tmpdir )
        P.touch( outfile )
        return

    workspaces, synonyms = PAnnotator.buildAnnotatorWorkSpace( tmpdir, 
                                                               outfile,
                                                               workspaces = workspaces,
                                                               gc_control = True )
    
    PAnnotator.runAnnotator( tmpdir, 
                             outfile, 
                             annotations, 
                             segments, 
                             workspaces, 
                             synonyms )

    shutil.rmtree( tmpdir )