def savitzky_golay_order2(signal, window_size, deriv=0):
    if window_size % 2 != 1: window_size += 1
    half_window = (window_size - 1) / 2
    # precompute coefficients
    b = np.mat([[1, k, k**2] for k in range(-half_window, half_window+1)],
               dtype='int64')
    m = np.linalg.pinv(b).A[deriv]
    # pad the signal at the extremes with
    # values taken from the signal itself
    firstvals = signal[0] - np.abs(signal[1:half_window+1][::-1] - signal[0])
    lastvals = signal[-1] + np.abs(signal[-half_window-1:-1][::-1] - signal[-1])
    signal = np.concatenate((firstvals, signal, lastvals))
    ret = np.convolve( m, signal.astype('float64'), mode='valid').astype('float32')
    return ret
%prog filter gffile > filtered.gff
dataset/ETHPy150Open taoliu/MACS/test/test_callsummits.py/savitzky_golay_order2--crossover with--dataset/ETHPy150Open tanghaibao/jcvi/formats/gff.py/filter