# Minimap2 -ax map-pb doesn't output tlen field

I have used minimap2 to map some pacbio reads to a reference genome. I would like to know the "insert size" (true length of sequence) relative to the reference. More specifically, I want to know the first base position in the reference where the read maps and the last base position in the reference where the mapping ends.

As I understand it I need the TLEN field from bam files (sam format field 9). However, all the alignment files from minimap2 have 0 in the TLEN field.

Does anyone know how to get pacbio alignments with the TLEN field? I am also happy using bwa or another aligner.

The command I used was minimap2 -ax map-pb {fasta} {reads} | samtools view -h -b - | samtools sort - > myfile.bam.

import pysam

The reference_end value is automatically calculated from the CIGAR string.