def call_gt(bam_path, search_threshold, chr, read_id_list, max_cluster_bias, gt_round): import pysam querydata = set() bamfile = pysam.AlignmentFile(bam_path) search_start = max(int(search_threshold) - max_cluster_bias, 0) search_end = min( int(search_threshold) + max_cluster_bias, bamfile.get_reference_length(chr)) up_bound = threshold_ref_count(len(read_id_list)) status = count_coverage(chr, search_start, search_end, bamfile, querydata, up_bound, gt_round) bamfile.close() if status == -1: DR = '.' GT = "./." GL = ".,.,." GQ = "." QUAL = "." # elif status == 1: # pass else: DR = 0 for query in querydata: if query not in read_id_list: DR += 1 GT, GL, GQ, QUAL = cal_GL(DR, len(read_id_list)) return len(read_id_list), DR, GT, GL, GQ, QUAL
def call_gt(bam_path, pos_1, pos_2, chr_1, chr_2, read_id_list, max_cluster_bias, gt_round): import pysam bamfile = pysam.AlignmentFile(bam_path) querydata = set() search_start = max(int(pos_1) - max_cluster_bias, 0) search_end = min( int(pos_1) + max_cluster_bias, bamfile.get_reference_length(chr_1)) up_bound = threshold_ref_count(len(read_id_list)) status = count_coverage(chr_1, search_start, search_end, bamfile, querydata, up_bound, gt_round) if status == -1: DR = '.' GT = "./." GL = ".,.,." GQ = "." QUAL = "." elif status == 1: DR = 0 for query in querydata: if query not in read_id_list: DR += 1 GT, GL, GQ, QUAL = cal_GL(DR, len(read_id_list)) else: search_start = max(int(pos_2) - max_cluster_bias, 0) search_end = min( int(pos_2) + max_cluster_bias, bamfile.get_reference_length(chr_2)) status_2 = count_coverage(chr_2, search_start, search_end, bamfile, querydata, up_bound, gt_round) # status_2 judgement DR = 0 for query in querydata: if query not in read_id_list: DR += 1 GT, GL, GQ, QUAL = cal_GL(DR, len(read_id_list)) bamfile.close() return len(read_id_list), DR, GT, GL, GQ, QUAL