Spaces:
Sleeping

Arko006 commited on
Commit
dfa6c70
·
verified ·
1 Parent(s): f62b821

Upload agent/structural_alerts.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. agent/structural_alerts.py +81 -0
agent/structural_alerts.py ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from rdkit import Chem
2
+
3
+ STRUCTURAL_ALERTS_DB = {
4
+ "aromatic_amine": {
5
+ "smarts": "c[NH2]",
6
+ "name": "Primary Aromatic Amine",
7
+ "detail": "Known to undergo metabolic activation forming mutagenic nitrenium ions.",
8
+ },
9
+ "alkyl_halide": {
10
+ "smarts": "[CX4][Cl,Br,I]",
11
+ "name": "Alkyl Halide",
12
+ "detail": "Direct-acting alkylating agent; electrophilic risk of DNA damage.",
13
+ },
14
+ "hydrazine": {
15
+ "smarts": "[NX3][NX3]",
16
+ "name": "Hydrazine",
17
+ "detail": "Associated with genotoxic risk and reactive oxygen species generation.",
18
+ },
19
+ "aldehyde": {
20
+ "smarts": "[CX3H1](=O)[#6]",
21
+ "name": "Aldehyde",
22
+ "detail": "Highly reactive electrophile; risk of DNA-protein crosslinks.",
23
+ },
24
+ "nitro": {
25
+ "smarts": "[NX3](=O)=O",
26
+ "name": "Nitro Aromatic",
27
+ "detail": "Undergoes metabolic reduction to reactive nitroso and hydroxylamine intermediates.",
28
+ },
29
+ "epoxide": {
30
+ "smarts": "[O]1[CH][CH]1",
31
+ "name": "Epoxide",
32
+ "detail": "Highly strained electrophilic ring; direct DNA alkylation risk.",
33
+ },
34
+ "quinone": {
35
+ "smarts": "O=c1cccc(=O)c1",
36
+ "name": "Quinone",
37
+ "detail": "Redox-active species generating ROS and forming covalent adducts.",
38
+ },
39
+ "azide": {
40
+ "smarts": "[NX2-]N#[N+]",
41
+ "name": "Azide",
42
+ "detail": "Explosive and reactive; potential for bioorthogonal toxicity.",
43
+ },
44
+ "aflatoxin_b1_like": {
45
+ "smarts": "O=C1OC2C3OC3C=CC2=C1",
46
+ "name": "Aflatoxin-like Furan",
47
+ "detail": "Metabolic epoxidation leads to DNA adduct formation.",
48
+ },
49
+ "beta_lactam": {
50
+ "smarts": "O=C1[CH][CH]N1",
51
+ "name": "Beta-Lactam",
52
+ "detail": "Acylating agent; risk of hypersensitivity and covalent protein binding.",
53
+ },
54
+ }
55
+
56
+
57
+ def identify_structural_alerts(smiles: str, high_attribution_indices: list = None):
58
+ mol = Chem.MolFromSmiles(smiles)
59
+ if mol is None:
60
+ return []
61
+
62
+ alerts_found = []
63
+
64
+ for key, alert in STRUCTURAL_ALERTS_DB.items():
65
+ pattern = Chem.MolFromSmarts(alert["smarts"])
66
+ if pattern is None:
67
+ continue
68
+ matches = mol.GetSubstructMatches(pattern)
69
+ for match in matches:
70
+ match_attributed = False
71
+ if high_attribution_indices and match:
72
+ match_attributed = any(idx in high_attribution_indices for idx in match)
73
+
74
+ alerts_found.append({
75
+ "alert_name": alert["name"],
76
+ "details": alert["detail"],
77
+ "matched_atoms": list(match),
78
+ "high_attribution": match_attributed,
79
+ })
80
+
81
+ return alerts_found