def run_BWA_Command_for_RAD(genome_file, fastq_file1, fastq_file2=None, output_dir=None, sample_name=None, clean_up=True, thread=1, read_group=None, illumina=False, fifo=False): run_fine = True try: pipeline_param = utils_param.get_pipeline_parameters() BWA_dir = pipeline_param.get_bwa_dir() samtools_dir = pipeline_param.get_samtools_dir() picard_dir = pipeline_param.get_picard_dir() #get the path to the current script to infer the path to RAD_set_read1_consensus_to_read2.py script_dir = os.path.dirname(os.path.realpath(__file__)) path_to_script = os.path.join(script_dir, "RAD_set_read1_consensus_to_read2.py") if not os.path.exists(path_to_script): logging.warning( "Can't find RAD_set_read1_consensus_to_read2.py which is required" ) path_to_script = "RAD_set_read1_consensus_to_read2.py" except Config_file_error, e: #logging.exception('Config_file_error:') logging.critical( "You need to have the environment variable properly set to use that script" ) return False
def run_stats_from_bam(bam_file): try: pipeline_param = utils_param.get_pipeline_parameters() samtools_dir = pipeline_param.get_samtools_dir() except Config_file_error, e: logging.warning("You'll need to have samtools in your path") samtools_dir = ''
def run_stats_from_bam(bam_file): try: pipeline_param=utils_param.get_pipeline_parameters() samtools_dir=pipeline_param.get_samtools_dir() except Config_file_error, e: logging.warning("You'll need to have samtools in your path") samtools_dir=''
def prepare_genome(genome_file, color_space=False): run_fine = True pipeline_param = utils_param.get_pipeline_parameters() BWA_dir = pipeline_param.get_bwa_dir() BWA_bin = os.path.join(BWA_dir, 'bwa') genome_loader = GenomeLoader(genome_file=genome_file) length = 0 for fasta_rec in genome_loader: header, sequence = fasta_rec length += len(sequence) if length > 1000000000: break genome_loader.close() #Following recommendation set the indexing algorithm to is if genome is <10M if length > 1000000000: a_option = 'bwtsw' else: a_option = 'is' #Create the indexes if color_space: command = '%s index -c -a %s %s' % (BWA_bin, a_option, genome_file) else: command = '%s index -a %s %s' % (BWA_bin, a_option, genome_file) command_runner.run_command(command) return run_fine
def prepare_genome(genome_file,color_space=False): run_fine=True pipeline_param=utils_param.get_pipeline_parameters() BWA_dir=pipeline_param.get_bwa_dir() BWA_bin=os.path.join(BWA_dir,'bwa') genome_loader = GenomeLoader(genome_file=genome_file) length=0 for fasta_rec in genome_loader: header, sequence = fasta_rec length+=len(sequence) if length>1000000000: break genome_loader.close() #Following recommendation set the indexing algorithm to is if genome is <10M if length>1000000000: a_option='bwtsw' else: a_option='is' #Create the indexes if color_space: command='%s index -c -a %s %s'%(BWA_bin, a_option, genome_file) else: command='%s index -a %s %s'%(BWA_bin, a_option, genome_file) command_runner.run_command(command) return run_fine
def get_mpileup_from_bam(bam_file, options=''): try: pipeline_parm=utils_param.get_pipeline_parameters() samtools_bin=os.path.join(pipeline_parm.get_samtools_dir(),'samtools') except Config_file_error, e: logging.warning("Can't find the configuration file you'll need to have samtools in you path.") samtools_bin='samtools'
def index_bam_file(bam_file, samtools_bin=None): if samtools_bin==None: try: pipeline_parm=utils_param.get_pipeline_parameters() samtools_bin=os.path.join(pipeline_parm.get_samtools_dir(),'samtools') except Config_file_error, e: logging.warning("Can't find the configuration file you'll need to have samtools in you path.") samtools_bin='samtools'
def RAD_median_coverage(bam_files,output_file): try: pipeline_param=utils_param.get_pipeline_parameters() samtools_dir=pipeline_param.get_samtools_dir() except Config_file_error, e: #logging.exception('Config_file_error:') logging.warning("You'll need to have samtools in your path") samtools_dir=''
def set_read1_consensus_to_read2_old(input_bam_file, output_bam_file): try: pipeline_param=utils_param.get_pipeline_parameters() samtools_dir=pipeline_param.get_samtools_dir() except Config_file_error, e: #logging.exception('Config_file_error:') logging.critical("You need to have the environment variable properly set to use that script") return False
def mark_duplicate(bam_file, distance_threshold=5): try: pipeline_param = utils_param.get_pipeline_parameters() samtools_dir = pipeline_param.get_samtools_dir() picard_dir = pipeline_param.get_picard_dir() except Config_file_error, e: logging.warning("You'll need to have samtools in your path") samtools_dir = '' picard_dir = None
def run_alignment(consensus_file, read1_fastq, read2_fastq, single_fastq, all_read_groups, snp_call=False): try: pipeline_param = utils_param.get_pipeline_parameters() picard_dir = pipeline_param.get_picard_dir() # GATK_dir=pipeline_param.get_gatk_dir() samtools_dir = pipeline_param.get_samtools_dir() except Config_file_error, e: logging.exception('Config_file_error:') sys.exit(1)
def mark_duplicate(bam_file, distance_threshold=5): try: pipeline_param=utils_param.get_pipeline_parameters() samtools_dir=pipeline_param.get_samtools_dir() picard_dir=pipeline_param.get_picard_dir() except Config_file_error, e: logging.warning("You'll need to have samtools in your path") samtools_dir='' picard_dir=None
def get_sam_stream(bam_file, samtools_bin=None, options='', chomosome_and_position=''): """This method opens a .bam file with samtools and returns an open file. The std error will be output in the console through another thread.""" if samtools_bin==None: try: pipeline_parm=utils_param.get_pipeline_parameters() samtools_bin=os.path.join(pipeline_parm.get_samtools_dir(),'samtools') except Config_file_error, e: logging.warning("Can't find the configuration file you'll need to have samtools in you path.") samtools_bin='samtools'
def get_mpileup_from_bam(bam_file, options=''): try: pipeline_parm = utils_param.get_pipeline_parameters() samtools_bin = os.path.join(pipeline_parm.get_samtools_dir(), 'samtools') except Config_file_error, e: logging.warning( "Can't find the configuration file you'll need to have samtools in you path." ) samtools_bin = 'samtools'
def index_bam_file(bam_file, samtools_bin=None): if samtools_bin == None: try: pipeline_parm = utils_param.get_pipeline_parameters() samtools_bin = os.path.join(pipeline_parm.get_samtools_dir(), 'samtools') except Config_file_error, e: logging.warning( "Can't find the configuration file you'll need to have samtools in you path." ) samtools_bin = 'samtools'
def run_all_snps_call(directory): directory = os.path.abspath(directory) all_dirs = glob(os.path.join(directory, '*_dir')) GATK_dir = None try: pipeline_param = utils_param.get_pipeline_parameters() picard_dir = pipeline_param.get_picard_dir() GATK_dir = pipeline_param.get_gatk_dir() samtools_dir = pipeline_param.get_samtools_dir() samtools_bin = os.path.join(samtools_dir, 'samtools') except Config_file_error, e: logging.exception('Config_file_error:') sys.exit(1)
def run_BWA_Command(genome_file, fastq_file1, fastq_file2=None, output_dir=None, sample_name=None, clean_up=True, sort=False, thread=1, analysis_type=None, read_group=None, illumina=False): run_fine=True try: pipeline_param=utils_param.get_pipeline_parameters() BWA_dir=pipeline_param.get_bwa_dir() samtools_dir=pipeline_param.get_samtools_dir() picard_dir=pipeline_param.get_picard_dir() except Config_file_error, e: logging.exception('Config_file_error:') logging.warning("You'll need to have bwa and samtools in your path") BWA_dir='' samtools_dir='' picard_dir=None
def get_sam_stream(bam_file, samtools_bin=None, options='', chomosome_and_position=''): """This method opens a .bam file with samtools and returns an open file. The std error will be output in the console through another thread.""" if samtools_bin == None: try: pipeline_parm = utils_param.get_pipeline_parameters() samtools_bin = os.path.join(pipeline_parm.get_samtools_dir(), 'samtools') except Config_file_error, e: logging.warning( "Can't find the configuration file you'll need to have samtools in you path." ) samtools_bin = 'samtools'
def run_BWA_Command_for_RAD(genome_file, fastq_file1, fastq_file2=None, output_dir=None, sample_name=None, clean_up=True, thread=1, read_group=None, illumina=False, fifo=False): run_fine=True try: pipeline_param=utils_param.get_pipeline_parameters() BWA_dir=pipeline_param.get_bwa_dir() samtools_dir=pipeline_param.get_samtools_dir() picard_dir=pipeline_param.get_picard_dir() #get the path to the current script to infer the path to RAD_set_read1_consensus_to_read2.py script_dir = os.path.dirname(os.path.realpath(__file__)) path_to_script = os.path.join(script_dir,"RAD_set_read1_consensus_to_read2.py") if not os.path.exists(path_to_script): logging.warning("Can't find RAD_set_read1_consensus_to_read2.py which is required") path_to_script = "RAD_set_read1_consensus_to_read2.py" except Config_file_error, e: #logging.exception('Config_file_error:') logging.critical("You need to have the environment variable properly set to use that script") return False
def run_BWA_Command(genome_file, fastq_file1, fastq_file2=None, output_dir=None, sample_name=None, clean_up=True, sort=False, thread=1, analysis_type=None, read_group=None, illumina=False): run_fine = True try: pipeline_param = utils_param.get_pipeline_parameters() BWA_dir = pipeline_param.get_bwa_dir() samtools_dir = pipeline_param.get_samtools_dir() picard_dir = pipeline_param.get_picard_dir() except Config_file_error, e: logging.exception('Config_file_error:') logging.warning("You'll need to have bwa and samtools in your path") BWA_dir = '' samtools_dir = '' picard_dir = None