Add Cigar string and Template Length to Read Name
Entering edit mode
7 months ago
Leendert ▴ 30

Hi all,

I need to convert a BAM file to Fastq format, but I don't want to loose the Cigar and TLen information.

My idea is to edit each read name in the BAM file, by appending both Cigar and TLen to the current read name, so that this information can go across to Fastq file. I can then parse these read names later, and split on separator to extract this information.

I couldn't come across any software that can do this. So my thoughts are to use pysam, but this seems to be the long way round.

I'm thinking something like samtools | awk | sed might be quicker, but I'm still getting to know these tools in bash.

Can anyone suggest any tools that might help to do this, or point me in the right direction for the bash | pysam commands?

pysam bam sed awk python • 300 views
Entering edit mode
7 months ago

using samjdk:

java -jar dist/samjdk.jar -e 'record.setReadName(record.getReadName()+":"+record.getCigarString()+":"+record.getInferredInsertSize() ); return record;'  in.bam |samtools sort -n | samtools fastq

Login before adding your answer.

Traffic: 866 users visited in the last hour
Help About
Access RSS

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6