Exemplo n.º 1
0
def mapReadsAgainstSpadesContigs(infiles, outfile):
    '''
    map reads against spades contigs
    '''
    inf = infiles[0]
    to_cluster = True
    index_dir = os.path.dirname(outfile)

    if "agg" not in infiles[1]:
        genome = re.search(
            ".*R[0-9]*", infiles[0]).group(0) + ".filtered.contigs.fa"
    else:
        genome = "agg-agg-agg.filtered.contigs.fa"

    if infiles[1].endswith(".bt2") or infiles[1].endswith(".ebwt"):
        infile, reffile = infiles[0],  os.path.join(index_dir, genome) + ".fa"
        m = PipelineMapping.Bowtie(
            executable=P.substituteParameters(**locals())["bowtie_executable"])

    elif infiles[1].endswith("bwt"):
        genome = genome
        job_options = " -l mem_free=%s" % (PARAMS["bwa_memory"])
        bwa_index_dir = index_dir
        bwa_mem_options = PARAMS["bwa_mem_options"]
        bwa_threads = PARAMS["bwa_threads"]
        m = PipelineMapping.BWAMEM(remove_non_unique=True)
    statement = m.build((inf,), outfile)
    P.run()
Exemplo n.º 2
0
def mapBowtieAgainstTranscriptomeGSE65525(infiles, outfile):
    ''' map reads using Bowtie against transcriptome

    bowtie parameterised according to Allon et al 2015 except
    random reporting of alignments where more than one "best" exist (-M 1):

    -n 1 number of mismatches allowed
    -l 15 seed length
    -e 300 maxmimum permitted sum of sequence qualities at all mismatched
           positions
    -M 1 if more than one "best" alignment exist, report one at random
    --best report in best to worst order
    --strata only report reads falling into the best stratum
    '''

    infile, reference = infiles
    job_threads = 2
    job_options = "-l mem_free=1.9G"
    bowtie_options = "-n1 -l 15 -e 300 -M 1 --best --strata"
    bowtie_index_dir = os.path.abspath(os.path.dirname(reference))
    genome = P.snip(os.path.basename(reference), ".1.ebwt")
    reffile = reference
    bowtie_threads = job_threads

    m = PipelineMapping.Bowtie(tool_options=bowtie_options,
                               remove_non_unique=0,
                               strip_sequence=0)

    statement = m.build((infile, ), outfile)
    P.run()
Exemplo n.º 3
0
def run_mapping(infile, outfile):
    ''' Map reads with the specified read mapper '''

    if PARAMS["mapper"] == "star":
        job_threads = PARAMS["star_threads"]
        job_memory = PARAMS["star_memory"]
        star_mapping_genome = PARAMS["star_genome"] or PARAMS["genome"]
        m = PipelineMapping.STAR(
            executable=P.substituteParameters(**locals())["star_executable"],
            strip_sequence=0)

    elif PARAMS["mapper"] == "bowtie":
        job_threads = PARAMS["bowtie_threads"]
        job_memory = PARAMS["bowtie_memory"]

        m = PipelineMapping.Bowtie(executable="bowtie",
                                   tool_options=PARAMS["bowtie_options"],
                                   strip_sequence=0)

        genome = PARAMS["bowtie_genome"]
        reffile = os.path.join(PARAMS["bowtie_index_dir"],
                               PARAMS["bowtie_genome"] + ".fa")

    statement = m.build((infile, ), outfile)

    P.run()
Exemplo n.º 4
0
def buildBAM(infile, outfile):
    '''map reads with bowtie'''
    track = P.snip(os.path.basename(outfile), ".bam")
    job_threads = PARAMS["bowtie_threads"]
    m = PipelineMapping.Bowtie()
    reffile = PARAMS["samtools_genome"]
    statement = m.build((infile, ), outfile)
    P.run()
Exemplo n.º 5
0
def buildBAM(infile, outfile):
    '''map reads with bowtie'''
    to_cluster = True
    track = P.snip(os.path.basename(outfile), ".bam")
    job_options = "-pe dedicated %i -R y" % PARAMS["bowtie_threads"]
    m = PipelineMapping.Bowtie()
    reffile = PARAMS["samtools_genome"]
    statement = m.build((infile, ), outfile)
    P.run()
def buildBAM(infile, outfile, options):
    '''map reads with bowtie'''
    job_threads = PARAMS["bowtie_threads"]
    m = PipelineMapping.Bowtie()
    reffile = PARAMS["samtools_genome"]
    bowtie_options = options
    statement = m.build((infile,), outfile)
    # print(statement)
    P.run()
Exemplo n.º 7
0
def alignReadsToTranscriptome(infile, outfile):
    '''map reads to transcriptome with bowtie'''
    track = P.snip(os.path.basename(outfile), ".bam")
    job_threads = PARAMS["bowtie_threads"]
    m = PipelineMapping.Bowtie()
    reffile = PARAMS["bowtie_transcriptome"]
    bowtie_options = PARAMS["bowtie_options"]
    statement = m.build((infile,), outfile)
    P.run()
Exemplo n.º 8
0
def buildBAM(infile, outfile, options):
    '''map reads with bowtie'''
    to_cluster = True
    job_options = "-pe dedicated %i -R y" % PARAMS["bowtie_threads"]
    m = PipelineMapping.Bowtie()
    reffile = PARAMS["samtools_genome"]
    bowtie_options = options
    statement = m.build((infile,), outfile)
    # print(statement)
    P.run()
Exemplo n.º 9
0
def mapReadsWithBowtieAgainstRayContigs(infile, outfile):
    '''
    map reads against contigs with bowtie
    '''
    PARAMS["bowtie_index_dir"] = "ray.dir"
    PARAMS["genome"] = TRACKS.getTracks(infile)[0].split(".")[0]

    infile, reffile = infile, os.path.join("ray.dir",
                                           TRACKS.getTracks(infile)[0])
    m = PipelineMapping.Bowtie(executable=P.substituteParameters(
        **locals())["bowtie_executable"])
    statement = m.build((infile, ), outfile)
    P.run()
Exemplo n.º 10
0
def run_mapping(infile, outfile):
    ''' Map reads using the selected read mapper '''

    job_threads = PARAMS["bowtie_threads"]
    job_memory = PARAMS["bowtie_memory"]

    m = PipelineMapping.Bowtie(
           executable="bowtie",
           tool_options=PARAMS["bowtie_options"],
           strip_sequence=0)

    genome = PARAMS["bowtie_genome"]
    reffile = os.path.join(PARAMS["bowtie_index_dir"],
                           PARAMS["bowtie_genome"] + ".fa")

    statement = m.build((infile,), outfile)

    P.run()
Exemplo n.º 11
0
def filterPhiX(infiles, outfile):
    ''' Use mapping to bowtie to remove any phiX mapping reads '''

    infile, reffile = infiles
    outfile = P.snip(outfile, ".gz")
    bam_out = P.snip(infile, ".fastq.gz") + ".phix.bam"

    job_threads = PARAMS["phix_bowtie_threads"]
    job_memory = PARAMS["phix_bowtie_memory"]
    options = PARAMS["phix_bowtie_options"] + " --un %s" % outfile
    genome = PARAMS["phix_genome"]
    bowtie_threads = PARAMS["phix_bowtie_threads"]

    m = PipelineMapping.Bowtie(executable=PARAMS["phix_bowtie_exe"],
                               strip_sequence=False,
                               remove_non_unique=False,
                               tool_options=options)

    statement = m.build((infile, ), bam_out)
    statement += "checkpoint; gzip %(outfile)s"

    P.run()