full_annots = full_annots.groupby('ID').agg(col_operations) full_annots.index = full_annots.index.map(str) #Add the annotations and write new VCF step_time = time.time() start_annot_time = time.time() logger.info("### ADD ANNOTATIONS TO OUTPUT VCF ###") logger.info("Output file: %s", out_filename) outfile = open(out_filename, "w+") if args.inputvcf.endswith("vcf.gz"): vcf = gzip.open(args.inputvcf, "rt") elif args.inputvcf.endswith("vcf"): vcf = open(args.inputvcf, "r") line = vcf.readline() while line.startswith('##'): outfile.write(line) line = vcf.readline() #Add INFO tags descriptions to header for tag, data_type in tags_dataTypes.items(): header_line = '##INFO=<ID={tag},Number=1,Type={datatype},Description="SV annotation">'.format( tag=tag, datatype=data_type) outfile.write(header_line + "\n") while line.startswith('#'): outfile.write(line) line = vcf.readline() #Annotate vars