Convert VCF to TAB user Kantale
From PyPedia
Contents |
[edit] Documentation
Documentation for Convert VCF to TAB
[edit] Parameters
<inputs> </inputs>
[edit] Return
[edit] See also
[edit] Code
def Convert_VCF_to_TAB_user_Kantale( input_filename = None, output_filename = None, print_header = True, ): input_file = open(input_filename) output_file = open(output_filename, "w") header = ["CHROM", "POS", "ID", "REF", "ALT"] while True: line = input_file.readline() if not line: break ls = line.split() if ls[0] == "#CHROM": samples_n = len(ls) - 9 header += ls[9:] if print_header: output_file.write(str.join("\t", header) + "\n") continue if ls[0][0] == "#": continue to_print = [ls[0], ls[1], ls[2], ls[3], ls[4]] format = ls[8] format_s = format.split(":") format_index = format_s.index("GT") for gtf in ls[9:]: gt = gtf.split(":")[format_index] gt1 = gt[0] phase = gt[1] gt2 = gt[2] tab_gt = [] for gts in [gt1, gt2]: if gts == "0": tab_gt += [ls[3]] else: tab_gt += [ls[4][int(gts)-1]] to_print += [str.join(phase, tab_gt)] output_file.write(str.join("\t", to_print) + "\n") output_file.close() input_file.close()
[edit] Unit Tests
def uni1(): return True
[edit] Development Code
def Convert_VCF_to_TAB_user_Kantale(): pass
[edit] Permissions
[edit] Documentation Permissions
Kantale
[edit] Code Permissions
Kantale
[edit] Unit Tests Permissions
Kantale