From 15b98b1b7b9668dd48367a7103bcebc005384a35 Mon Sep 17 00:00:00 2001 From: Ge94 Date: Mon, 22 Jul 2024 16:53:22 +0100 Subject: [PATCH] Error handling on metadata improved --- genomeuploader/genome_upload.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/genomeuploader/genome_upload.py b/genomeuploader/genome_upload.py index a9691ec..9763605 100755 --- a/genomeuploader/genome_upload.py +++ b/genomeuploader/genome_upload.py @@ -410,15 +410,17 @@ def extract_ENA_info(genomeInfo, uploadDir, webin, password): elif longitude.endswith('E'): longitude = longitude.split('E')[0].strip() - if latitude: - latitude = "{:.{}f}".format(round(float(latitude), GEOGRAPHY_DIGIT_COORDS), GEOGRAPHY_DIGIT_COORDS) - else: - raise IOError("Latitude could not be parsed. Check metadata for run {}.".format(runAccession)) - - if longitude: - longitude = "{:.{}f}".format(round(float(longitude), GEOGRAPHY_DIGIT_COORDS), GEOGRAPHY_DIGIT_COORDS) - else: - raise IOError("Longitude could not be parsed. Check metadata for run {}.".format(runAccession)) + if latitude != "not provided": + try: + latitude = "{:.{}f}".format(round(float(latitude), GEOGRAPHY_DIGIT_COORDS), GEOGRAPHY_DIGIT_COORDS) + except ValueError: + raise IOError("Latitude could not be parsed. Check metadata for run {}.".format(runAccession)) + + if longitude != "not provided": + try: + longitude = "{:.{}f}".format(round(float(longitude), GEOGRAPHY_DIGIT_COORDS), GEOGRAPHY_DIGIT_COORDS) + except ValueError: + raise IOError("Longitude could not be parsed. Check metadata for run {}.".format(runAccession)) country = sampleInfo["country"].split(':')[0] if not country in GEOGRAPHIC_LOCATIONS: