Hi All, I am working with a BAM file generated using cell ranger. I am trying to edit the BAM file where i want the cell barcode and UMI to be added to the read name. The cell barcode is provided in CR tag and error corrected cell barcode is provided in CB tag. Similarly, for UMI, UR is UMI and UB is error corrected. I am using pysam to to edit the BAM file.
bamfile = pysam.AlignmentFile("sample.bam", "rb")
for read in bamfile.fetch('chr1',100,1000):
if read.has_tag('CB'):
CB=read.get_tag('CB')
UB=read.get_tag('UB')
EditedReadName=read.query_name+'_'+CB.split('-')[0]+'_'+UBenter code here
Now i wanted to add the other columns of the read (as it is) to the edited read name. I tried to split the line but the pysam.libcalignedsegment.AlignedSegment' object has no attribute split. Any help? Thanks in advance!
Thank you Geek for your suggestion!
Please accept the answer if it solved your issue. Otherwise it will bump into feed in future unnecessarily .