-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaltrevis.sh
79 lines (67 loc) · 2.28 KB
/
altrevis.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
# Script Name: altrevis.sh
# Description: An easy-to-use, beginner-oriented tool to align DNA/RNA or protein sequences, infer a ML-like phylogenetic tree from the alignment and visualize it.
# Author: Astra Bertelli
# Date: November 9, 2023
# Version: 1.0.0
# Please consider to cite the author of this script and the original GitHub repository when using altrevis for your projects
# Usage function
usage() {
echo "Usage: altrevis -i,--infile INFILE [-at, --alignment_type nt OR aa]
REQUIRED ARGUMENTS:
-i, --infile: Provide the path to the original fasta file from which to start the phylogenetic analysis
OPTIONAL ARGUMENTS:
-at, --alignment_type: Choose between nt (for DNA/RNA alignment) and aa (for protein alignments): default is nt.
Input altrevis -h to show this message again."
exit 1
}
infile=""
alignment_type=""
while [ $# -gt 0 ]; do
case "$1" in
-h|--help)
usage
;;
-i|--infile)
infile="$2"
shift 2
;;
-at|--alignment_type)
alignment_type="$2"
shift 2
;;
*)
echo "Unknown option: $1"
exit 1
;;
esac
done
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
usage
fi
if [ -z "$alignment_type" ] && [ ! "$1" = "-h" ] && [ ! "$1" = "--help" ]; then
alignment_type="nt"
fi
if [ -z "$infile" ] && [ ! "$1" = "-h" ] && [ ! "$1" = "--help" ]; then
echo "Missing required argument: INFILE"
usage
fi
if [ ! -f "$infile" ]
then
echo "Provided path does not represent an existing file"
else
flnm=$(basename "$infile")
no_ext="${flnm%.*}"
fold_name=$(dirname "$infile")
folder_name=$(realpath "$fold_name")
mkdir -p ${folder_name}/altrevis_results
if [[ "$alignment_type" == "nt" ]]
then
mafft $infile > ${folder_name}/altrevis_results/${no_ext}.afn
fasttree -nt ${folder_name}/altrevis_results/${no_ext}.afn > ${folder_name}/altrevis_results/${no_ext}.tree
else
muscle -in $infile -out ${folder_name}/altrevis_results/${no_ext}.afaa
fasttree ${folder_name}/altrevis_results/${no_ext}.afaa > ${folder_name}/altrevis_results/${no_ext}.tree
fi
seaview ${folder_name}/altrevis_results/${no_ext}.tree
fi