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
fragmentEnd = fragmentStart + abs(read.isize)


and the second

fragmentStart = read.reference_start
fragmentEnd = fragmentStart + abs(read.isize)


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 • 321 views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
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

ADD REPLY
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?

ADD REPLY
0
Entering edit mode

Thanks for the reply, will try that.

ADD REPLY
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)

ADD REPLY
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.

ADD REPLY

Login before adding your answer.

Traffic: 1188 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

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

Powered by the version 2.3.6