for line in STATS_HEADER: combined_f.write(line) # write the chr\tpos\t... line combined_f.write(vcf_list[0].header) # Write the variants for v_key in combined_variants: callers_indexes = variant_to_vcf_dict[v_key] callers_names = [callers[i] for i in callers_indexes] info_dict = OrderedDict() for i in callers_indexes: # Combine the selected information in the dictionary info_dict.update(vcf_list[i].variants[v_key].info) i = callers_indexes[0] combined_variant = Variant.combine_info( vcf_list[i].variants[v_key], columns_to_keep, callers_names, info_dict) combined_f.write(Variant.write(combined_variant)) else: # Process each vcf and extract the information from the selected columns vcf_list = [ NormalisedVcf(vcf).process_somatic_vcf(columns_to_keep, normal_id, tumor_id) for vcf in vcf_in ] # Combine the variants into a list combined_variants, variant_to_vcf_dict = [], dd(list) callers = [vcf.caller for vcf in vcf_list]