-
Notifications
You must be signed in to change notification settings - Fork 0
/
panX_generator.sh
executable file
·99 lines (80 loc) · 2.82 KB
/
panX_generator.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/bash
#title :panX_generator.sh
#description :This script will run panX pan-genome analysis and push to the pan-genome visualisation folder.
#author :Nouri L. Ben Zakour
#date :20180315
#version :0.1
#usage :panX_generator.sh <metadata_file> <gbk_dir> <run_name> <run_dir> <vis_dir> <nullarbor>
#=======================================================================================================
display_usage() {
echo "This script will run panX pan-genome analysis and push to the pan-genome visualisation folder."
echo "Usage: panX_generator.sh <metadata_file> <nullarbor_run> <run_name> <run_dir> <vis_dir>"
echo " <metadata_file> metadata file in tab delimited format with full path. "
echo " first field has to be named 'accession' for successful metadata linking."
echo " <gbk_dir> full path to folder containing gbk"
echo " <run_name> name of the run"
echo " <run_dir> full path to running directory"
echo " <vis_dir> full path to visualisation directory, typically /your/path/pan-genome-visualisation/public/datasets..."
echo " <nullarbor> yes, if genbank data are to be retrieved from a nullarbor run. No, otherwise."
}
# if less than 6 arguments supplied, display usage
if [ $# -le 5 ]
then
display_usage
exit 1
fi
# check whether user had supplied -h or --help . If yes display usage
if [[ ( $# == "--help") || $# == "-h" ]]
then
display_usage
exit 0
fi
# check whether user has supplied appropriate value for Nullarbor run. If different display usage
if [[ $6 != "yes" && $6 != "no" && $6 != "y" && $6 != "n" ]]
then
display_usage
exit 0
fi
metadata_file=$1
gbk_dir=$2
run_name=$3
run_dir=$4
vis_dir=$5
nullarbor=$6
## set up
echo "Setting up running folder..."
if [ ! -d $run_dir ];
then
mkdir $run_dir
cd $run_dir
mkdir input_GenBank
fi
echo "Importing Genbank files..."
cd $run_dir/input_GenBank
if [[ $nullarbor == "yes" || $nullarbor == "y" ]];
then
cp $gbk_dir/*/prokka/*UNION.gbk .
for f in *;
do rename .UNION.gbk .gbk $f;
done
else
cp $gbk_dir/*gbk .
fi
ls *gbk | cut -f 1 -d "." > ../$run_name.txt
cat ../$run_name.txt
cd $run_dir
## run
echo "Running PanX pan-genome analysis..."
python /opt/sw/pan-genome-analysis/panX.py -fn . -st 1 2 3 5 6 7 8 9 10 11 -mi $metadata_file -sl $run_name.txt -t 32 1> $run_name.log 2> $run_name.err
cat $run_name.err
## transfer results to visualisation folder, typically /your/path/pan-genome-visualisation/public/datasets"
## Pan-genome analysis is successfully accomplished
echo "Copying results to visualisation folder"
if [ ! -d $vis_dir/$run_name ];
then
mkdir $vis_dir/$run_name
fi
cp -rf vis/* $vis_dir/$run_name
cd $vis_dir
bash add-new-pages-repo.sh $run_name wide
echo "PanX analysis completed and transferred, ready for visualisation"