Skip to content

Commit df56649

Browse files
authored
Version 2.0
1 parent b736eb2 commit df56649

File tree

1 file changed

+34
-29
lines changed

1 file changed

+34
-29
lines changed

src/fetch-data.sh

+34-29
Original file line numberDiff line numberDiff line change
@@ -51,26 +51,29 @@ fi
5151

5252
# ---------------------------------------------------------------------
5353
# The following parameters should be provided:
54+
# Mandatory
5455
# 1) Identifiers provided in a txt file, one per line. These can be from SRA, ENA, DDBJ, GEO or Synapse repositories
5556
# 2) Specifies the type of identifier provided {'sra', 'synapse'}
56-
# 3) CPUs
57-
# 4) Max memory to be used
58-
# 5) Provide a name. A samplesheet for direct use with the nf-core/rna-seq pipeline will be created {'rnaseq'}
59-
# 6) Optional (-x): If this run is a resume or a new job
60-
# 7) The output directory where the results will be saved
57+
# 3) Provide a name. A samplesheet for direct use with the nf-core/rna-seq pipeline will be created {'rnaseq'}
58+
# 4) The output directory where the results will be saved
59+
# Optional
60+
# 5) CPUs
61+
# 6) Max memory to be used
62+
# 7) (-x): If this run is a resume or a new job
63+
6164
# ---------------------------------------------------------------------
6265

6366

64-
while getopts i:t:p:m:n:x:o: flag
67+
while getopts i:t:n:o:p:m:x: flag
6568
do
6669
case "${flag}" in
6770
i) ID=${OPTARG};;
6871
t) type=${OPTARG};;
72+
n) name=${OPTARG};;
73+
o) output=${OPTARG};;
6974
p) cpu=${OPTARG};;
7075
m) memory=${OPTARG};;
71-
n) name=${OPTARG};;
7276
x) resume=${OPTARG};;
73-
o) output=${OPTARG};;
7477
\?) echo "Invalid option: $OPTARG" 1>&2;;
7578
:) echo "Invalid option: $OPTARG requires an argument" 1>&2;;
7679
esac
@@ -92,13 +95,15 @@ if [ $# -eq 0 ]; then
9295
echo ""
9396
echo " **Empty parameters! Unable to run**. Please provide the following parameters:"
9497
echo "
98+
Mandatory
9599
-i: Identifiers provided in a txt file, one per line. These can be from SRA, ENA, DDBJ, GEO or Synapse repositories
96100
-t: Specifies the type of identifier provided {'sra', 'synapse'}
101+
-n: Provide a name. A samplesheet for direct use with the nf-core/rna-seq pipeline will be created (CSV) {'rnaseq'}
102+
-o: The output directory where the results will be saved
103+
Optional
97104
-p: CPUs
98105
-m: Max memory to be used (ej. -m 100.GB) Please note the syntaxis.
99-
-n: Provide a name. A samplesheet for direct use with the nf-core/rna-seq pipeline will be created (CSV) {'rnaseq'}
100106
-x: resume a previous Job. Options: y/n
101-
-o) The output directory where the results will be saved
102107
103108
"
104109

@@ -114,7 +119,7 @@ fi
114119
# ---------------------------------------------------------------------
115120

116121

117-
#Mandatory: Identifiers
122+
# Mandatory: Identifiers
118123
if [ -z "${ID}" ];then
119124
printf "Missing Identifiers File. Please provide it and run again.\n"
120125
exit 1
@@ -132,21 +137,21 @@ else
132137
fi
133138

134139

135-
#Mandatory: Type of identifier
140+
# Mandatory: Type of identifier
136141
if [ -z "${type}" ];then
137142
printf "Missing Identifier Type. Please provide sra or synapse and run again.\n"
138143
exit 1
139144
fi
140145

141146

142-
#Mandatory: Samplesheet name
147+
# Mandatory: Samplesheet name
143148
if [ -z "${name}" ];then
144149
printf "Missing samplesheet name. Please provide it and run again.\n"
145150
exit 1
146151
fi
147152

148153

149-
#Mandatory: Name of output directory
154+
# Mandatory: Name of output directory
150155
if [ -z "${output}" ];then
151156
printf "Output not provided.\n"
152157
output="SRA"
@@ -156,30 +161,30 @@ else
156161
fi
157162

158163

159-
#Optional: Resume previous job
160-
if [[ "$resume" == "y" ]];then
161-
printf "Resuming previous Job\n"
162-
again="-resume"
163-
elif [[ "$resume" == "n" ]];then
164-
printf "Starting a new Job\n"
165-
again=" "
166-
else
167-
printf "Missing option y/n for resuming process (-x option). Quitting.\n"
168-
exit 1
164+
# Optional: CPU
165+
if [ -z "${cpu}" ];then
166+
cpu=$(cat /proc/cpuinfo | grep -c 'processor')
167+
printf "CPUs to use not provided. Using all $cpu cores available.\n"
169168
fi
170169

171170

172-
#Optional: Memory
171+
# Optional: Memory
173172
if [ -z "${memory}" ];then
174173
memory=$(vmstat -s -S M | grep 'total memory' | awk '{ print $1 / (1024) }' | awk '{ print int($1+0.5) }')
175174
printf "Max memory not provided. Using all $memory GB of memory.\n"
176175
fi
177176

178177

179-
#Optional: CPU
180-
if [ -z "${cpu}" ];then
181-
cpu=$(cat /proc/cpuinfo | grep -c 'processor')
182-
printf "CPUs to use not provided. Using all $cpu cores available.\n"
178+
# Optional: Resume previous job
179+
if [[ "$resume" == "y" ]];then
180+
printf "Resuming previous Job\n"
181+
again="-resume"
182+
elif [[ "$resume" == "n" ]];then
183+
printf "Starting a new Job\n"
184+
again=" "
185+
else
186+
printf "Missing option y/n for resuming process (-x option). Quitting.\n"
187+
exit 1
183188
fi
184189

185190

0 commit comments

Comments
 (0)