def removeEndGaps(self):

        pattern_start_gaps = re.compile("^([- ]+)")

        min_from = self.mLength
        max_to = 0

        for s in self.mMali.values():

            first = pattern_start_gaps.match(s.mString)
            if first:
                first = first.groups()[0]
                min_from = min(min_from, len(first))

            # search from the back end by reversing. This is much faster than
            # using $ from the back.
            last = pattern_start_gaps.search(s.mString[::-1])
            if last:
                last = last.groups()[0]
                max_to = max(max_to, len(s) - len(last))

        for s in self.mMali.values():
            s.mString = s.mString[min_from:max_to]

        self.mLength = min(map(lambda x: x.mString, self.mMali.values()))
remove end gaps.
dataset/ETHPy150Open CGATOxford/cgat/CGAT/Mali.py/Mali.removeEndGaps