Skip to content

Commit

Permalink
fix lon and lat digits
Browse files Browse the repository at this point in the history
  • Loading branch information
KateSakharova committed Feb 20, 2024
1 parent 22e107f commit e5bc45c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
14 changes: 8 additions & 6 deletions genomeuploader/genome_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@

ena = ENA()

GEOGRAPHY_DIGIT_COORDS = 8

'''
Input table: expects the following parameters:
genome_name: genome file name
Expand Down Expand Up @@ -402,19 +404,19 @@ def extract_ENA_info(genomeInfo, uploadDir, webin, password):

location = sampleInfo["location"]
if 'N' in location:
latitude = str(float(location.split('N')[0].strip()))
longitude = location.split('N')[1].strip()
latitude = str(round(float(location.split('N')[0].strip()), GEOGRAPHY_DIGIT_COORDS))
longitude = str(round(float(location.split('N')[1].strip()), GEOGRAPHY_DIGIT_COORDS))
elif 'S' in location:
latitude = '-' + str(float(location.split('S')[0].strip()))
longitude = location.split('S')[1].strip()
latitude = '-' + str(round(float(location.split('S')[0].strip()), GEOGRAPHY_DIGIT_COORDS))
longitude = str(round(float(location.split('S')[1].strip()), GEOGRAPHY_DIGIT_COORDS))
else:
latitude = "not provided"
longitude = "not provided"

if 'W' in longitude:
longitude = '-' + str(float(longitude.split('W')[0].strip()))
longitude = '-' + str(round(float(longitude.split('W')[0].strip()), GEOGRAPHY_DIGIT_COORDS))
elif longitude.endswith('E'):
longitude = str(float(longitude.split('E')[0].strip()))
longitude = str(round(float(longitude.split('E')[0].strip()), GEOGRAPHY_DIGIT_COORDS))

country = sampleInfo["country"].split(':')[0]
if not country in GEOGRAPHIC_LOCATIONS:
Expand Down
5 changes: 3 additions & 2 deletions requirements.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
name: genome_uploader
channels:
- bioconda
- conda-forge
- defaults
dependencies:
- python=3.10
- requests=2.26.0
- pandas=1.3.3
- pandas=1.4.1
- ena-webin-cli
- python-dotenv=1.0.1

0 comments on commit e5bc45c

Please sign in to comment.