Skip to content

Commit 66252b9

Browse files
committed
accomodate differences in behavior for web vs FTP flu submissions
1 parent 9e881b1 commit 66252b9

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

pipes/WDL/tasks/tasks_ncbi.wdl

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,6 +1552,7 @@ task package_genbank_submissions {
15521552
python3 << CODE
15531553
import json
15541554
import zipfile
1555+
import csv
15551556
15561557
# initialize counters and file lists for each submission category
15571558
counts_by_type = {}
@@ -1633,20 +1634,43 @@ task package_genbank_submissions {
16331634
src_header = header
16341635
out_src.write(header)
16351636
out_src.write(inf.read())
1636-
with zipfile.ZipFile("~{spuid_base}_" + group + ".zip", 'w') as zf:
1637-
for fname in ('sequences.fsa', 'comment.cmt', 'source.src', 'template.sbt'):
1638-
zf.write(fname)
1637+
# make FTP zips and xmls
16391638
if group.startswith('SARS-CoV-2'):
1639+
with zipfile.ZipFile("~{spuid_base}_FTP_" + group + ".zip", 'w') as zf:
1640+
for fname in ('sequences.fsa', 'comment.cmt', 'source.src', 'template.sbt'):
1641+
zf.write(fname)
16401642
wizard = "BankIt_SARSCoV2_api"
1641-
write_submission_xml("~{spuid_base}_" + group, "~{spuid_namespace}", "~{account_name}", wizard=wizard)
1643+
write_submission_xml("~{spuid_base}_FTP_" + group, "~{spuid_namespace}", "~{account_name}", wizard=wizard)
16421644
elif group.startswith('Influenza'):
1645+
with zipfile.ZipFile("~{spuid_base}_FTP_" + group + ".zip", 'w') as zf:
1646+
for fname in ('sequences.fsa', 'comment.cmt', 'source.src', 'template.sbt'):
1647+
zf.write(fname)
16431648
wizard = "BankIt_influenza_api"
1644-
write_submission_xml("~{spuid_base}_" + group, "~{spuid_namespace}", "~{account_name}", wizard=wizard)
1649+
write_submission_xml("~{spuid_base}_FTP_" + group, "~{spuid_namespace}", "~{account_name}", wizard=wizard)
1650+
# make a different src file for web after making FTP zip
1651+
# because for some reason, you can't use the same source.src file for web and FTP for flu
1652+
# strain column is required for FTP and prohibited for web
1653+
with open('source.src', 'rt') as inf:
1654+
reader = csv.DictReader(inf, delimiter='\t')
1655+
out_header = list(h for h in reader.fieldnames if h != 'strain')
1656+
rows = []
1657+
for row in reader:
1658+
del row['strain']
1659+
rows.append(row)
1660+
with open('source.src', 'wt') as outf:
1661+
writer = csv.DictWriter(outf, delimiter='\t', fieldnames=out_header, dialect=csv.unix_dialect, quoting=csv.QUOTE_MINIMAL)
1662+
for row in rows:
1663+
writer.writerow(row)
1664+
1665+
# make web portal zips
1666+
with zipfile.ZipFile("~{spuid_base}_" + group + ".zip", 'w') as zf:
1667+
for fname in ('sequences.fsa', 'comment.cmt', 'source.src', 'template.sbt'):
1668+
zf.write(fname)
16451669
CODE
16461670
>>>
16471671

16481672
output {
1649-
Array[File] ftp_submission_files = glob("~{spuid_base}_[IS]*_clean.*")
1673+
Array[File] ftp_submission_files = glob("~{spuid_base}_FTP_*_clean.*")
16501674
File? submit_sqns_clean_zip = "~{spuid_base}_table2asn_clean.zip"
16511675
File? submit_sqns_warnings_zip = "~{spuid_base}_table2asn_warnings.zip"
16521676
Int num_sqns_clean = read_int("count_table2asn_clean.int")

0 commit comments

Comments
 (0)