コード例 #1
0
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
コード例 #2
0
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 = ''
コード例 #3
0
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=''
コード例 #4
0
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
コード例 #5
0
ファイル: run_BWA_commands.py プロジェクト: tcezard/RADmapper
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
コード例 #6
0
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'
コード例 #7
0
ファイル: __init__.py プロジェクト: tcezard/RADmapper
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'
コード例 #8
0
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=''
コード例 #9
0
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
コード例 #10
0
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
コード例 #11
0
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)
コード例 #12
0
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
コード例 #13
0
ファイル: __init__.py プロジェクト: tcezard/RADmapper
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'
コード例 #14
0
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'
コード例 #15
0
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'
コード例 #16
0
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)
コード例 #17
0
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)
コード例 #18
0
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)
コード例 #19
0
ファイル: run_BWA_commands.py プロジェクト: tcezard/RADmapper
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
コード例 #20
0
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'
コード例 #21
0
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
コード例 #22
0
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