-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq2pipe_step9_rarefy.sh
executable file
·82 lines (67 loc) · 2.5 KB
/
q2pipe_step9_rarefy.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
################################
# #
# Qiime 2 Pipeline #
# By: Patrick Gagne (NRCan) #
# Step 9 - Rarefy #
# 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
$APPTAINER_COMMAND qiime feature-table rarefy \
--i-table $ANALYSIS_NAME.filtered_table_dn"$p_perc_identity".qza \
--p-sampling-depth $p_sampling_depth \
--o-rarefied-table $ANALYSIS_NAME.rarefied_"$p_sampling_depth"_filtered_table_dn"$p_perc_identity".qza --verbose || exit_on_error
$APPTAINER_COMMAND qiime feature-table summarize \
--i-table $ANALYSIS_NAME.rarefied_"$p_sampling_depth"_filtered_table_dn"$p_perc_identity".qza \
--o-visualization $ANALYSIS_NAME.rarefied_"$p_sampling_depth"_filtered_table_dn"$p_perc_identity".qzv --verbose
$APPTAINER_COMMAND qiime taxa barplot \
--i-table $ANALYSIS_NAME.rarefied_"$p_sampling_depth"_filtered_table_dn"$p_perc_identity".qza \
--i-taxonomy $ANALYSIS_NAME.taxo_dn"$p_perc_identity".qza \
--m-metadata-file $METADATA_FILE_PATH \
--o-visualization $ANALYSIS_NAME.barplots_rarefied_"$p_sampling_depth"_filtered_table_dn"$p_perc_identity".qzv --verbose || exit_on_error