-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq2pipe_step8_rarefaction_curve.sh
executable file
·102 lines (84 loc) · 2.69 KB
/
q2pipe_step8_rarefaction_curve.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
100
#!/bin/bash
################################
# #
# Qiime 2 Pipeline #
# By: Patrick Gagne (NRCan) #
# Step 8 - Rarefaction Curve #
# October 5, 2021 #
# #
################################
exit_on_error(){
echo "Qiime2 command error detected"
echo "Exiting program"
exit 1
}
optionfile=$1
if [ ! $optionfile ] || [ ! -e $optionfile ] || [ ! -r $optionfile ]
then
echo "ERROR: you must specify a valid, accessible qiime2 optionfile"
exit 1
fi
source $optionfile
if [ $TEMPORARY_DIRECTORY ]
then
echo "Overriding default temporary directory to $TEMPORARY_DIRECTORY"
if [ ! -d $TEMPORARY_DIRECTORY ] || [ ! -w $TEMPORARY_DIRECTORY ]
then
echo "ERROR: $TEMPORARY_DIRECTORY does not exist or is read only"
exit 2
fi
export TMPDIR=$TEMPORARY_DIRECTORY
fi
if [ ! $TMPDIR ]
then
export TMPDIR=/tmp
fi
if [ "$APPTAINER_COMMAND" != "" ]
then
echo "DEBUG: Checking temporary folder"
temp_check=$( $APPTAINER_COMMAND mktemp -t Q2PIPE_TEMPFOLDER_CHECK.XXXXXX.temp )
bname=$( basename $temp_check )
if [ ! -e $TMPDIR/$bname ]
then
echo "ERROR: Disparity between Apptainer temporary folder and system temporary folder"
echo "Please make sure both are pointing to the same folder"
exit 5
else
echo "DEBUG: Temporary file check status: OK"
rm $TMPDIR/Q2PIPE_TEMPFOLDER_CHECK.??????.temp
fi
fi
if [ "$SKIP_RAREFACTION" == "true" ]
then
echo "Rarefaction override detected in option file, you must skip this step"
exit 0
fi
metric_str=''
if [ $p_metrics ]
then
metric_str=""
for i in $( echo $p_metrics | sed 's/,/ /g' )
do
metric_str="$metric_str --p-metrics $i"
done
#metric_str="$metric_str \\"
fi
$APPTAINER_COMMAND qiime diversity alpha-rarefaction \
--i-table $ANALYSIS_NAME.filtered_table_dn"$p_perc_identity".qza \
--p-max-depth $p_max_depth \
--p-steps $p_steps \
--p-iterations $p_iterations $metric_str \
--m-metadata-file $METADATA_FILE_PATH \
--o-visualization $ANALYSIS_NAME.rarefaction_curves_filtered.qzv --verbose || exit_on_error
if [ "$GENERATE_PHYLOGENY" == "true" ]
then
$APPTAINER_COMMAND qiime diversity alpha-rarefaction \
--i-table $ANALYSIS_NAME.filtered_table_dn"$p_perc_identity".qza \
--i-phylogeny $ANALYSIS_NAME.rooted_tree.qza \
--p-max-depth $p_max_depth \
--p-steps $p_steps \
--p-iterations $p_iterations $metric_str \
--m-metadata-file $METADATA_FILE_PATH \
--o-visualization $ANALYSIS_NAME.rarefaction_curves_filtered_phylo.qzv --verbose || exit_on_error
fi
# Do some things to prepare the curve (maybe show it inside the terminal)