def make_mix(input1, input2, mixtures): """ Create mix of input files for mixtures""" uid1 = get_uid(input1) uid2 = get_uid(input2) input_root = uid1 + "-" + uid2 subprocess.call(["mkdir", "-p", input_root]) # mix_sam_list = [] for i in mixtures: mix_root = input_root + "/" + input_root + "_" + str(i) subprocess.call(["mkdir", "-p", mix_root + "/tmp"]) subprocess.call(["mkdir", "-p", mix_root + "/logs"]) out_root_name = input_root + "_" + str(i) + ".sam" output1 = mix_root + "/tmp/Sample_" + out_root_name output2 = mix_root + "/tmp/Contam_" + out_root_name mix_out = mix_root + "/" + input_root + "_" + str(i) + ".sam" # mix_sam_list.append([mix_out, input_root + "_" + str(i)]) out1_file = open(output1, "w") out2_file = open(output2, "w") subprocess.call(["samtools", "view", "-Sh", "-s", str(i), input1], stdout=out1_file) assert os.path.isfile(output1), "File %s not found" % output1 subprocess.call(["samtools", "view", "-Sh", "-s", str(1 - i), input2], stdout=out2_file) assert os.path.isfile(output2), "File %s not found" % output2 append_sam_file(mix_out, [output1, output2]) assert os.path.isfile(mix_out), "File %s not found" % mix_out subprocess.call(["rm", "-r", mix_root + "/tmp"]) pathoid_command(mix_out, "", input_root + str(i))
def mix_pathoid(mix_sam): mix_id = mix_sam.re.replace(".sam", "-sam-report.tsv") pathoid_command(mix_sam, mix_id) assert os.path.isfile(mix_id), "File %s not found" % mix_id