Hi Biostars community,
Is there an analogous way in Pysam to the code below to extract the header information in .bam and .vcf (or .vcf.gz) files? Help with a code snippet will great. The code snippet below uses exifread library to get the meta-info (in key-value pair) in jpeg and tiff files.
import exifreaddef acPostProcForPut(rule_args, callback, rei): sv = session_vars.get_map(rei) phypath = sv['data_object']['file_path'] objpath = sv['data_object']['object_path'] exiflist = [] with open(phypath, 'rb') as f: tags = exifread.process_file(f, details=False) for (k, v) in tags.iteritems(): if k not in ('JPEGThumbnail', 'TIFFThumbnail', 'Filename', 'EXIF MakerNote'): exifpair = '{0}={1}'.format(k, v) exiflist.append(exifpair) exifstring = '%'.join(exiflist) <post>
did you read the doc ? https://pysam.readthedocs.io/en/latest/api.html#pysam.AlignmentFile
Thanks for posting the link. I read it, but I didn't get how to remove the "@" in .bam and "##" in vcf file. I was hoping that someone who knows better can help. Here is my approach:
Could you please give an example how your output should look like?