-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
69 lines (53 loc) · 1.66 KB
/
run.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
#!/bin/bash
set -o errexit
set -o nounset
INPUT=/bbx/input/biobox.yaml
OUTPUT=/bbx/output
METADATA=/bbx/metadata
TASK=$1
#validate yaml
${VALIDATOR}/validate-biobox-file --schema=${VALIDATOR}schema.yaml --input=${INPUT}
# Parse the read locations from this file
READS=$(sudo /usr/local/bin/yaml2json < ${INPUT} \
| jq --raw-output '.arguments[] | select(has("fastq")) | .fastq[].value ')
#get fastq entries
FASTQS=$(sudo /usr/local/bin/yaml2json < ${INPUT} | jq --raw-output '.arguments[] | select(has("fastq")) | [.fastq[] | {value,type}] ' | tr '\n' ' ' )
#get length of fastq array
LENGTH=$( echo "$FASTQS" | jq --raw-output 'length')
TMP_DIR="$(mktemp -d)/ray"
FASTQ_TYPE=""
mkdir -p $OUTPUT
for ((COUNTER=0; COUNTER <$LENGTH; COUNTER++))
do
FASTQ_GZ=$( echo "$FASTQS" | jq --arg COUNTER "$COUNTER" --raw-output '.['$COUNTER'].value')
TYPE=$( echo "$FASTQS" | jq --arg COUNTER "$COUNTER" --raw-output '.['$COUNTER'].type')
if [ $TYPE == "paired" ]; then
FASTQ_TYPE="$FASTQ_TYPE -i $FASTQ_GZ"
else
FASTQ_TYPE="$FASTQ_TYPE -s $FASTQ_GZ"
fi
done
# Run the given task
CMD=$(egrep ^${TASK}: /Taskfile | cut -f 2 -d ':')
if [[ -z ${CMD} ]]; then
echo "Abort, no task found for '${TASK}'."
exit 1
fi
# if /bbx/metadata mounted create log.txt
if [ -d "$METADATA" ]; then
CMD="($CMD) >& $METADATA/log.txt"
fi
eval $CMD
mv ${TMP_DIR}/Contigs.fasta ${OUTPUT}
mv ${TMP_DIR}/Scaffolds.fasta ${OUTPUT}
cat << EOF > ${OUTPUT}/biobox.yaml
version: 0.9.0
arguments:
- fasta:
- id: 1
value: Contigs.fasta
type: contig
- id: 2
value: Scaffolds.fasta
type: scaffold
EOF