Calculating fragment start and end in python
0
0
Entering edit mode
7 weeks ago
mhasa006 ▴ 70

I'm trying to calculate the fragment information for Illumina pair-end sequences. For that, I need to calculate the fragment start and fragment end. There are two ways I'm calculating the fragment start/end

fragmentStart = min(read.pos, read.pnext) + 1


and the second

fragmentStart = read.reference_start


Can anybody tell me which one is the correct way? Also, how can I verify the numbers I'm getting? Currently, I'm trying to manually check the BAM files to find the positions.

python insert fragment • 322 views
0
Entering edit mode

would bedtools bamtobed get you what you want? https://bedtools.readthedocs.io/en/latest/content/tools/bamtobed.html

0
Entering edit mode

Actually, I'm fetching reads form a BAM file that is within a bed region. Then I'm trying to calculate the fragment start/end of the fetched reads

0
Entering edit mode

how about filtering the BAM file for the region on interest and then converting the output to a BED file which will contain the read start and stop coordinates?

0
Entering edit mode

Thanks for the reply, will try that.

0
Entering edit mode

Do you need to to this in python? There are tools already out there performing these kind of tasks, such as CollectInsertSizeMetrics (picard)

0
Entering edit mode

Well, that is true, but it is part of a bigger project. And calling third-party tools can be problematic. Either way, thanks for the reply.