diff options
author | lltommy | 2020-11-11 09:56:12 +0100 |
---|---|---|
committer | lltommy | 2020-11-11 09:56:12 +0100 |
commit | d6aa323b6fc7a82e45cc1df51fc72c2d547146eb (patch) | |
tree | 6e8b77bde4dc34fab3fa8804906f3cb821f61dae /bh20seqanalyzer | |
parent | c5fe5de7e4c77bfb48b1ae2f662c2d9cc120c06e (diff) | |
parent | c872248e43c1c66e5fed8ef341f7b4ac21d63e6f (diff) | |
download | bh20-seq-resource-d6aa323b6fc7a82e45cc1df51fc72c2d547146eb.tar.gz bh20-seq-resource-d6aa323b6fc7a82e45cc1df51fc72c2d547146eb.tar.lz bh20-seq-resource-d6aa323b6fc7a82e45cc1df51fc72c2d547146eb.zip |
Merge branch 'master' of https://github.com/arvados/bh20-seq-resource
Diffstat (limited to 'bh20seqanalyzer')
-rw-r--r-- | bh20seqanalyzer/main.py | 52 |
1 files changed, 36 insertions, 16 deletions
diff --git a/bh20seqanalyzer/main.py b/bh20seqanalyzer/main.py index 5f00080..b54a746 100644 --- a/bh20seqanalyzer/main.py +++ b/bh20seqanalyzer/main.py @@ -42,11 +42,11 @@ class SeqAnalyzer: self.schema_ref = None def validate_upload(self, collection, revalidate): - col = arvados.collection.Collection(collection["uuid"], api_client=self.api, keep_client=self.keepclient) - if not revalidate and collection["properties"].get("status") in ("validated", "rejected"): return False + col = arvados.collection.Collection(collection["uuid"], api_client=self.api, keep_client=self.keepclient) + # validate the collection here. Check metadata, etc. logging.info("Validating upload '%s' (%s)" % (collection["name"], collection["uuid"])) @@ -98,19 +98,7 @@ class SeqAnalyzer: except Exception as v: errors.append(str(v)) - - if not errors: - # Move it to the "validated" project to be included in the next analysis - if "errors" in collection["properties"]: - del collection["properties"]["errors"] - collection["properties"]["status"] = "validated" - self.api.collections().update(uuid=collection["uuid"], body={ - "owner_uuid": self.validated_project, - "name": "%s (%s)" % (collection["name"], time.asctime(time.gmtime())), - "properties": collection["properties"]}).execute() - logging.info("Added '%s' to validated sequences" % collection["name"]) - return True - else: + if errors: # It is invalid logging.warn("'%s' (%s) has validation errors: %s" % ( collection["name"], collection["uuid"], "\n".join(errors))) @@ -119,6 +107,38 @@ class SeqAnalyzer: self.api.collections().update(uuid=collection["uuid"], body={"properties": collection["properties"]}).execute() return False + existing = self.api.collections().list(filters=[["owner_uuid", "=", self.validated_project], + ["properties.sequence_label", "=", sample_id]]).execute() + + update_from = None + if existing["items"]: + # "collection" is the newly uploaded one we're looking at + update_from = collection + collection = existing["items"][0] + collection["properties"] = update_from["properties"] + + if "errors" in collection["properties"]: + del collection["properties"]["errors"] + collection["properties"]["status"] = "validated" + collection["properties"]["sequence_label"] = sample_id + + if update_from: + self.api.collections().update(uuid=collection["uuid"], body={ + "properties": collection["properties"], + "manifest_text": col.manifest_text() + }).execute() + self.api.collections().delete(uuid=update_from["uuid"]).execute() + logging.info("Updated '%s' in validated sequences" % collection["name"]) + else: + # Move it to the "validated" project to be included in the next analysis + self.api.collections().update(uuid=collection["uuid"], body={ + "owner_uuid": self.validated_project, + "name": "%s (%s)" % (collection["name"], time.asctime(time.gmtime())), + "properties": collection["properties"]}).execute() + logging.info("Added '%s' to validated sequences" % collection["name"]) + + return True + def run_workflow(self, parent_project, workflow_uuid, name, inputobj): project = self.api.groups().create(body={ @@ -215,7 +235,7 @@ class SeqAnalyzer: most_recent_analysis = self.api.groups().list(filters=[['owner_uuid', '=', self.pangenome_analysis_project]], order="created_at desc").execute() for m in most_recent_analysis["items"]: - wf = self.get_workflow_output_from_project(m["uuid"], "arv-main.cwl") + wf = self.get_workflow_output_from_project(m["uuid"], "collect-seqs.cwl") if wf is None: continue src = self.api.collections().get(uuid=wf["output_uuid"]).execute() |