forked from MIRRI/mirri_utils
update mirri folder
This commit is contained in:
@@ -37,14 +37,14 @@ TRUEFALSE_TRANSLATOR = {
|
||||
}
|
||||
|
||||
|
||||
def parse_mirri_excel(fhand, version="20200601"):
|
||||
if version == "20200601":
|
||||
return _parse_mirri_v20200601(fhand)
|
||||
def parse_mirri_excel(fhand, version=""):
|
||||
if version == "5.1.2":
|
||||
return _parse_mirri_v12052023(fhand)
|
||||
else:
|
||||
raise NotImplementedError("Only version 20200601 is implemented")
|
||||
raise NotImplementedError("Only version is 5.1.2 implemented")
|
||||
|
||||
|
||||
def _parse_mirri_v20200601(fhand):
|
||||
def _parse_mirri_v12052023(fhand):
|
||||
fhand.seek(0)
|
||||
file_content = BytesIO(fhand.read())
|
||||
wb = load_workbook(filename=file_content, read_only=True, data_only=True)
|
||||
@@ -64,7 +64,6 @@ def _parse_mirri_v20200601(fhand):
|
||||
|
||||
return {"strains": strains, "growth_media": growth_media}
|
||||
|
||||
|
||||
def index_list_by(list_, id_):
|
||||
return {str(item[id_]): item for item in list_}
|
||||
|
||||
@@ -125,7 +124,7 @@ def parse_strains(wb, locations, growth_media, markers, publications,
|
||||
publications = index_list_by_attr(publications, 'id')
|
||||
markers = index_markers(markers)
|
||||
|
||||
for strain_row in workbook_sheet_reader(wb, STRAINS, "Accession number"):
|
||||
for strain_row in workbook_sheet_reader(wb, STRAINS, "accessionNumber"):
|
||||
strain = StrainMirri()
|
||||
strain_id = None
|
||||
label = None
|
||||
@@ -140,7 +139,7 @@ def parse_strains(wb, locations, growth_media, markers, publications,
|
||||
collection, number = value.split(" ", 1)
|
||||
value = StrainId(collection=collection, number=number)
|
||||
rsetattr(strain, attribute, value)
|
||||
|
||||
|
||||
elif attribute == "restriction_on_use":
|
||||
rsetattr(strain, attribute, RESTRICTION_USE_TRANSLATOR[value])
|
||||
elif attribute == "nagoya_protocol":
|
||||
@@ -202,9 +201,19 @@ def parse_strains(wb, locations, growth_media, markers, publications,
|
||||
items = value.split(";")
|
||||
strain.collect.location.latitude = float(items[0])
|
||||
strain.collect.location.longitude = float(items[1])
|
||||
strain.collect.location.precision = float(items[2])
|
||||
strain.collect.location.altitude = float(items[3])
|
||||
if len(items) > 4:
|
||||
strain.collect.location.coord_uncertainty = items[4]
|
||||
|
||||
elif attribute == "collect.site.links":
|
||||
items = value.split(";")
|
||||
strain.collect.site.links.nameSite = str(items[0])
|
||||
strain.collect.site.links.urlSite = str(items[1])
|
||||
rsetattr(strain, attribute, value.split(";")) #ver o separador
|
||||
if len(items) > 2:
|
||||
strain.collect.location.coord_uncertainty = items[2]
|
||||
|
||||
strain.collect.site.links.site_uncertainty = items[2]
|
||||
|
||||
elif attribute == "collect.location":
|
||||
location = locations[value]
|
||||
if 'Country' in location and location['Country']:
|
||||
|
||||
Reference in New Issue
Block a user