我的目标是增加此 fastq 验证的重试次数,该验证有时会因网络问题而失败,尽管有给定 NCBI SRA id 的数据,但它失败了。所以我需要在中止之前增加至少5次重试。
我该如何做同样的事情?
set -x
PS4='[\\d \\t] '
# Check parameter for error
check=0
# Print fastq-dump executable path
echo \$(which fastq-dump)
# Loop through all parameters to check validity
for file in \$@;
do
cp \${file} .
# Extract filename for sampleID
file_basename=\$(basename \${file})
id=\${file_basename%".id"}
# Start validation
echo "Checking \${id}..."
# Download start of fastq
fastq-dump $(get_ngc()) -X 1 -Z --split-spot \${id} > \${id}.test.fastq 2> \${id}.test.log
# Get number of lines downloaded to valildate for error
numLines=\$(cat \${id}.test.fastq | wc -l)
if [ \$numLines -gt 0 ]; then
echo "\${id} has data... OK"
else
echo "\${id} does not have data... ERROR"
check=1
fi
done
# Exit with error if some fastqs not accessible
if [ \$check -gt 0 ]; then
echo "ERROR: One or more samples have inaccessible fastqs.. exiting"
exit 1
fi
############ 更新 ###############
#!/usr/bin/env cwl-runner
cwlVersion: cwl:v1.0
class: CommandLineTool
requirements:
- class: DockerRequirement
dockerPull: kcm1400/validate_fastq_ncbi_sra:v1
- class: InlineJavascriptRequirement
expressionLib:
- var get_ngc= function(){ if(inputs["ngc_file"]==null){ return " "; }else{ return
"--ngc "+inputs["ngc_file"].path+" "; } }
- class: InitialWorkDirRequirement
listing:
- entry: |-
set -x
PS4='[\\d \\t] '
# Check parameter for error
check=0
# Print fastq-dump executable path
echo \$(which fastq-dump)
# Loop through all parameters to check validity
for file in \$@;
do
cp \${file} .
# Extract filename for sampleID
file_basename=\$(basename \${file})
id=\${file_basename%".id"}
# Start validation
echo "Checking \${id}..."
# Download start of fastq
fastq-dump $(get_ngc()) -X 1 -Z --split-spot \${id} > \${id}.test.fastq 2> \${id}.test.log
# Get number of lines downloaded to valildate for error
numLines=\$(cat \${id}.test.fastq | wc -l)
if [ \$numLines -gt 0 ]; then
echo "\${id} has data... OK"
else
echo "\${id} does not have data... ERROR"
check=1
fi
done
# Exit with error if some fastqs not accessible
if [ \$check -gt 0 ]; then
echo "ERROR: One or more samples have inaccessible fastqs.. exiting"
exit 1
fi
entryname: validate_fastq.sh
writable: false
label: validate_fastq_ncbi_sra
stdout: validate_fastq.log.txt
inputs:
sra_ID:
type:
- type: array
items: string
- 'null'
inputBinding:
position: 1
id_file:
type:
- type: array
items: File
- 'null'
inputBinding:
position: 2
ngc_file:
type:
- File
- 'null'
inputBinding:
position: 3
outputs:
output_log:
type: stdout
label: output log file
ncbi_ids:
type:
type: array
items: File
outputBinding:
glob:
- '*.id'
baseCommand:
- sh
- validate_fastq.sh
相同的 CWL 文件