I try to understand a number theoretical identity used by Jan-Christoph Schlage-Puchta in this answer.
He defined the function
$$S(\alpha)=\sum_{n\leq N}\Lambda(n) e(n\alpha)$$
where $\Lambda(n)$ is the Mangoldt function and $e(x)$ the exponential $e(x)=e^{2\pi i x}$.
Assume $\alpha=\frac{p}{q}$ is rational, and $p:= p_1 p_2...p_n$ and $q:= q_1 ...p_m$ are coprime positive integers where $p_i$ and $q_j$ are primes such that every pair $p_i, q_j$ is pair wise different.
Why the following identity is true:
$$\sum_{n\leq N}\Lambda(n) e(n\alpha) = \sum_{(a,q)=1} e(\frac{ap}{q})\underset{n\equiv a\pmod{q}}{\sum_{n\leq N}} \Lambda(n)$$