You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()
The text was updated successfully, but these errors were encountered:
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.
The text was updated successfully, but these errors were encountered: