Esempio n. 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
    #0 output arguments
    assert options.format != 'BAMPE', "Pair-end data with BAMPE option currently doesn't work with pileup command. You can pretend your data to be single-end with -f BAM. Please try again!"

    #0 prepare output file
    outfile = os.path.join(options.outdir, options.outputfile)
    if os.path.isfile(outfile):
        info("# Existing file %s will be replaced!" % outfile)
        os.unlink(outfile)

    #1 Read tag files
    info("# read alignment files...")
    (tsize, treat) = load_tag_files_options(options)

    info("# tag size = %d", tsize)

    t0 = treat.total
    info("# total tags in alignment file: %d", t0)

    if options.bothdirection:
        info(
            "# Pileup alignment file, extend each read towards up/downstream direction with %d bps"
            % options.extsize)
        pileup_and_write(treat,
                         outfile,
                         options.extsize * 2,
                         1,
                         directional=False,
                         halfextension=False)
    else:
        info(
            "# Pileup alignment file, extend each read towards downstream direction with %d bps"
            % options.extsize)
        pileup_and_write(treat,
                         outfile,
                         options.extsize,
                         1,
                         directional=True,
                         halfextension=False)

    info("# Done! Check %s" % options.outputfile)
Esempio n. 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
    #0 output arguments
    options.PE_MODE = options.format in ('BAMPE','BEDPE')
    #assert options.format != 'BAMPE', "Pair-end data with BAMPE option currently doesn't work with pileup command. You can pretend your data to be single-end with -f BAM. Please try again!"


    #0 prepare output file
    outfile = os.path.join( options.outdir, options.outputfile )
    if os.path.isfile( outfile ):
        info("# Existing file %s will be replaced!" % outfile )
        os.unlink( outfile )
        
    #1 Read tag files
    info("# read alignment files...")
    if options.PE_MODE:
        info("# read input file in Paired-end mode.")
        treat = load_frag_files_options ( options ) # return PETrackI object
        t0 = treat.total # total fragments
        info("# total fragments/pairs in alignment file: %d" % (t0) )
        info("# Pileup paired-end alignment file.")
        pileup_and_write_pe(treat, outfile )
        
    else:
        (tsize, treat) = load_tag_files_options  (options)
    
        info("# tag size = %d", tsize)
    
        t0 = treat.total
        info("# total tags in alignment file: %d", t0)

        if options.bothdirection:
            info("# Pileup alignment file, extend each read towards up/downstream direction with %d bps" % options.extsize)
            pileup_and_write(treat, outfile, options.extsize * 2, 1, directional=False, halfextension=False)
        else:
            info("# Pileup alignment file, extend each read towards downstream direction with %d bps" % options.extsize)
            pileup_and_write(treat, outfile, options.extsize, 1, directional=True, halfextension=False)

    info("# Done! Check %s" % options.outputfile)