LLM / molecules.py
anaghanagesh's picture
Update molecules.py
30e8770 verified
# molecules.py
def generate_molecules(symptoms):
symptoms = symptoms.lower()
categories = {
"pain": {
"name": "Ibuprofen",
"smiles": "CC(C)CC1=CC=C(C=C1)C(C)C(=O)O",
"molecular_weight": "206.28"
},
"fever": {
"name": "Paracetamol",
"smiles": "CC(=O)NC1=CC=C(O)C=C1",
"molecular_weight": "151.16"
},
"infection": {
"name": "Amoxicillin",
"smiles": "CC1(C)S[C@@H]2[C@H](NC(=O)C(N)=O)C(=O)N2[C@H]1C(O)=O",
"molecular_weight": "365.40"
},
"allergy": {
"name": "Cetirizine",
"smiles": "CN1CCC(CC1)OC2=CC=CC=C2C(C(=O)O)N",
"molecular_weight": "388.89"
},
"nausea": {
"name": "Ondansetron",
"smiles": "CN1CCC(CC1)C2=NC3=CC=CC=C3N=C2N",
"molecular_weight": "293.36"
},
"stomach": {
"name": "Omeprazole",
"smiles": "COC1=NC=NC2=C1N=CN2S(=O)CC3=CN=C(C=C3)OC",
"molecular_weight": "345.42"
},
"cough": {
"name": "Dextromethorphan",
"smiles": "CN1CCC23CCCCC2C1CC4=C3C=CC(=C4)OC",
"molecular_weight": "271.40"
},
"skin": {
"name": "Hydrocortisone",
"smiles": "CC(=O)C1CC[C@H]2[C@@H]3CCC4=CC(=O)C=C[C@]4(C)[C@H]3[C@@H](O)C[C@]12C",
"molecular_weight": "362.46"
},
"breathing": {
"name": "Salbutamol",
"smiles": "CC(C)(C)NCC(C1=CC(=C(C=C1)O)CO)O",
"molecular_weight": "239.31"
},
"heart": {
"name": "Nitroglycerin",
"smiles": "C(C(CO[N+](=O)[O-])O[N+](=O)[O-])O[N+](=O)[O-]",
"molecular_weight": "227.09"
}
}
symptom_map = {
# PAIN
"headache": "pain",
"migraine": "pain",
"body pain": "pain",
"joint pain": "pain",
"muscle pain": "pain",
"back pain": "pain",
"neck pain": "pain",
"leg pain": "pain",
"tooth pain": "pain",
"ear pain": "pain",
# FEVER
"fever": "fever",
"high temperature": "fever",
"chills": "fever",
"viral fever": "fever",
"sweating": "fever",
# INFECTION
"infection": "infection",
"bacterial infection": "infection",
"sore throat": "infection",
"swelling": "infection",
"pus": "infection",
# ALLERGY
"allergy": "allergy",
"sneezing": "allergy",
"itching": "allergy",
"watery eyes": "allergy",
"runny nose": "allergy",
# NAUSEA
"nausea": "nausea",
"vomiting": "nausea",
"dizziness": "nausea",
"motion sickness": "nausea",
# STOMACH
"stomach pain": "stomach",
"abdominal pain": "stomach",
"acid reflux": "stomach",
"gas": "stomach",
"indigestion": "stomach",
"bloating": "stomach",
"ulcer": "stomach",
"constipation": "stomach",
"diarrhea": "stomach",
# COUGH
"cough": "cough",
"dry cough": "cough",
"cold": "cough",
"flu": "cough",
"throat irritation": "cough",
# SKIN
"rash": "skin",
"skin irritation": "skin",
"eczema": "skin",
"redness": "skin",
"burning skin": "skin",
"acne": "skin",
# BREATHING
"breathing difficulty": "breathing",
"shortness of breath": "breathing",
"asthma": "breathing",
"wheezing": "breathing",
"lung congestion": "breathing",
# HEART
"chest pain": "heart",
"heart pain": "heart",
"palpitations": "heart",
"high blood pressure": "heart",
"cardiac discomfort": "heart"
}
for key in symptom_map:
if key in symptoms:
category = symptom_map[key]
return [categories[category]]
# DEFAULT
return [{
"name": "Paracetamol",
"smiles": "CC(=O)NC1=CC=C(O)C=C1",
"molecular_weight": "151.16"
}]