aboutsummaryrefslogtreecommitdiff
path: root/bh20sequploader/main.py
diff options
context:
space:
mode:
authorAdam Novak2020-04-09 15:57:37 -0700
committerAdam Novak2020-04-09 15:58:56 -0700
commitd9a24cfb81a028fcd901abd08fc02b9140d5e78b (patch)
treeb08ac8d559a263381703ce14c06e144e6f48912c /bh20sequploader/main.py
parent2cd6623aa0ddfe4e42b2d434e0523773bb3536ef (diff)
parentb1039ff369ee88770e42d1bbbdc402b1181c2aa5 (diff)
downloadbh20-seq-resource-d9a24cfb81a028fcd901abd08fc02b9140d5e78b.tar.gz
bh20-seq-resource-d9a24cfb81a028fcd901abd08fc02b9140d5e78b.tar.lz
bh20-seq-resource-d9a24cfb81a028fcd901abd08fc02b9140d5e78b.zip
Merge remote-tracking branch 'upstream/master' into add-web-ui
Diffstat (limited to 'bh20sequploader/main.py')
-rw-r--r--bh20sequploader/main.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/bh20sequploader/main.py b/bh20sequploader/main.py
index d3ebc0c..bf74ea5 100644
--- a/bh20sequploader/main.py
+++ b/bh20sequploader/main.py
@@ -6,6 +6,7 @@ import json
import urllib.request
import socket
import getpass
+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,5 +58,7 @@ def main():
(properties['upload_user'], properties['upload_ip']),
properties=properties, ensure_unique_name=True)
+ print("Done")
+
if __name__ == "__main__":
main()