-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathena-submit.sh
More file actions
executable file
·155 lines (125 loc) · 3.99 KB
/
ena-submit.sh
File metadata and controls
executable file
·155 lines (125 loc) · 3.99 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
set -euo pipefail
#------------------------------------------------------------------------------#
# Thank you to adapt information below #
#------------------------------------------------------------------------------#
# Submit or test?
# One of the following:
# "true": real data submission,
# "false": submit to testing server
SUBMISSION="false"
# EXPECTED ACTION
# One of the following actions:
# "ADD": submit new data,
# "MODIFY": submit updates data
ACTION="ADD"
# CREDENTIAL FILE
# File containing the credentials.
# One line containing:
# username password
CREDENDIAL=.credential
# SPREADSHEET FILE
# Name of the spreadsheet file containing your data.
# Start using the giving template
TEMPLATE_XLS="spreadsheet_template.xlsx"
# DIRECTORY CONTAINING THE DATA READS
# The name of the directory where sequencing reads are stored
# Generally fastq.gz files
DATA_IN_DIR="data"
# DIRECTORY CONTAINING THE GENERATED XLM FILES
# This directrory will be used to store the xml files produced
XML_OUT_DIR="xml"
#------------------------------------------------------------------------------#
# You should not have to modify the code below #
#------------------------------------------------------------------------------#
# ENA SERVERS
FTP="ftp://webin.ebi.ac.uk/"
URL_TEST="https://wwwdev.ebi.ac.uk/ena/submit/drop-box/submit/"
URL_PROD="https://www.ebi.ac.uk/ena/submit/drop-box/submit/"
echo
# SELECT SERVER
if [ $SUBMISSION = "true" ]
then
URL=$URL_PROD
echo "This is a real submission..."
else
URL=$URL_TEST
echo "This a test submission..."
fi
# IMPORT CREDENTIALS
read user pass < $CREDENDIAL
# UPLOAD FILES TO ENA (FTP)
echo
echo "# Upload data to ENA FTP server..."
echo
# curl --user $user:$pass --upload-file "{$(find $DATA_IN_DIR -name '*.gz' -printf '%p,' | sed 's/,$//')}" --url $FTP
# GENERATE XML FILES
echo
echo "# Generate XML submission files..."
echo
./generate-xml.py -o $XML_OUT_DIR $TEMPLATE_XLS
echo
project=$XML_OUT_DIR/project.xml
sample=$XML_OUT_DIR/sample.xml
experiment=$XML_OUT_DIR/experiment.xml
run=$XML_OUT_DIR/run.xml
files=" "
# CHECK IF XML FILES WERE GENERATED
if [ -f $project ]; then
echo "Project XML file: $project generated successfully."
files="$file -F PROJECT=@${project} "
else
echo "Project XML file: $project not found. Skipping project submission."
fi
if [ -f $sample ]; then
echo "Sample XML file: $sample generated successfully."
files="$files -F SAMPLE=@${sample} "
else
echo "Sample XML file: $sample not found. Skipping sample submission."
fi
if [ -f $experiment ]; then
echo "Experiment XML file: $experiment generated successfully."
files="$files -F EXPERIMENT=@${experiment} "
else
echo "Experiment XML file: $experiment not found. Skipping experiment submission."
fi
if [ -f $run ]; then
echo "Run XML file: $run generated successfully."
files="$files -F RUN=@${run} "
else
echo "Run XML file: $run not found. Skipping run submission."
fi
# ENA SUBMISSION
echo
echo "# Submit XML files to ENA server..."
echo
curl -u $user:$pass -F "ACTION=${ACTION}" ${files} --url ${URL} > server-receipt.xml
echo
if grep "RECEIPT" server-receipt.xml &> /dev/null; then
echo "Server connection was ok."
success=$(perl -ne 'm/success="(true|false)"/ && print $1' server-receipt.xml)
if [ $success = "true" ]
then
echo "Submission was successful."
# PARSE RECEIPT XML RESPONSE
./parse-receipt.py -t -o server-receipt.txt server-receipt.xml
echo "See the server receipts returned: "
echo " - server-receipt.xml (original receipt)"
echo " - server-receipt.txt (tabular format)"
else
echo "Submission failed!"
echo "See server receipt XML returned: server-receipt.xml."
echo "Check the receipt for error messages and after making corrections, "
echo " try the submission again."
echo
exit 2
fi
else
echo "Server connection error!"
echo "See server receipt file: server-receipt.xml."
echo
exit 1
fi
# END
echo
echo "Done."