Skip to content
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (46 sloc) 1.88 KB
"""Next gen sequence alignments with Bowtie (
import os
import subprocess
from bcbio.utils import file_exists
from bcbio.distributed.transaction import file_transaction
galaxy_location_file = "bowtie_indices.loc"
def _bowtie_args_from_config(config):
"""Configurable high level options for bowtie.
qual_format = config["algorithm"].get("quality_format", None)
if qual_format is None or qual_format.lower() == "illumina":
qual_flags = ["--phred64-quals"]
qual_flags = []
multi_mappers = config["algorithm"].get("multiple_mappers", True)
multi_flags = ["-M", 1] if multi_mappers else ["-m", 1]
cores = config.get("resources", {}).get("bowtie", {}).get("cores", None)
core_flags = ["-p", str(cores)] if cores else []
return core_flags + qual_flags + multi_flags
def align(fastq_file, pair_file, ref_file, out_base, align_dir, config,
extra_args=None, rg_name=None):
"""Do standard or paired end alignment with bowtie.
out_file = os.path.join(align_dir, "%s.sam" % out_base)
if not file_exists(out_file):
with file_transaction(out_file) as tx_out_file:
cl = [config["program"]["bowtie"]]
cl += _bowtie_args_from_config(config)
cl += extra_args if extra_args is not None else []
cl += ["-q",
"-v", config["algorithm"]["max_errors"],
"-k", 1,
"-X", 2000, # default is too selective for most data
if pair_file:
cl += ["-1", fastq_file, "-2", pair_file]
cl += [fastq_file]
cl += [tx_out_file]
cl = [str(i) for i in cl]
return out_file
Jump to Line
Something went wrong with that request. Please try again.