add comparison to clade date
@@ -97,6 +97,21 @@ def read_data(path, path_to_metadata):
# Double check sample dates for invalid format or unrealistic / impossible date
def check_dates(data, today):
+ clade_dates = {
+ "19A": "2019-12-01",
+ "19B": "2019-12-01",
+ "20A": "2020-01-20",
+ "20A.EU2": "2020-02-15",
+ "20B": "2020-02-14",
+ "20C": "2020-02-25",
+ "20D": "2020-03-12",
+ "20E (EU1)": "2020-05-27",
+ "20F": "2020-05-24",
+ "20G": "2020-06-11",
+ "20H/501Y.V2": "2020-08-10",
+ "20I/501Y.V1": "2020-09-20",
+ "20J/501Y.V3": "2020-10-29"
+ }
invalid_sample_date = {}
suspicious_sample_date = {}
@@ -132,15 +147,31 @@ def check_dates(data, today):
continue
#Check for early dates
- if (year == 2020 and (month == 2 or month == 1)) or year == 2019:
- suspicious_sample_date[strain] = date
+ #if (year == 2020 and (month == 2 or month == 1)) or year == 2019:
+ #suspicious_sample_date[strain] = date
+
+ clade = data[id]["Nextstrain_clade"]
+ if clade not in clade_dates:
+ print("Unknown clade " + clade + " for sequence " + id)
+ else:
+ clade_day = clade_dates[clade]
+ day_clade = int(clade_day[8:])
+ month_clade = int(clade_day[5:7])
+ year_clade = int(clade_day[:4])
+
+ if (year < year_clade) or (year == year_clade and month < month_clade) or (year == year_clade and month == month_clade and day < day_clade):
+ suspicious_sample_date[strain] = date + ", " + clade
+ data.pop(id)
+ continue
+
+
print("\n----------------------------------------------\n")
print("Invalid sample dates (please check whether all are automatically excluded):")
for strain in invalid_sample_date:
print(strain + ": " + invalid_sample_date[strain])
- print("\nEarly sample dates (might require double checking depending on country):")
+ print("\nSample date before clade:")
for strain in suspicious_sample_date:
print(strain + ": " + suspicious_sample_date[strain])
