-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathena-submit.sh
executable file
·132 lines (106 loc) · 3.25 KB
/
ena-submit.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
set -e
#------------------------------------------------------------------------------#
# Thank you to adapt information below #
#------------------------------------------------------------------------------#
# TEST/SUBMIT YOUR DATA
# One of the following:
# "true": submit to testing server,
# "false": real data submission
TEST="true"
# 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
LIBREOFFICE_ODS="spreadsheet_template.ods"
# 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 [ $TEST = "false" ]
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 \
-T "{$(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 -d $DATA_IN_DIR -o $XML_OUT_DIR $LIBREOFFICE_ODS
project=$XML_OUT_DIR/project.xml
sample=$XML_OUT_DIR/sample.xml
experiment=$XML_OUT_DIR/experiment.xml
run=$XML_OUT_DIR/run.xml
# ENA SUBMISSION
echo
echo "# Submit XML files to ENA server..."
echo
curl -u $user:$pass \
-F "ACTION=${ACTION}" \
-F "PROJECT=@${project}" \
-F "SAMPLE=@${sample}" \
-F "EXPERIMENT=@${experiment}" \
-F "RUN=@${run}" \
--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 was not successful!"
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."