mhammell-laboratory / TEpeaks

Package for including repetitive regions in peak calling from ChIP-seq datasets
GNU General Public License v3.0
7 stars 4 forks source link

Segfault if there are more read 1 than read 2 entries for a pair #2

Open dpryan79 opened 4 years ago

dpryan79 commented 4 years ago

Currently if an aligner produces more alignments for read 1 than read 2 then TEpeaks will segfault. The following will patch that:

--- a/src/TEToolkit/Parser.cpp
+++ b/src/TEToolkit/Parser.cpp
@@ -245,7 +245,8 @@ void process_aligned_fragment(global_context_t<T> * global_context, thread_conte
             //get the first alignment of the first segment
             cur_read1 = (bam1_t *)read_pair->first_reads[k];

-            if (read_pair->second_reads.size() > 0) {
+            cur_read2 = NULL;
+            if (read_pair->second_reads.size() > k) {
                 //the first alignment of the second segment
                 cur_read2 = (bam1_t *)read_pair->second_reads[k];
             }

I'm not entirely sure why this scenario would arise, but one of our post-docs just managed to trigger it using a BAM file produced by STAR 2.6.0c