]> git.donarmstrong.com Git - samtools.git/blobdiff - bam2bcf_indel.c
Fix to prevent long stretches of Ns to be mistaken for indels; Always output the...
[samtools.git] / bam2bcf_indel.c
index 5142b3e100aa96a7ab598a95b9953aa4c6034289..11cd371978e6e654987d35c35dd6465539a22523 100644 (file)
@@ -161,6 +161,11 @@ int bcf_call_gap_prep(int n, int *n_plp, bam_pileup1_t **plp, int pos, bcf_calla
                                if (j > max_rd_len) max_rd_len = j;
                        }
                }
+        // To prevent long stretches of N's to be mistaken for indels (sometimes thousands of bases),
+        //  check the number of N's in the sequence. TODO: this may not be the best place and the best way of doing it
+        int nN=0; for (i=0; i<max_rd_len && ref[i]; i++) if ( ref[i]=='N' ) nN++;
+        if ( nN*2>i ) return -1;
+
                ks_introsort(uint32_t, m, aux);
                // squeeze out identical types
                for (i = 1, n_types = 1; i < m; ++i)