nloyfer / wgbs_tools

tools for working with Bisulfite Sequencing data while preserving reads intrinsic dependencies
Other
134 stars 37 forks source link

Missing last CPG site in chromosome #42

Closed linhxxx closed 1 year ago

linhxxx commented 1 year ago

In patter.cpp, line 95-100, a bool array is constructed. If the last loci is 100 (bsize==100), the bool array should be constructed in a 100 + 1 size. If we make a bool array with 100 elements, we cant access the conv[100].

bsize = loci.at(loci.size() - 1);    

conv = new bool[bsize]();   -->  conv = new bool[(bsize + 1)]();
for (int locus: loci) {
    conv[locus] = true;
}

In line 254, we also need add 1 to make the code assess to the last locus of the chromosome:

    if ((start_locus + i) > (bsize - 1)) {           --->  if ((start_locus + i) > (bsize - 1 + 1)) {
        continue;  
    }
nloyfer commented 1 year ago

Thank you @HaoxiangLin! You are correct, of course. I fixed it.