This is a simple software to calculate π value file from multiple sequence alignment fasta file.
Make sure you have JDK>=1.8 and ant installed on your computer.
git clone https://github.com/baoxingsong/MSA2pi.git
cd MSA2pi
ant
You will get MSA2pi.jar
java -jar MSA2pi.jar -i inputFile [-r reference sequence name]
The input file should be in multiple fasta format and aligned with multiple sequence alignment application.
For DNA sequence, if your sequence used wide IUPAC code (https://www.bioinformatics.org/sms/iupac.html)
and the reference sequence name is assigned in the parameter,
those ambiguous letters could be changed to the reference letter at the same position.
If the reference sequence name is no assigned, the ambiguous letters would be treated
in the same way with INDEL (-).
Nucleotide diversity, π, was defined as, the average number of nucleotide differences per site between two sequences. And it is a widely used measure for sequence conservation.
As the accumulation of our knowledge, we find it is controversial to calculate π value for INDELs. Especially when there are INDELs with positive overlap with each other, since we do not know the evolution process, it is not convincing to take each INDEL as a single variant. If we take the INDEL as missing value, and divide the total number of variants by the total sequence length, there would be bias. Since sequence_length*n*(n-1)/2 times of comparison have not been performed. And I did not find available application with detailed document about how to deal with INDELs for π value calculation, I decide to write this simple application.
For n sequences with length l, 1<=i<=l, we calculate total number of pair-wised variants at position i. We have the allele frequency fa,i for the allele a and total number of accession with no INDEL at position i, mi. Then Pi=sum(fa,i*(mi-fa,i)/2), Ni=mi*(mi-1)/2. And P=sum(Pi), N=sum(Ni).
π=P/N