Пример #1
0
def deploy_binary():
    aws_pool.make_pool()
    with misc.chdir("./bin"):
        misc.call("python3 -m zipfile -c muta.zip muta")
        aws_pool.pool.run(f"rm -rf {convention.remote_path}/muta")
        aws_pool.pool.run("rm -rf /tmp/muta.zip")
        for e in aws_pool.pool:
            print(f"{e.host} upload muta.zip")
            e.put("muta.zip", "/tmp/muta.zip")
    aws_pool.pool.run(f"python3 -m zipfile -e /tmp/muta.zip {convention.remote_path}")
    aws_pool.pool.run(f"cd {convention.remote_path}/muta && chmod +x muta-chain && chmod +x muta-keypair")
Пример #2
0
def GROSeqPL(args):
    call("mkdir -p alignment conv_rpkm")
    #if (os.path.isfile(args.file_1) and "L001" in args.file_1):
    #    read_concat(args)
    fq_to_bam(args)
    wig_convert(args)
    homer(args)
    convergent(args)
    gmean_cal(args)
    extract_rpkm(args)

    call("rm -rf alignment/{output}.sam".format(**vars(args)))
Пример #3
0
def read_concat(args):
    index_1 = args.file_1.find("L001")
    cat_R1 = args.file_1.replace(args.file_1[index_1:], "L00*_R1*")
    index_2 = args.file_2.find("L001")
    cat_R2 = args.file_2.replace(args.file_2[index_2:], "L00*_R2*")
    args.file_1 = args.file_1.replace("L001_", "")
    args.file_2 = args.file_2.replace("L001_", "")

    call("cat {0}> {1}".format(cat_R1, args.file_1))
    call("cat {0}> {1}".format(cat_R2, args.file_2))
    call("rm -f {0}".format(cat_R1[:-4]))
    return
Пример #4
0
def homer(args):
    if args.custom_genome:
        call(
            "/bin/homer/bin/makeTagDirectory conv_rpkm/{0} alignment/{0}.bam -genome {1}.fa"
            .format(args.output, args.custom_genome))
    else:
        call(
            "/bin/homer/bin/makeTagDirectory conv_rpkm/{0} alignment/{0}.bam -genome {1}.fa"
            .format(args.output, args.genome))
    # call("/bin/homer/bin/findPeaks conv_rpkm/{0} -style groseq -o auto -uniqmap /usr/local/homer/data/uniqmap/mm9-uniqmap".format(args.output))
    call("/bin/homer/bin/findPeaks conv_rpkm/{0} -style groseq -o auto".format(
        args.output))
    return
Пример #5
0
def build_binary():
    with misc.chdir(convention.muta_path):
        misc.call("unset ROCKSDB_LIB_DIR && cargo build --release --example muta-chain")
        with misc.chdir("./devtools/keypair"):
            misc.call("cargo build --release")

    misc.call("rm -rf ./bin/muta")
    misc.call("mkdir -p ./bin/muta")

    a = os.path.join(convention.muta_path, "target/release/examples/muta-chain")
    misc.call(f"cp {a} ./bin/muta")
    a = os.path.join(convention.muta_path, "target/release/muta-keypair")
    misc.call(f"cp {a} ./bin/muta")
Пример #6
0
def parseFILE(args):
    genomefile = args.genome
    normdef = ''
    if args.normalization == 'T':
        normdef = ' -t 1000000000 '

    if args.strandspecific == 'F':
        prefix = args.bamfile.replace('.bam', '')
        call('python2 /bin/bam2wig.py -i %s -o %s -s %s %s' %
             (args.bamfile, prefix, genomefile, normdef))
        call('rm -rf %s.wig' % prefix)
    else:
        prefix_pos = args.bamfile.replace('.bam', '.pos')
        call('/bin/samtools view -@ %s -F 0x10 -hb -o %s.bam %s' %
             (args.threads, prefix_pos, args.bamfile))
        call('/bin/samtools sort -@ %s %s.bam -o %s.sort.bam' %
             (args.threads, prefix_pos, prefix_pos))
        call('mv %s.sort.bam %s.bam' % (prefix_pos, prefix_pos))
        call('/bin/samtools index -@ %s %s.bam' % (args.threads, prefix_pos))
        call('python2 /bin/bam2wig.py -i %s.bam -o %s -s %s %s' %
             (prefix_pos, prefix_pos, genomefile, normdef))

        # Need to add minus symbol in minus bw file
        prefix_neg = args.bamfile.replace('.bam', '.neg')
        call('/bin/samtools view -@ %s -f 0x10 -hb -o %s.bam %s' %
             (args.threads, prefix_neg, args.bamfile))
        call('/bin/samtools sort -@ %s %s.bam -o %s.sort.bam' %
             (args.threads, prefix_neg, prefix_neg))
        call('mv %s.sort.bam %s.bam' % (prefix_neg, prefix_neg))
        call('/bin/samtools index -@ %s %s.bam' % (args.threads, prefix_neg))
        call('python2 /bin/bam2wig.py -i %s.bam -o %s -s %s %s' %
             (prefix_neg, prefix_neg, genomefile, normdef))
        fout = open('%s.2.wig' % prefix_neg, 'w')
        for line in open('%s.wig' % prefix_neg):
            if line.startswith('variableStep'):
                fout.write(line)
            else:
                fout.write('%s\t-%s\n' % (line.split()[0], line.split()[1]))
        fout.close()
        call('wigToBigWig -clip %s.2.wig %s %s.bw' %
             (prefix_neg, genomefile, prefix_neg))

        call('rm -rf %s.bam* %s.bam*' % (prefix_pos, prefix_neg))
        call('rm -rf %s.wig %s.wig' % (prefix_pos, prefix_neg))
        call('rm -rf %s.2.wig' % (prefix_neg))
