An update after more discussion of the issue: I was not correct about the patch being a no-op. Due to monotonization, it may happen that
q[i - 1] > q[i] but cumsum[i-1] == cumsum[i]. I think I understand what you mean now. Indeed, if there is a local minimum on the curve of FDRs, the calculation procedure will monotonize the q-values so that the minimal value is propagated all the way up until FDR goes even lower.
I believe this is in accordance with the adopted definition of q value as "the minimal FDR at which a PSM is accepted" [1]. This behavior is also consistent with our description of the procedure in [2].
The suggested patch, on the other hand, seems to break the monotonicity of q values. Here's an (poorly plotted) example, where each green line is a target PSM and each red one is a decoy, sorted PSMs go from left to right:
[1]
Käll, L., Storey, J. D., MacCoss, M. J., & Noble, W. S. (2008). Posterior error probabilities and false discovery rates: Two sides of the same coin. Journal of Proteome Research, 7, 40–44. http://doi.org/10.1021/pr700739d[2]
Levitsky, L. I., Ivanov, M. V., Lobas, A. A., & Gorshkov, M. V. (2017). Unbiased False Discovery Rate Estimation for Shotgun Proteomics Based on the Target-Decoy Approach. Journal of Proteome Research, 16(2), 393–397. http://doi.org/10.1021/acs.jproteome.6b00144
Best regards,
Lev