Entering edit mode
2.1 years 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.
would
bedtools bamtobed
get you what you want? https://bedtools.readthedocs.io/en/latest/content/tools/bamtobed.htmlActually, 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
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?
Thanks for the reply, will try that.
Do you need to to this in python? There are tools already out there performing these kind of tasks, such as CollectInsertSizeMetrics (picard)
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.