Пример #7
0
def build_binary():
    os.makedirs('./bin/telnet', exist_ok=True)
    with misc.chdir('./telnet'):
        misc.call('go build -o ../bin/telnet/ github.com/libraries/muta_aws_fabric/telnet/cmd/server')
        misc.call('go build -o ../bin/telnet/ github.com/libraries/muta_aws_fabric/telnet/cmd/client')
Пример #8
0
def gmean_cal(args):
    call(
        "awk '{{OFS=\"\\t\"}}{{printf \"%s\\t%s\\t%s\\t%s_%s_%s\\t.\\t.\\n\", $1, $2, $3, $1, $2, $3}}' conv_rpkm/{output}.transcripts.convergent.bed > conv_rpkm/{output}.transcripts.convergent.6.bed"
        .format(**vars(args)),
        shell=True)
    call(
        "/bin/samtools view -@ {threads} alignment/{output}.pos.bam | gfold count -annf BED -ann conv_rpkm/{output}.transcripts.convergent.6.bed -tag stdin -o conv_rpkm/{output}.pos.cnt"
        .format(**vars(args)),
        shell=True)
    call(
        "/bin/samtools view -@ {threads} alignment/{output}.neg.bam | gfold count -annf BED -ann conv_rpkm/{output}.transcripts.convergent.6.bed -tag stdin -o conv_rpkm/{output}.neg.cnt"
        .format(**vars(args)),
        shell=True)
    call(
        "/bin/samtools view -@ {threads} alignment/{output}.pos.bam | gfold count -annf BED -s T -ann {annotation} -tag stdin -o conv_rpkm/{output}.pos3.cnt"
        .format(**vars(args)),
        shell=True)
    call(
        "/bin/samtools view -@ {threads} alignment/{output}.neg.bam | gfold count -annf BED -s T -ann {annotation} -tag stdin -o conv_rpkm/{output}.neg3.cnt"
        .format(**vars(args)),
        shell=True)
    call(
        "python2 /bin/COVT.gmean_cal.py conv_rpkm/{output} > conv_rpkm/{output}.gmean.cnt"
        .format(**vars(args)),
        shell=True)
    call(
        "sort -gr -k 4 conv_rpkm/{output}.gmean.cnt > conv_rpkm/{output}.gmean.cnt.sort"
        .format(**vars(args)),
        shell=True)
    call(
        "python2 /bin/Add.col.py conv_rpkm/{output}.gmean.cnt.sort > conv_rpkm/{output}.gmean.bed"
        .format(**vars(args)),
        shell=True)
    return
Пример #9
0
def convergent(args):
    call(
        "grep -v \"#\" conv_rpkm/{0}/transcripts.txt | awk '{{OFS=\"\t\"}}{{print $2, $3, $4, $1, $6, $5}}' > conv_rpkm/{0}.transcript.bed"
        .format(args.output),
        shell=True)
    call("/bin/bedtools/bedtools sort -i conv_rpkm/{0}.transcript.bed > see".
         format(args.output),
         shell=True)
    call("mv see conv_rpkm/{0}.transcript.bed".format(args.output), shell=True)
    call(
        "grep -v \"+\" conv_rpkm/{0}.transcript.bed > conv_rpkm/{0}.transcripts.minus.bed"
        .format(args.output),
        shell=True)
    call(
        "grep \"+\" conv_rpkm/{0}.transcript.bed > conv_rpkm/{0}.transcripts.plus.bed"
        .format(args.output),
        shell=True)
    call(
        "/bin/bedtools/bedtools multiinter -i conv_rpkm/{0}.transcripts.plus.bed conv_rpkm/{0}.transcripts.minus.bed |grep \"1,2\" |awk \'{{OFS=\"\\t\"}}{{ if ($3-$2>100){{print $1, $2, $3}} }}\' > conv_rpkm/{0}.transcripts.convergent.bed"
        .format(args.output),
        shell=True)
    return
Пример #10
0
def fq_to_bam(args):
    if args.custom_genome:
        # path, folder = os.path.split(args.custom_genome)
        args.genome = args.custom_genome

    if args.file_1:
        call(
            "/bin/bowtie2/bowtie2 -p {threads} -x {genome} -1 {file_1} -2 {file_2} --non-deterministic -S alignment/{output}.sam"
            .format(**vars(args)))
    else:
        call(
            "/bin/bowtie2/bowtie2 -p {threads} -x {genome} -U {file} --non-deterministic -S alignment/{output}.sam"
            .format(**vars(args)))
    call(
        "/bin/samtools view -@ {threads} -bhS -F 4 alignment/{output}.sam -o alignment/{output}.bam"
        .format(**vars(args)))
    call(
        "/bin/samtools sort -@ {threads} alignment/{output}.bam -o alignment/{output}.sort.bam"
        .format(**vars(args)))

    call("mv alignment/{output}.sort.bam alignment/{output}.bam".format(
        **vars(args)))
    call(
        "/bin/samtools index -@ {threads} alignment/{output}.bam alignment/{output}.bam.bai"
        .format(**vars(args)))
    call(
        "/bin/samtools stats -@ {threads} alignment/{output}.bam > alignment/{output}.stats.txt"
        .format(**vars(args)),
        shell=True)

    return