This repository contains the backend API for the eDNA classification project. It uses FastAPI to serve a PyTorch deep learning model that predicts the phylum of an organism based on a raw DNA sequence.
Follow these instructions to get a local copy of the project up and running for development and testing.
Make sure you have Python 3.8+ installed on your system.
-
Clone the repository:
git clone https://github.com/ssrithwik007/eDNA-backend.git cd eDNA-backend -
Create and activate a virtual environment:
# Create the virtual environment python -m venv venv # Activate it: # On Windows (PowerShell) .\venv\Scripts\activate # On macOS / Linux source venv/bin/activate
-
Install the required packages: This command reads the
requirements.txtfile and installs all the necessary libraries for the project.pip install -r requirements.txt
Once the installation is complete, you can run the API server.
From the project's root directory (backend), run the following command to start the Uvicorn server:
uvicorn app.main:app --reloadThe --reload flag makes the server restart automatically when you make changes to the code.
The API will now be running and available at http://127.0.0.1:8000. 🚀
You can interact with the API in two primary ways:
-
Interactive Docs (Recommended): Navigate to
http://127.0.0.1:8000/docsin your browser to see the automatically generated Swagger UI documentation. You can test the endpoints directly from this page. -
Using
curl: You can send a POST request to the/predictendpoint from your terminal.curl -X 'POST' \ 'http://127.0.0.1:8000/predict' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "sequence": "GTCGATCGGCTAGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCATGCTAGCTAGCA" }'