def call_after_mapping(working_dir, prefix, bam_or_fastq, sample_dict,
                       ped_type):
    os.chdir(working_dir)
    print 'hello'
    ##variant calling
    make_list_of_bams(sample_dict, final_bam_suffix, bamlist)
    variant_calling_freebayes(bamlist, prefix)
    variant_calling_gatk_hc_no_gvcf(bamlist, prefix)
    intesect_two_vcf_files(prefix + '.gatkHC.vcf.gz',
                           prefix + '.freebayes.vcf.gz',
                           prefix + '.intersected_vcfs')
    ##coverage
    calculate_exome_coverage(sample_dict, final_bam_suffix,
                             exome_bed_for_coverage, prefix)
    ##plink for sex and relatedness -- work in progress
    plink_relatadness_check(prefix + '.intersected_vcfs/0002.vcf', prefix)
    ##delete unwanted files
    delete_unwated_files([
        '*.r1.fastq', '*.r2.fastq', '*.bwa.bam', '*.bwa_sort.bam', '*.metrics',
        '*.bwa_religned.bam', '*.bwa_religned.bai', '*.recal_data.table',
        '*temp*', '*bwa_mkdup.bai', '*bwa_mkdup.bam'
    ])
    ##run gemini
    dobyns_gemini_pipeline_cybertron_v8.standard_gemini_protocol(
        working_dir, prefix, ped_type)
def call_all_exome_methods_inc_gemini(working_dir, prefix, bam_or_fastq,
                                      sample_dict, ped_type):
    os.chdir(working_dir)
    ##covert bam to fastq and then process
    # '''
    if bam_or_fastq == 'bam':
        for sample in sample_dict:
            read1_fastq = sample + '.r1.fastq'
            read2_fastq = sample + '.r2.fastq'
            # convert_bam_fastq_bedtools(sample_dict[sample], read1_fastq, read2_fastq)
            convert_bam_fastq_picard(sample_dict[sample], read1_fastq,
                                     read2_fastq)
            align_with_bwa_one_at_time(sample, read1_fastq, read2_fastq)
    elif bam_or_fastq == 'messy_bam':
        for sample in sample_dict:
            read1_fastq = sample + '.r1.fastq'
            read2_fastq = sample + '.r2.fastq'
            convert_bam_fastq_bedtools(sample_dict[sample], read1_fastq,
                                       read2_fastq)
            align_with_bwa_one_at_time(sample, read1_fastq, read2_fastq)
    elif bam_or_fastq == 'fastq':
        for sample in sample_dict:
            read1_fastq = sample_dict[sample][0]
            read2_fastq = sample_dict[sample][1]
            align_with_bwa_one_at_time(sample, read1_fastq, read2_fastq)
            ##single fq
            # align_with_bwa_one_at_time_single_end(sample,sample_dict[sample])
    else:
        print 'must specify if starting with fastq or bam file'
    # '''
    ##variant calling
    make_list_of_bams(sample_dict, final_bam_suffix, bamlist)
    variant_calling_freebayes(bamlist, prefix)
    variant_calling_gatk_hc_no_gvcf(bamlist, prefix)
    intesect_two_vcf_files(prefix + '.gatkHC.vcf.gz',
                           prefix + '.freebayes.vcf.gz',
                           prefix + '.intersected_vcfs')
    ##coverage
    calculate_exome_coverage(sample_dict, final_bam_suffix,
                             exome_bed_for_coverage, prefix)
    ##plink for sex and relatedness -- work in progress
    plink_relatadness_check(prefix + '.intersected_vcfs/0002.vcf', prefix)
    ##delete unwanted files
    delete_unwated_files([
        '*.r1.fastq', '*.r2.fastq', '*.bwa.bam', '*.bwa_sort.bam', '*.metrics',
        '*.bwa_religned.bam', '*.bwa_religned.bai', '*.recal_data.table',
        '*temp*', '*bwa_mkdup.bai', '*bwa_mkdup.bam'
    ])
    ##run gemini
    dobyns_gemini_pipeline_cybertron_v8.standard_gemini_protocol(
        working_dir, prefix, ped_type)
def intersect_vcfs_and_gemini(working_dir, prefix, bam_or_fastq, sample_dict,
                              ped_type):
    os.chdir(working_dir)
    intesect_two_vcf_files(prefix + '.gatkHC.vcf.gz',
                           prefix + '.freebayes.vcf.gz',
                           prefix + '.intersected_vcfs')
    ##coverage
    # calculate_exome_coverage(sample_dict, final_bam_suffix, exome_bed_for_coverage, prefix)
    ##plink for sex and relatedness -- work in progress
    plink_relatadness_check(prefix + '.intersected_vcfs/0002.vcf', prefix)
    ##delete unwanted files
    # delete_unwated_files(['*.r1.fastq', '*.r2.fastq', '*.bwa.bam', '*.bwa_sort.bam', '*.metrics', '*.bwa_religned.bam', '*.bwa_religned.bai', '*.recal_data.table', '*temp*', '*bwa_mkdup.bai', '*bwa_mkdup.bam'])
    ##run gemini
    dobyns_gemini_pipeline_cybertron_v8.standard_gemini_protocol(
        working_dir, prefix, ped_type)
def call_just_gemini(working_dir, prefix, bam_or_fastq, sample_dict, ped_type):
    os.chdir(working_dir)
    print 'hello'
    ##run gemini
    dobyns_gemini_pipeline_cybertron_v8.standard_gemini_protocol(
        working_dir, prefix, ped_type)