Last active
April 27, 2021 10:20
-
-
Save fredyr/98e6184cdde98dc77d28b2a0589f3c22 to your computer and use it in GitHub Desktop.
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
#/usr/bin/env bash | |
set -e | |
ENV=snp_tree | |
source miniconda3/etc/profile.d/conda.sh | |
if !(conda info --envs | grep $ENV); then | |
echo "Installing dependencies..." | |
# conda config --add channels defaults | |
# conda config --add channels bioconda | |
# conda config --add channels conda-forge | |
conda create --name $ENV python=3.9 mafft snp-sites snp-dists quicktree -q -y | |
conda activate $ENV | |
pip install bio pandas | |
wget https://gist.githubusercontent.com/fredyr/5bff0d4a3fdc7fc41512791351b2da51/raw/f26ed9e5c52b161bb5df49462d2e1e67f7f470b1/snp-dists_phylip.py | |
conda deactivate | |
echo "Installation done!" | |
echo "Run with: " | |
echo "./snp_tree.sh <prefix> *.consensus.fa" | |
exit 0 | |
else | |
echo | |
echo "Dependencies installed, running pipeline..." | |
fi | |
conda activate $ENV | |
prefix=$1; shift 1 | |
FA=$@ | |
if [ ! -f "$prefix.nwk" ]; then | |
cat $FA > $prefix.cns.fa | |
mafft $prefix.cns.fa > $prefix.aln.fa | |
snp-sites -c $prefix.aln.fa > $prefix.core.fa | |
snp-dists $prefix.core.fa | python snp-dists_phylip.py > $prefix.phylip | |
quicktree -in m $prefix.phylip > $prefix.nwk | |
echo "Newick tree written to $prefix.nwk" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment