def combine_vcfs(output_filename, input_vcf_filenames):
tmp_filename = output_filename + ".tmp"
for (i,fn) in enumerate(input_vcf_filenames):
if i == 0:
args = 'cat ' + fn
subprocess.check_call(args + " > " + tmp_filename, shell=True)
else:
args = 'grep -v "^#" ' + fn
ret = subprocess.call(args + " >> " + tmp_filename, shell=True)
if ret == 2:
raise Exception("grep call failed: " + args)
# Sort and index the files
tk_tabix.sort_vcf(tmp_filename, output_filename)
tk_tabix.index_vcf(output_filename)
os.remove(tmp_filename)
评论列表
文章目录