Example #1
0
def run( o_options ):
    """The Main function/pipeline for duplication filter.
    
    """
    # Parse options...
    options = opt_validate( o_options )
    # end of parsing commandline options
    info = options.info
    warn = options.warn
    debug = options.debug
    error = options.error


    outputfile = open(options.oprefix+"_refinepeak.bed", "w")

    peakio = file(options.bedfile)
    peaks = PeakIO()
    for l in peakio:
        fs = l.rstrip().split()
        peaks.add( fs[0], int(fs[1]), int(fs[2]), name=fs[3] )

    peaks.sort()
    
    #1 Read tag files
    info("read tag files...")
    fwtrack = load_tag_files_options (options)
    
    retval = fwtrack.compute_region_tags_from_peaks( peaks, find_summit, window_size = options.windowsize, cutoff = options.cutoff )
    outputfile.write( "\n".join( map(lambda x: "%s\t%d\t%d\t%s\t%.2f" % x , retval) ) )
    info("Done!")
    info("Check output file: %s" % options.oprefix+"_refinepeak.bed")
Example #2
0
def run( o_options ):
    """The Main function/pipeline for duplication filter.
    
    """
    # Parse options...
    options = opt_validate( o_options )
    # end of parsing commandline options
    info = options.info
    warn = options.warn
    debug = options.debug
    error = options.error


    outputfile = open(options.oprefix+"_refinepeak.bed", "w")

    
    #if options.outputfile != "stdout":
    #    assert not os.path.exists(options.outputfile), "%s already exists, please check!" % options.outputfile
    #    outfhd = open(options.outputfile,"w")
    #else:
    #    outfhd = sys.stdout

    peakio = file(options.bedfile)
    peaks = PeakIO()
    for l in peakio:
        fs = l.rstrip().split()
        peaks.add( fs[0], int(fs[1]), int(fs[2]), name=fs[3] )

    peaks.sort()
    
    #for l in peakio:
    #l = peakio.readline()
    #fs = l.rstrip().split()
    #print fs
    
    #1 Read tag files
    info("read tag files...")
    fwtrack = load_tag_files_options (options)
    
    #info("tag size = %d" % options.tsize)
    #fwtrack.fw = options.tsize

    retval = fwtrack.compute_region_tags_from_peaks( peaks, find_summit, window_size = options.windowsize, cutoff = options.cutoff )
    outputfile.write( "\n".join( map(lambda x: "%s\t%d\t%d\t%s\t%.2f" % x , retval) ) )
    info("Done!")
    info("Check output file: %s" % options.oprefix+"_refinepeak.bed")