Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Bug fixes: Handled 'collection date' error and ENA error when uploadi…
Browse files Browse the repository at this point in the history
…ng reads manifests
  • Loading branch information
Sherida101 committed Nov 30, 2023
1 parent ce2901a commit 0eae863
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
2 changes: 1 addition & 1 deletion web/apps/web_copo/utils/dtol/Dtol_Helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def check_taxon_ena_submittable(taxon, by="id"):
errors.append("TAXON_ID " + taxon + " is not submittable to ENA")
if taxinfo[0]["rank"] not in ["species", "subspecies"]:
errors.append("TAXON_ID " + taxon + " is not a 'species' or 'subspecies' level entity.")
if taxinfo["binomial"] == "false":
if taxinfo[0]["binomial"] == "false":
errors.append(msg['validation_msg_invalid_binomial_name'] % (taxon, taxinfo["scientificName"]))
except Exception as e:
l.exception(e)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from web.apps.web_copo.validators.validator import Validator
from web.apps.web_copo.validators.validation_messages import MESSAGES as msg
from dal.copo_da import Sample
Expand Down Expand Up @@ -53,8 +54,22 @@ def validate(self):
regex = field.get("regex","")
if regex:
if not re.match(regex, row):
self.errors.append("Invalid value '" + row + "' in column : '" + field["name"] + "' at row " + str(i))
self.flag = False
if column == 'collection date':
# Remove the time part from the date string if it is present
try:
result = bool(datetime.strptime(row, "%Y-%m-%d %H:%M:%S"))
except ValueError:
result = False

if result:
row = row.split(' ')[0]
self.data.at[i-2, column] = row
else:
self.errors.append("Invalid value '" + row + "' in column : '" + field["name"] + "' at row " + str(i))
self.flag = False
else:
self.errors.append("Invalid value '" + row + "' in column : '" + field["name"] + "' at row " + str(i))
self.flag = False
elif type == "TAXON_FIELD":
if row not in biosampleAccessionsMap.keys():
self.errors.append("Invalid value " + row + " in column:'" + field["name"] + "'")
Expand Down
2 changes: 1 addition & 1 deletion web/apps/web_copo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ def agave_oauth(request):

def import_ena_accession(request):
if request.method == 'GET':
profile_id = request.session['profile_id']
profile_id = request.session.get('profile_id','')
return render(request, 'copo/import_ena_accession.html', {'profile_id': profile_id})
else:
accessions = request.POST['accessions']
Expand Down

0 comments on commit 0eae863

Please sign in to comment.