mgbam commited on
Commit
bf50c62
·
verified ·
1 Parent(s): e35b779

Update genesis/biosecurity.py

Browse files
Files changed (1) hide show
  1. genesis/biosecurity.py +70 -26
genesis/biosecurity.py CHANGED
@@ -1,30 +1,74 @@
1
  # genesis/biosecurity.py
2
  """
3
- Biosecurity intelligence module for GENESIS-AI
4
- Fetches latest biosecurity guidelines, laws, and alerts globally.
5
  """
6
 
7
- import requests
8
- import os
9
-
10
- BIOPORTAL_API_KEY = os.getenv("BIOPORTAL_API_KEY")
11
- WHO_BIOSECURITY_FEED = "https://www.who.int/feeds/entity/csr/don/en/rss.xml" # Example WHO disease outbreak feed
12
-
13
- def get_who_biosecurity_updates():
14
- """Fetch latest biosecurity updates from WHO RSS."""
15
- try:
16
- r = requests.get(WHO_BIOSECURITY_FEED)
17
- r.raise_for_status()
18
- return r.text # Can parse XML later in app.py for display
19
- except Exception as e:
20
- return {"error": str(e)}
21
-
22
- def search_biosecurity_terms(term):
23
- """Search BioPortal for biosecurity-related ontology terms."""
24
- try:
25
- url = f"https://data.bioontology.org/search?q={term}&apikey={BIOPORTAL_API_KEY}"
26
- r = requests.get(url)
27
- r.raise_for_status()
28
- return r.json()
29
- except Exception as e:
30
- return {"error": str(e)}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # genesis/biosecurity.py
2
  """
3
+ Biosecurity Risk Assessment Module for GENESIS-AI
4
+ Analyzes potential dual-use or misuse risks of synthetic biology research.
5
  """
6
 
7
+ import logging
8
+
9
+ logging.basicConfig(level=logging.INFO)
10
+
11
+ def analyze_biosecurity_risks(entity_name: str, description: str = ""):
12
+ """
13
+ Analyze biosecurity risks for a given entity (gene, protein, organism, or technology).
14
+ Returns a structured dictionary of risks, severity, and mitigation suggestions.
15
+
16
+ Args:
17
+ entity_name (str): Name of the biological entity.
18
+ description (str, optional): Additional context or description.
19
+
20
+ Returns:
21
+ dict: Biosecurity risk profile.
22
+ """
23
+ logging.info(f"[Biosecurity] Assessing risks for: {entity_name}")
24
+
25
+ # Simple keyword-based heuristic
26
+ high_risk_keywords = ["smallpox", "anthrax", "ebola", "h5n1", "plague", "ricin", "botulinum"]
27
+ medium_risk_keywords = ["viral vector", "gain-of-function", "CRISPR", "dual-use"]
28
+
29
+ risk_level = "Low"
30
+ risk_factors = []
31
+
32
+ text_to_check = f"{entity_name} {description}".lower()
33
+
34
+ for kw in high_risk_keywords:
35
+ if kw in text_to_check:
36
+ risk_level = "High"
37
+ risk_factors.append(f"Contains high-risk keyword: {kw}")
38
+
39
+ if risk_level != "High":
40
+ for kw in medium_risk_keywords:
41
+ if kw in text_to_check:
42
+ risk_level = "Medium"
43
+ risk_factors.append(f"Contains medium-risk keyword: {kw}")
44
+
45
+ # If no match, still return low risk baseline
46
+ if not risk_factors:
47
+ risk_factors.append("No known high/medium risk indicators detected.")
48
+
49
+ mitigation_suggestions = []
50
+ if risk_level == "High":
51
+ mitigation_suggestions = [
52
+ "Engage institutional biosecurity committee immediately.",
53
+ "Restrict access to authorized personnel.",
54
+ "Perform BSL-3/BSL-4 lab containment assessment.",
55
+ "Consult WHO guidance for dangerous pathogens."
56
+ ]
57
+ elif risk_level == "Medium":
58
+ mitigation_suggestions = [
59
+ "Review project with bioethics board.",
60
+ "Use gene synthesis screening services.",
61
+ "Ensure compliance with NIH and WHO guidelines."
62
+ ]
63
+ else:
64
+ mitigation_suggestions = [
65
+ "Maintain good laboratory practices.",
66
+ "Continue monitoring for any emerging risks."
67
+ ]
68
+
69
+ return {
70
+ "entity": entity_name,
71
+ "risk_level": risk_level,
72
+ "risk_factors": risk_factors,
73
+ "mitigation": mitigation_suggestions
74
+ }