This project is a Django REST API that provides functionality for user authentication, compound data retrieval, IC50 prediction, and Google authentication.
- User Authentication
- Registration
- Login (JWT Authentication)
- Google OAuth Login
- Compound Data Management
- Retrieve a list of compounds
- Retrieve detailed compound information
- Prediction Management
- Submit SMILES strings for IC50 prediction
- Retrieve a list of user-specific predictions
- View detailed prediction data
- Backend: Django, Django REST Framework
- Authentication: Simple JWT, Google OAuth
- Database: PostgreSQL
- External APIs: PubChem for compound data
Sebelum memulai, pastikan Anda sudah menginstal hal-hal berikut:
- Python ^3.9
- pip (Python package installer)
- PostgreSQL (jika menggunakan PostgreSQL sebagai database)
Ikuti langkah-langkah berikut untuk meng-clone dan men-setup proyek.
Clone repository proyek ke mesin lokal Anda menggunakan Git:
git clone https://github.com/DaffaNofiansyah/antimalaria-backend.git
cd antimalaria-backend
python -m venv venv
.\venv\Scripts\activate
pip install -r requirements.txt
File requirements.txt mencakup paket-paket berikut:
Django==5.1.4 djangorestframework psycopg2 (untuk PostgreSQL) django-environ (untuk mengelola env) djangorestframework-simplejwt (untuk JWT authentication)
Pastikan database PostgreSQL sudah disiapkan sebelumnya. Buat file .env di root proyek dan tambahkan variabel lingkungan yang diperlukan (seperti pengaturan database):
DB_NAME=(nama_database)
DB_USER=(user_database)
DB_PASSWORD=(password_database)
DB_HOST=localhost
DB_PORT=5432
Jalankan migrasi untuk menyiapkan skema database:
python manage.py migrate
python manage.py runserver
This API provides authentication, compound prediction, and user management features. It supports user registration, login, token-based authentication, compound data retrieval, and IC50 prediction.
https://antimalaria-backend-production.up.railway.app/
This API uses JWT authentication.
- Obtain tokens via
/login/
- Refresh tokens via
/refresh-token/
Endpoint:
POST /register/
Request Body:
{
"username": "your_username",
"email": "[email protected]",
"password": "your_password",
"password2": "your_password"
}
Response:
{
"message": "User registered successfully"
}
Endpoint:
POST /login/
Request Body:
{
"username": "your_username",
"password": "your_password"
}
Response:
{
"refresh": "your_refresh_token",
"access": "your_access_token",
"username": "your_username",
"email": "your_email"
}
Endpoint:
POST /refresh-token/
Request Body:
{
"refresh": "your_refresh_token"
}
Response:
{
"access": "new_access_token"
}
Endpoint:
GET /compounds/base/
Response:
[
{
"id": 1,
"iupac_name": "ethene",
"smiles": "C=C",
"cid": 6325,
"ic50": 4.262408256530762,
"category": "Inactive",
"molecular_formula": "C2H4",
"molecular_weight": "28.05",
"synonyms": "ETHYLENE, Ethene, Acetene, Elayl, Olefiant gas, 74-85-1, Athylen, Etileno, Bicarburretted hydrogen, Liquid ethylene, Ethylene, pure, Caswell No. 436, Aethylen, ...",
"inchi": "InChI=1S/C2H4/c1-2/h1-2H2",
"inchikey": "VGGSQFUCUMXWEO-UHFFFAOYSA-N",
"structure_image": "https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=6325&t=l",
"description": "Ethene is an alkene and a gas molecular entity. It has a role as a refrigerant and a plant hormone."
},
{
"id": 2,
"iupac_name": "ethene",
"smiles": "C=C",
"cid": 6325,
"ic50": 4.262408256530762,
"category": "Inactive",
"molecular_formula": "C2H4",
"molecular_weight": "28.05",
"synonyms": "ETHYLENE, Ethene, Acetene, Elayl, Olefiant gas, 74-85-1, Athylen, Etileno, Bicarburretted hydrogen, Liquid ethylene, Ethylene, pure, Caswell No. 436, Aethylen, ...",
"inchi": "InChI=1S/C2H4/c1-2/h1-2H2",
"inchikey": "VGGSQFUCUMXWEO-UHFFFAOYSA-N",
"structure_image": "https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=6325&t=l",
"description": "Ethene is an alkene and a gas molecular entity. It has a role as a refrigerant and a plant hormone."
}
]
Endpoint:
GET /compounds/
Headers:
Authorization: Bearer your_access_token
Response:
[
{
"id": 1,
"iupac_name": "ethene",
"smiles": "C=C",
"cid": 6325,
"ic50": 4.262408256530762,
"category": "Inactive",
"molecular_formula": "C2H4",
"molecular_weight": "28.05",
"synonyms": "ETHYLENE, Ethene, Acetene, Elayl, Olefiant gas, 74-85-1, Athylen, Etileno, Bicarburretted hydrogen, Liquid ethylene, Ethylene, pure, Caswell No. 436, Aethylen, ...",
"inchi": "InChI=1S/C2H4/c1-2/h1-2H2",
"inchikey": "VGGSQFUCUMXWEO-UHFFFAOYSA-N",
"structure_image": "https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=6325&t=l",
"description": "Ethene is an alkene and a gas molecular entity. It has a role as a refrigerant and a plant hormone."
},
{
"id": 2,
"iupac_name": "ethene",
"smiles": "C=C",
"cid": 6325,
"ic50": 4.262408256530762,
"category": "Inactive",
"molecular_formula": "C2H4",
"molecular_weight": "28.05",
"synonyms": "ETHYLENE, Ethene, Acetene, Elayl, Olefiant gas, 74-85-1, Athylen, Etileno, Bicarburretted hydrogen, Liquid ethylene, Ethylene, pure, Caswell No. 436, Aethylen, ...",
"inchi": "InChI=1S/C2H4/c1-2/h1-2H2",
"inchikey": "VGGSQFUCUMXWEO-UHFFFAOYSA-N",
"structure_image": "https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=6325&t=l",
"description": "Ethene is an alkene and a gas molecular entity. It has a role as a refrigerant and a plant hormone."
}
]
Endpoint:
GET /predictions/
Headers:
Authorization: Bearer your_access_token
Response:
[
{
"id": 1,
"user": "your_username",
"model": "model_name",
"jenis_malaria": "default",
"created_at": "timestamps"
},
{
"id": 2,
"user": "your_username",
"model": "model_name",
"jenis_malaria": "default",
"created_at": "timestamps"
}
]
Endpoint:
GET /predictions/<int:prediction_id>/
Headers:
Authorization: Bearer your_access_token
Response:
[
{
"id": 1,
"iupac_name": "ethene",
"smiles": "C=C",
"cid": 6325,
"ic50": 4.262408256530762,
"category": "Inactive",
"molecular_formula": "C2H4",
"molecular_weight": "28.05",
"synonyms": "ETHYLENE, Ethene, Acetene, Elayl, Olefiant gas, 74-85-1, Athylen, Etileno, Bicarburretted hydrogen, Liquid ethylene, Ethylene, pure, Caswell No. 436, Aethylen, ...",
"inchi": "InChI=1S/C2H4/c1-2/h1-2H2",
"inchikey": "VGGSQFUCUMXWEO-UHFFFAOYSA-N",
"structure_image": "https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=6325&t=l",
"description": "Ethene is an alkene and a gas molecular entity. It has a role as a refrigerant and a plant hormone."
},
{
"id": 2,
"iupac_name": "ethene",
"smiles": "C=C",
"cid": 6325,
"ic50": 4.262408256530762,
"category": "Inactive",
"molecular_formula": "C2H4",
"molecular_weight": "28.05",
"synonyms": "ETHYLENE, Ethene, Acetene, Elayl, Olefiant gas, 74-85-1, Athylen, Etileno, Bicarburretted hydrogen, Liquid ethylene, Ethylene, pure, Caswell No. 436, Aethylen, ...",
"inchi": "InChI=1S/C2H4/c1-2/h1-2H2",
"inchikey": "VGGSQFUCUMXWEO-UHFFFAOYSA-N",
"structure_image": "https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=6325&t=l",
"description": "Ethene is an alkene and a gas molecular entity. It has a role as a refrigerant and a plant hormone."
}
]
Endpoint:
GET /compounds/<int:compound_id>/
Headers:
Authorization: Bearer your_access_token
Response:
{
"id": 1,
"iupac_name": "ethene",
"smiles": "C=C",
"cid": 6325,
"ic50": 4.262408256530762,
"category": "Inactive",
"molecular_formula": "C2H4",
"molecular_weight": "28.05",
"synonyms": "ETHYLENE, Ethene, Acetene, Elayl, Olefiant gas, 74-85-1, Athylen, Etileno, Bicarburretted hydrogen, Liquid ethylene, Ethylene, pure, Caswell No. 436, Aethylen, ...",
"inchi": "InChI=1S/C2H4/c1-2/h1-2H2",
"inchikey": "VGGSQFUCUMXWEO-UHFFFAOYSA-N",
"structure_image": "https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=6325&t=l",
"description": "Ethene is an alkene and a gas molecular entity. It has a role as a refrigerant and a plant hormone.",
"prediction": 1
}
Endpoint:
DELETE /predictions/<int:prediction_id>/delete
Headers:
Authorization: Bearer your_access_token
Endpoint:
DELETE /compounds/<int:compound_id>/delete
Headers:
Authorization: Bearer your_access_token
πΉ ECFP Models
- Deep Learning, ECFP
model_ECFP_DL.h5
βmodel_descriptor = ecfp
,model_method = dl
- Random Forest, ECFP
rf_model_ecfp.pkl
βmodel_descriptor = ecfp
,model_method = rf
- XGBoost, ECFP
xgb_model_ecfp.json
βmodel_descriptor = ecfp
,model_method = xgb
πΉ MACCS Models
- Deep Learning, MACCS
model_MACCS_DL.h5
βmodel_descriptor = maccs
,model_method = dl
- Random Forest, MACCS
rf_model_maccs.pkl
βmodel_descriptor = maccs
,model_method = rf
- XGBoost, MACCS
xgb_model_maccs.json
βmodel_descriptor = maccs
,model_method = xgb
πΉ PubchemFP Models
- Deep Learning, Mordred
model_PubchemFp_DL.h5
βmodel_descriptor = pubchemfp
,model_method = dl
- Random Forest, Mordred
rf_model_pubchemfp.pkl
βmodel_descriptor = pubchemfp
,model_method = rf
- XGBoost, Mordred
xgb_model_pubchemfp.json
βmodel_descriptor = pubchemfp
,model_method = xgb
Endpoint:
POST /predict/
Headers:
Authorization: Bearer your_access_token
Request Body:
{
"smiles": "C=C, CHO, H2O, ..",
"model_descriptor": "model_descriptor",
"model_method": "model_method"
}
OR
{
"file": ".csv/.json",
"model_descriptor": "model_descriptor",
"model_method": "model_method"
}
Response:
[
{
"id": 1,
"iupac_name": "ethene",
"smiles": "C=C",
"cid": 6325,
"ic50": 4.262408256530762,
"category": "Inactive",
"molecular_formula": "C2H4",
"molecular_weight": "28.05",
"synonyms": "ETHYLENE, Ethene, Acetene, Elayl, Olefiant gas, 74-85-1, Athylen, Etileno, Bicarburretted hydrogen, Liquid ethylene, Ethylene, pure, Caswell No. 436, Aethylen, ...",
"inchi": "InChI=1S/C2H4/c1-2/h1-2H2",
"inchikey": "VGGSQFUCUMXWEO-UHFFFAOYSA-N",
"structure_image": "https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=6325&t=l",
"description": "Ethene is an alkene and a gas molecular entity. It has a role as a refrigerant and a plant hormone."
},
{
"id": 1,
"iupac_name": "ethene",
"smiles": "C=C",
"cid": 6325,
"ic50": 4.262408256530762,
"category": "Inactive",
"molecular_formula": "C2H4",
"molecular_weight": "28.05",
"synonyms": "ETHYLENE, Ethene, Acetene, Elayl, Olefiant gas, 74-85-1, Athylen, Etileno, Bicarburretted hydrogen, Liquid ethylene, Ethylene, pure, Caswell No. 436, Aethylen, ...",
"inchi": "InChI=1S/C2H4/c1-2/h1-2H2",
"inchikey": "VGGSQFUCUMXWEO-UHFFFAOYSA-N",
"structure_image": "https://pubchem.ncbi.nlm.nih.gov/image/imgsrv.fcgi?cid=6325&t=l",
"description": "Ethene is an alkene and a gas molecular entity. It has a role as a refrigerant and a plant hormone."
},
]