- vcfpy version: 0.13.3
- Python version: 3.6.1
- Operating System: Linux (Ubuntu)
Description
I'm having a hard time understanding why there is a mapping of escape characters, because when I write a vcf if I have some % in my fields, this gets changed to %25 instead of remaining as % like in the original. And I believe this can cause conflicts when using tools on the VCF with the field formatted like %25.
What I Did
I ran this custom function to split the VCF in samples.
def split_vcf(vcf_path):
reader_main = vcfpy.Reader.from_path(vcf_path)
samples = list(set([x.replace('NORMAL.', '').replace('TUMOR.', '') for x in reader_main.header.samples.names]))
reader_main.close()
for sample in samples:
reader_1 = vcfpy.Reader.from_path(vcf_path)
reader_2 = vcfpy.Reader.from_path(vcf_path)
header = reader_2.header
header.samples.names = [x for x in header.samples.names if x in [f'NORMAL.{sample}', f'TUMOR.{sample}']]
header.samples.name_to_idx = {x: header.samples.name_to_idx[x] for x in [f'NORMAL.{sample}', f'TUMOR.{sample}']}
writer = vcfpy.Writer.from_path('./{}.vcf'.format(sample), header)
for record in reader_1:
if any(sample == s for s in record.INFO['set'].split('-')):
writer.write_record(record)
writer.close()
Description
I'm having a hard time understanding why there is a mapping of escape characters, because when I write a vcf if I have some
%in my fields, this gets changed to%25instead of remaining as%like in the original. And I believe this can cause conflicts when using tools on the VCF with the field formatted like%25.What I Did
I ran this custom function to split the VCF in samples.