Beispiel #1
0
def _hisat(input, index, mirbase):
    safe_makedir("hisat")
    with ch_directory("hisat"):
        output = "hisat_map.bam"
        cmd = ("hisat -f -k 50 -L 18 -x {index}" " -U {input}" " >| hits.sam")
        cmd_bam = "samtools view -Sbh hits.sam >| {output}"

        if not is_there("hits.sam"):
            do.run(cmd.format(**locals()), "")
        if not is_there(output):
            do.run(cmd_bam.format(**locals()), "")

        mirbase_output = _annotate(output, mirbase)
        return (mirbase_output, full(output))
Beispiel #2
0
def _tailor(input, index, mirbase):
    safe_makedir("tailor")
    with ch_directory("tailor"):
        output = "tailor_map.bam"
        cmd = ("tailor  -l 15 map -p {index}" " -i {input}" " -o hits.sam")
        cmd_bam = "samtools view -Sbh hits.sam >| {output}"

        if not is_there("hits.sam"):
            do.run(cmd.format(**locals()), "")
        if not is_there(output):
            do.run(cmd_bam.format(**locals()), "")

        mirbase_output = _annotate(output, mirbase)
        return (mirbase_output, full(output))
Beispiel #3
0
def _hisat(input, index, mirbase):
    with ch_directory("hisat"):
        output = "hisat_map.bam"
        cmd = ("hisat -k 50 -L 18 -x {index}"
               " -U {input}"
               " >| hits.sam")
        cmd_bam = "samtools view -Sbh hits.sam >| {output}"

        if not is_there("hits.sam"):
            do.run(cmd.format(**locals()), "")
        if not is_there(output):
            do.run(cmd_bam.format(**locals()), "")

        mirbase_output = _annotate(output, mirbase)
    return mirbase_output
Beispiel #4
0
def _tailor(input, index, mirbase):
    safe_makedir("tailor")
    with ch_directory("tailor"):
        output = "tailor_map.bam"
        cmd = ("tailor  -l 15 map -p {index}"
               " -i {input}"
               " -o hits.sam")
        cmd_bam = "samtools view -Sbh hits.sam >| {output}"

        if not is_there("hits.sam"):
            do.run(cmd.format(**locals()), "")
        if not is_there(output):
            do.run(cmd_bam.format(**locals()), "")

        mirbase_output = _annotate(output, mirbase)
        return (mirbase_output, full(output))
Beispiel #5
0
def _bowtie2(input, index, mirbase):
    safe_makedir("bowtie2")
    with ch_directory("bowtie2"):
        output = "bowtie2_map.bam"
        cmd = ("bowtie2 -f -k 50 -L 18 -x {index}"
               " -U {input}"
               " >| hits.sam")
        cmd_bam = "samtools view -Sbh hits.sam >| {output}"

        if not is_there("hits.sam"):
            do.run(cmd.format(**locals()), "")
        if not is_there(output):
            do.run(cmd_bam.format(**locals()), "")

        mirbase_output = _annotate(output, mirbase)
        return (mirbase_output, full(output))
Beispiel #6
0
def _annotate(input, mirbase):
    output = "mirbase.bed"
    cmd = ("bedtools intersect -bed -wo -s -f 0.80 -a"
           " {input} -b {mirbase} >| {output}")
    if not is_there(output):
        do.run(cmd.format(**locals()), "")
    return full(output)
Beispiel #7
0
def _annotate(input, mirbase):
    output = "mirbase.bed"
    cmd = ("bedtools intersect -bed -wo -s -f 0.80 -a"
           " {input} -b {mirbase} >| {output}")
    if not is_there(output):
        do.run(cmd.format(**locals()), "")
    return full(output)
Beispiel #8
0
def _star(input, index, mirbase):
    with ch_directory("star"):
        output = "star_map.bam"
        cmd = ("STAR --genomeDir {index} --readFilesIN {input}"
               " --outFilterMultimapNmax 50"
               " --outSAMattributes NH HI NM"
               " --alignIntronMax 1")
        cmd_bam = "samtools view -Sbh Aligned.out.sam >| {output}"

        if not is_there("Aligned.out.sam"):
            do.run(cmd.format(**locals()), "")
        if not is_there(output):
            do.run(cmd_bam.format(**locals()), "")

        mirbase_output = _annotate(output, mirbase)
    return mirbase_output
Beispiel #9
0
def _stats(ann, fasta, prefix):
    output = prefix + ".tsv"
    if not is_there(output):
        sim_data = res.read_sim_fa(fasta)
        data, counts = res.read_bam(ann)
        res.print_output(data, counts, sim_data, output, prefix)
    return output
Beispiel #10
0
def _star(input, index, mirbase):
    safe_makedir("star")
    with ch_directory("star"):
        output = "star_map.bam"
        cmd = ("STAR --genomeDir {index} --readFilesIN {input}"
               " --outFilterMultimapNmax 50"
               " --outSAMattributes NH HI NM"
               " --alignIntronMax 1")
        cmd_bam = "samtools view -Sbh Aligned.out.sam >| {output}"

        if not is_there("Aligned.out.sam"):
            do.run(cmd.format(**locals()), "")
        if not is_there(output):
            do.run(cmd_bam.format(**locals()), "")

        mirbase_output = _annotate(output, mirbase)
        return (mirbase_output, full(output))
Beispiel #11
0
def _stats(ann, bam, fasta, prefix):
    output = prefix + ".tsv"
    if not is_there(output):
        sim_data = res.read_sim_fa(fasta)
        data, counts = res.read_ann(ann)
        mapped = res.read_bam(bam)
        res.print_output(data, counts, sim_data, mapped, output, prefix)
    return output
Beispiel #12
0
def _srnamapper(input, index, mirbase):
    safe_makedir("srnamapper")
    with ch_directory("srnamapper"):
        output = "srnamapper_map.bed"
        cmd = ("sRNAmapper.pl  -i {input} -g  {index}"
               " -s 10 -n 3 -o hits.eland")

        if not is_there("hits.eland"):
            do.run(cmd.format(**locals()), "")
        if not is_there(output):
            with open(output, 'w') as out_handle:
                with open("hits.eland") as in_handle:
                    for line in in_handle:
                        cols = line.strip().split('\t')
                        print >>out_handle, "%s\t%s\t%s\t%s\t1\t%s\t1\t1\t1\t1\t1\t1" % (cols[0], cols[1], int(cols[1]) + len(cols[2]), cols[3], cols[6])

        mirbase_output = _annotate(output, mirbase)
        return (mirbase_output, full(output))
Beispiel #13
0
def _srnamapper(input, index, mirbase):
    safe_makedir("srnamapper")
    with ch_directory("srnamapper"):
        output = "srnamapper_map.bed"
        cmd = ("sRNAmapper.pl  -i {input} -g  {index}"
               " -s 10 -n 3 -o hits.eland")

        if not is_there("hits.eland"):
            do.run(cmd.format(**locals()), "")
        if not is_there(output):
            with open(output, 'w') as out_handle:
                with open("hits.eland") as in_handle:
                    for line in in_handle:
                        cols = line.strip().split('\t')
                        print >> out_handle, "%s\t%s\t%s\t%s\t1\t%s\t1\t1\t1\t1\t1\t1" % (
                            cols[0], cols[1], int(cols[1]) + len(cols[2]),
                            cols[3], cols[6])

        mirbase_output = _annotate(output, mirbase)
        return (mirbase_output, full(output))