Skip to content

Commit

Permalink
Ena add address (#2965)
Browse files Browse the repository at this point in the history
* Add address

# Conflicts:
#	ena-submission/scripts/create_assembly.py

* Fix address parsing

* fix tests

* fix tests

(cherry picked from commit 673786c)

* log error
  • Loading branch information
anna-parker authored Oct 7, 2024
1 parent c4695da commit 6064eda
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions ena-submission/scripts/create_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import click
import pytz
import yaml
from call_loculus import get_group_info
from ena_submission_helper import (
CreationResult,
create_chromosome_list,
Expand Down Expand Up @@ -134,6 +135,17 @@ def create_manifest_object(
sample_accession = sample_table_entry["result"]["ena_sample_accession"]
study_accession = project_table_entry["result"]["bioproject_accession"]

address_string = project_table_entry["center_name"]
if config.is_broker:
try:
group_info = get_group_info(config, project_table_entry["group_id"])[0]["group"]
address = group_info["address"]
address_string = (f'{address.get("line1", "")}, {address.get("line2", "")}, '
f'{address.get("city", "")}, {address.get("state", "")}, '
f'{address.get("postalCode", "")}, {address.get("country")}')
except Exception as e:
logger.error(f"Was unable to create address, setting address to center_name due to {e}")

metadata = submission_table_entry["metadata"]
unaligned_nucleotide_sequences = submission_table_entry["unaligned_nucleotide_sequences"]
organism_metadata = config.organisms[group_key["organism"]]["enaDeposition"]
Expand Down Expand Up @@ -205,6 +217,7 @@ def create_manifest_object(
description=description,
moleculetype=moleculetype,
authors=authors,
address=address_string,
)


Expand Down
5 changes: 4 additions & 1 deletion ena-submission/scripts/test_ena_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,10 @@ def test_create_manifest(self):
study_accession = "Test Study Accession"
sample_accession = "Test Sample Accession"
results_in_sample_table = {"result": {"ena_sample_accession": sample_accession}}
results_in_project_table = {"result": {"bioproject_accession": study_accession}}
results_in_project_table = {
"result": {"bioproject_accession": study_accession},
"center_name": "generic_center_name",
}
manifest = create_manifest_object(
config,
results_in_sample_table,
Expand Down

0 comments on commit 6064eda

Please sign in to comment.