-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq2pipe_step6_classification.sh
executable file
·115 lines (93 loc) · 3.46 KB
/
q2pipe_step6_classification.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
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/bash
################################
# #
# Qiime 2 Pipeline #
# By: Patrick Gagne (NRCan) #
# Step 6 - Classification #
# November 28, 2023 #
# #
################################
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 [ $CLASSIFIER_DATABASE_PATH ] && [ $CLASSIFIER_OUTPUT_NAME ]
then
if [ "$(stat -L -c %d:%i $CLASSIFIER_DATABASE_PATH)" = "$(stat -L -c %d:%i $CLASSIFIER_OUTPUT_NAME)" ]
then
classifier_path=$CLASSIFIER_DATABASE_PATH
else
echo "ERROR: Ambiguity detected in option file"
echo "CLASSIFIER_DATABASE_PATH and CLASSIFIER_OUTPUT_NAME are both defined but are not the same file"
exit 1
fi
fi
if [ ! $CLASSIFIER_DATABASE_PATH ]
then
classifier_path=$CLASSIFIER_OUTPUT_NAME
else
classifier_path=$CLASSIFIER_DATABASE_PATH
fi
if [ ! $CLASSIFIER_NB_THREADS ]
then
echo "WARNING: CLASSIFIER_NB_THREADS variable not set, will fallback on NB_THREADS"
echo "This could cause a RAM overload during the classification"
CLASSIFIER_NB_THREADS=$NB_THREADS
fi
$APPTAINER_COMMAND qiime feature-classifier classify-sklearn \
--i-classifier $classifier_path \
--i-reads $ANALYSIS_NAME.rep-seqs-dada2_dn"$p_perc_identity".qza \
--p-n-jobs $CLASSIFIER_NB_THREADS \
--p-confidence $p_confidence \
--o-classification $ANALYSIS_NAME.taxo_dn"$p_perc_identity".qza --verbose || exit_on_error
$APPTAINER_COMMAND qiime metadata tabulate \
--m-input-file $ANALYSIS_NAME.taxo_dn"$p_perc_identity".qza \
--o-visualization $ANALYSIS_NAME.taxo_dn"$p_perc_identity".qzv --verbose
$APPTAINER_COMMAND qiime taxa barplot \
--i-table $ANALYSIS_NAME.table-dada2_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_taxo_dn"$p_perc_identity".qzv --verbose || exit_on_error
#if [ "$SKIP_FILTERING" == "true" ]
#then
# echo "Filtering skip option detected, table-dada2 and rep-seqs will copied as filtered_table for filename coherency"
# cp -v $ANALYSIS_NAME.table-dada2_dn"$p_perc_identity".qza $ANALYSIS_NAME.filtered_table_dn"$p_perc_identity".qza
# cp -v $ANALYSIS_NAME.rep-seqs-dada2_dn"$p_perc_identity".qza $ANALYSIS_NAME.filtered_rep-seqs-dada2_dn"$p_perc_identity".qza
#fi