Skip to content

Commit

Permalink
fix execution of ELOAD status (#184)
Browse files Browse the repository at this point in the history
Allow the current analysis to be None
  • Loading branch information
tcezard authored Nov 24, 2023
1 parent fa2420b commit 3304283
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
4 changes: 2 additions & 2 deletions bin/submission_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ def main():
# Load the config_file from default location
load_config()

with EloadStatus(args.eload) as eload:
eload.status()
eload = EloadStatus(args.eload)
eload.status()


if __name__ == "__main__":
Expand Down
24 changes: 15 additions & 9 deletions eva_submission/eload_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

from ebi_eva_common_pyutils.config import cfg
from ebi_eva_common_pyutils.logger import AppLogger
from ebi_eva_internal_pyutils.metadata_utils import resolve_variant_warehouse_db_name
from ebi_eva_internal_pyutils.metadata_utils import resolve_variant_warehouse_db_name, get_metadata_connection_handle
from ebi_eva_internal_pyutils.mongo_utils import get_mongo_connection_handle
from ebi_eva_internal_pyutils.pg_utils import get_all_results_for_query

from eva_submission.retrieve_eload_and_project_from_lts import ELOADRetrieval
from eva_submission.submission_config import EloadConfig


# noinspection SqlDialectInspection,SqlNoDataSourceInspection
class EloadStatus(AppLogger):

def __init__(self, eload_number: int):
Expand Down Expand Up @@ -117,10 +118,14 @@ def status(self):
else:
all_status = self.status_per_analysis()
writer = csv.DictWriter(sys.stdout, fieldnames=header, delimiter='\t')
# writer.writeheader()
writer.writeheader()
for st in all_status:
writer.writerow(st)

@property
def metadata_connection_handle(self):
return get_metadata_connection_handle(cfg['maven']['environment'], cfg['maven']['settings_file'])

@cached_property
def mongo_conn(self):
return get_mongo_connection_handle(cfg['maven']['environment'], cfg['maven']['settings_file'])
Expand Down Expand Up @@ -222,7 +227,8 @@ def project_information(self, analysis):
current_tax_id = tax_id
filenames = []
filenames.append(filename)
yield current_analysis, current_assembly, current_tax_id, filenames
if current_analysis:
yield current_analysis, current_assembly, current_tax_id, filenames

def get_taxonomy_for_project(self):
taxonomies = []
Expand All @@ -242,6 +248,11 @@ def check_accessioning_was_done(self, analysis, filenames):
"""
accessioning_reports = self.get_accession_reports_for_study()
accessioned_filenames = [self.get_accession_file(f) for f in filenames]
if not accessioning_reports:
# No reports
self.error(f'Cannot assign accessioning report to project {self.project} analysis {analysis} '
f'for files {accessioning_reports}')
return []
if len(accessioning_reports) == 1:
# Only one accessioning report
accessioning_report = accessioning_reports[0]
Expand All @@ -252,19 +263,14 @@ def check_accessioning_was_done(self, analysis, filenames):
# Only one accessioning report that contains the analysis accession in its name
accessioning_report = [r for r in accessioning_reports if analysis in r][0]
elif accessioning_reports:
# Multiple accessioning reports and we cannot figure out which one is for this analysis
# Multiple accessioning reports, and we cannot figure out which one is for this analysis
# Assume that the first one can be used
self.warning(
f'Assume all accessioning reports are from project {self.project}:{analysis} '
f'and only use the first one: {accessioning_reports[0]}\n'
f'All reports: {", ".join(accessioning_reports)}'
)
accessioning_report = accessioning_reports[0]
else:
# No reports
self.error(f'Cannot assign accessioning report to project {self.project} analysis {analysis} '
f'for files {accessioning_reports}')
return []
return self.get_accessioning_info_from_file(accessioning_report)

def get_accession_file(self, filename):
Expand Down

0 comments on commit 3304283

Please sign in to comment.