include check for flagged properties
@@ -230,6 +230,8 @@ def check_dates(data, today):
"21D (Eta)": "2020-11-21",
"21E (Theta)": "2021-01-10",
"21F (Iota)": "2020-11-20",
+ "21G (Lambda)": "2021-01-05",
+ "21H": "2021-01-05",
}
invalid_sample_date = {}
@@ -315,6 +317,48 @@ def check_dates(data, today):
return data
+flagged_properties = {"originating_lab": ["Synlab Haut de France"]}
+
+# Check for certain unique properties and potentially exclude (e.g. all sequences from a certain submission lab)
+def check_flagged_properties(data):
+
+ flagged_strains = {}
+ for p in flagged_properties:
+ flagged_strains[p] = {}
+ for name in flagged_properties[p]:
+ flagged_strains[p][name] = []
+
+ seqs_found = False
+ for id in list(data.keys()):
+ strain = data[id]["strain"]
+ exclude = False
+ for p in flagged_properties:
+ prop = data[id][p]
+ for name in flagged_properties[p]:
+ if prop == name:
+ flagged_strains[p][name].append(strain)
+ seqs_found = True
+ exclude = True
+ if exclude:
+ data.pop(id)
+
+ if seqs_found:
+ print(bold("\nFlagged properties found! Please check outputs_new_sequences/sequences_exclude.txt for strain names to exclude") + " (automatically excluded from total counts).\n")
+ else:
+ print("\nNo flagged properties found.\n")
+
+ with open(path_to_outputs + "sequences_exclude.txt", "w") as out:
+ out.write("\n\nStrains to add to exclude (based on flagged properties):\n")
+ for p in flagged_strains:
+ for name in flagged_properties[p]:
+ out.write(p + " = \"" + name + "\":\n")
+ for strain in flagged_strains[p][name]:
+ out.write(strain + "\n")
+ out.write("\n")
+
+ return data
+
+
# Plot distribution of dates to detect suspicious behaviour, e.g. large bunch of sequences from the same date
def plot_dates(data, path):
dates_by_country = {}
@@ -759,6 +803,7 @@ today = str(datetime.datetime.now())[:10]
if __name__ == '__main__':
data, list_of_strains = read_data(path_to_input)
data = check_dates(data, today)
+ data = check_flagged_properties(data)
#plot_dates(data, path_to_outputs + "plots/")
counts = print_counts(data)
lab_collection = collect_labs(data, table_file_name)
