bedtools shift -s with -pct is dysfunctional

I used the following commands:

bedtools shift -i ENCFF219OVU.bed -g mus_musculus.genome -s 0.5 -pct > peaks_centered.bed

However, peaks_centered.bed was the exact same as ENCFF219OVU.bed. I went into the source code and identified the issue. The shift is stored in an integer value. Therefore, the float value 0.5 is lost. I made the following changes in the /src/shiftBed/shiftBed.cpp file.

void BedShift::AddShift(BED &bed) {

  CHRPOS chromSize = (CHRPOS)_genome->getChromSize(bed.chrom);

  double input_shift;
  CHRPOS shift;

  if (bed.strand == “-“) {
    input_shift = _shiftMinus;
  } else {
    input_shift = _shiftPlus;

  }
  if (_fractional == true) {
    shift = input_shift * (double)bed.size();
  } else {
    shift = (CHRPOS)shift;
  }

  if ((bed.start + shift) < 0)
    bed.start = 0;
  else if ((bed.start + shift) > (chromSize – 1))
    bed.start = (chromSize – 1);
  else
    bed.start = bed.start + shift;

  if ((bed.end + shift) <= 0)
    bed.end = 1;
  else if ((bed.end + shift) > chromSize)
    bed.end = chromSize;
  else
    bed.end = bed.end + shift;
}

Read more here: Source link