Skip to content

Commit

Permalink
EVA-3304 - Validate the presence of the collection location and date (#…
Browse files Browse the repository at this point in the history
…155)

* Validate the presence of the collection location and date
* Update test
Co-authored-by: April Shen <april.tuesday@gmail.com>
  • Loading branch information
tcezard authored Jun 14, 2023
1 parent 673280c commit 7c9fa0c
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 3 deletions.
14 changes: 13 additions & 1 deletion eva_submission/biosamples_submission.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,11 @@ class SampleMetadataSubmitter(SampleSubmitter):
'ecotype', 'isolate', 'strain', 'sub_species', 'variety', 'sub_strain', 'cell_line',
'serotype', 'serovar']

characteristic_defaults = {
'collection_date': 'not provided',
'geographic location (country and/or sea)': 'not provided'
}

submitter_mapping = {
'Email Address': 'E-mail',
'First Name': 'FirstName',
Expand Down Expand Up @@ -405,7 +410,14 @@ def map_metadata_to_bsd_data(self):
self.map_sample_key(attribute.lower()),
[{'text': self.serialize(value)}]
)

# Apply defaults if the key doesn't already exist
for key in self.characteristic_defaults:
if key not in sample_row:
self.apply_mapping(
bsd_sample_entry['characteristics'],
self.map_sample_key(key.lower()),
[{'text': self.serialize(self.characteristic_defaults[key])}]
)
project_row = self.reader.project
for key in self.reader.project:
if key in self.project_mapping:
Expand Down
3 changes: 2 additions & 1 deletion eva_submission/xlsx/xlsx_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def complex_validation(self):
self.group_of_fields_required(
'Sample', row,
['Analysis Alias', 'Sample Accession', 'Sample ID'],
['Analysis Alias', 'Sample Name', 'Title', 'Tax Id', 'Scientific Name']
['Analysis Alias', 'Sample Name', 'Title', 'Tax Id', 'Scientific Name', 'collection_date',
'geographic location (country and/or sea)']
)

def semantic_validation(self):
Expand Down
Binary file modified tests/resources/brokering/metadata_sheet2.xlsx
Binary file not shown.
Binary file modified tests/resources/brokering/metadata_sheet_fail.xlsx
Binary file not shown.
Binary file modified tests/resources/brokering/metadata_wrong_scientific_name.xlsx
Binary file not shown.
Binary file modified tests/resources/metadata.xlsx
Binary file not shown.
3 changes: 2 additions & 1 deletion tests/test_submit_to_bsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,8 @@ def test_map_metadata_to_bsd_data(self):
'Organism': [{'text': 'Homo sapiens'}],
'description': [{'text': 'Sample %s' % (i+1)}],
'scientific name': [{'text': 'Homo sapiens'}],
'collection_date': [{'text': '2020-01-15'}]
'collection_date': [{'text': '2020-01-15'}],
'geographic location (country and/or sea)': [{'text': 'not provided'}]
}}
for i in range(100)
]
Expand Down

0 comments on commit 7c9fa0c

Please sign in to comment.