Created
October 13, 2022 05:19
-
-
Save rknx/3d3ad3b93ad963be84d7f2840486e07f to your computer and use it in GitHub Desktop.
Pairwise mismatch count from multifasta alignment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
######################################### | |
# Anuj Sharma # | |
# rknx@outlook.com # | |
# 2022-10-13 # | |
######################################### | |
# Usage: FastaToSNPCount.sh <input.fasta> | |
awk -vRS=">" -vFS="\n" -vOFS="\t" ' | |
{ a[$1] = $2; next} | |
END{ | |
for (i in a) {printf "\t%s", i} | |
for (i in a){ | |
printf "\n%s", i; | |
for (j in a) { | |
mis=0 | |
for (k=1; k<length($2); k++){ | |
if (substr(a[i], k, 1) != substr(a[j], k, 1)){ mis++ } | |
} | |
printf "\t%s", mis; | |
} | |
} | |
print ""; | |
} | |
' $1 | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment