aboutsummaryrefslogtreecommitdiff
path: root/bh20sequploader/main.py
diff options
context:
space:
mode:
authorPjotr Prins2020-04-09 15:34:06 -0500
committerPjotr Prins2020-04-09 15:34:06 -0500
commit0670ac0644c1e7366952e254bdee2db62e673275 (patch)
treeaed056a1ca4208cf30993da3e96bbb4fb08dbe52 /bh20sequploader/main.py
parent146cf2f5d1be9a5dd9d6cd65ce9c760853d014f8 (diff)
parentdbe094a150d6c969b3d69f112b3538e6a87a74a2 (diff)
downloadbh20-seq-resource-0670ac0644c1e7366952e254bdee2db62e673275.tar.gz
bh20-seq-resource-0670ac0644c1e7366952e254bdee2db62e673275.tar.lz
bh20-seq-resource-0670ac0644c1e7366952e254bdee2db62e673275.zip
Merge branch 'master' of github.com:arvados/bh20-seq-resource
Diffstat (limited to 'bh20sequploader/main.py')
-rw-r--r--bh20sequploader/main.py22
1 files changed, 17 insertions, 5 deletions
diff --git a/bh20sequploader/main.py b/bh20sequploader/main.py
index 17ad492..56cbe22 100644
--- a/bh20sequploader/main.py
+++ b/bh20sequploader/main.py
@@ -6,6 +6,7 @@ import json
import urllib.request
import socket
import getpass
+from .qc_metadata import qc_metadata
ARVADOS_API_HOST='lugli.arvadosapi.com'
ARVADOS_API_TOKEN='2fbebpmbo3rw3x05ueu2i6nx70zhrsb1p22ycu3ry34m4x4462'
@@ -19,18 +20,26 @@ def main():
api = arvados.api(host=ARVADOS_API_HOST, token=ARVADOS_API_TOKEN, insecure=True)
+ if not qc_metadata(args.metadata.name):
+ print("Failed metadata qc")
+ exit(1)
+
col = arvados.collection.Collection(api_client=api)
- print("Reading FASTA")
- with col.open("sequence.fasta", "w") as f:
+ if args.sequence.name.endswith("fasta") or args.sequence.name.endswith("fa"):
+ target = "sequence.fasta"
+ elif args.sequence.name.endswith("fastq") or args.sequence.name.endswith("fq"):
+ target = "reads.fastq"
+
+ with col.open(target, "w") as f:
r = args.sequence.read(65536)
print(r[0:20])
while r:
f.write(r)
r = args.sequence.read(65536)
- print("Reading JSONLD")
- with col.open("metadata.jsonld", "w") as f:
+ print("Reading metadata")
+ with col.open("metadata.yaml", "w") as f:
r = args.metadata.read(65536)
print(r[0:20])
while r:
@@ -49,4 +58,7 @@ def main():
(properties['upload_user'], properties['upload_ip']),
properties=properties, ensure_unique_name=True)
-main()
+ print("Done")
+
+if __name__ == "__main__":
+ main()