Back to .md Directory

PRD: ProteinClassify — Transformer-Based Protein Analysis Platform

Defines a full-stack bioinformatics dashboard that classifies protein sequences into 321 families using ESM-2 embeddings, predicts 3D structures, and generates AI explanations.

May 2, 2026
0 downloads
1 views
ai rag gemini
View source

What this file does

Defines a full-stack bioinformatics dashboard that classifies protein sequences into 321 families using ESM-2 embeddings, predicts 3D structures, and generates AI explanations.

When to use it

  • Building a transformer-based protein classification platform
  • Creating a bioinformatics dashboard with ML inference
  • Designing an interactive tool for biology students and researchers
  • Implementing batch FASTA analysis with visualization

Assumes this stack

ReactFlaskPyTorchESM-2Geminiscikit-learn

PRD: ProteinClassify — Transformer-Based Protein Analysis Platform

Version: 1.0 · Author: Manzil · Last Updated: 2026-02-13 Status: SHIPPED (Semester 6 Academic Project)


1. Overview

ProteinClassify is a full-stack bioinformatics dashboard that classifies protein sequences into 321 families using ESM-2 transformer embeddings, predicts 3D structures via ESMFold, and generates AI-powered biological insights using Gemini 2.5 Flash. It targets biology undergrads, researchers, and educators who need fast, interactive protein analysis without GPU infrastructure.


2. Problem Statement

Protein family classification traditionally requires deep bioinformatics expertise, access to large databases (Pfam, InterPro), and command-line tools. Students and early researchers need an accessible, visual tool that:

  1. Classifies unknown protein sequences with high confidence
  2. Visualizes where the protein sits in embedding space relative to known families
  3. Predicts 3D structure from sequence alone
  4. Explains results in human-readable biological language

3. Target Users

PersonaDescriptionPrimary Need
Biology UndergradLearning about protein familiesQuick classification + plain-language explanation
ResearcherExploring novel sequencesBatch analysis, export, embedding visualization
EducatorDemonstrating ML in biologyInteractive demo with visual feedback

4. Core Features

4.1 Single Sequence Classification

  • Input: Amino acid sequence (paste or sample)
  • Output: Predicted family, confidence score, PCA coordinates
  • API: POST /api/predict
  • Validation: Max 2,000 chars, standard amino acid alphabet only (ACDEFGHIKLMNPQRSTVWXY)

4.2 Batch FASTA Upload

  • Input: .fasta file (drag-and-drop or file picker), up to 20 sequences
  • Output: Sortable results table with family, confidence per sequence
  • API: POST /api/predict-batch
  • Export: CSV download, print-to-PDF

4.3 3D Structure Prediction

  • Source: Meta's ESMFold API (single-sequence, no MSA required)
  • Visualization: Interactive 3D viewer via NGL Viewer (rotate, zoom, color by chain)
  • API: POST /api/fold
  • Limits: Sequences capped at 400 residues for the public API

4.4 AI Biological Insights

  • Engine: Google Gemini 2.5 Flash
  • Output: Structured explanation — What is this family? Biological significance? Structural features? Fun fact.
  • API: POST /api/explain
  • Requires: GEMINI_API_KEY env var

4.5 Embedding Space Visualization

  • Method: PCA (2-component) projection of 320-dim ESM-2 embeddings
  • Display: Recharts scatter plot showing training data + user's protein
  • API: GET /api/data

4.6 Sequence Property Heatmaps

  • Properties: Hydrophobicity, polarity, charge
  • Display: Color-coded residue-level heatmap (client-side, no API call)

5. User Stories & Acceptance Criteria

5.1 Student Learning

As a biology student, I want to paste a protein sequence I found in a textbook, So that I can see what family it belongs to and understand its function.

Acceptance Criteria:

  • Paste inputs < 2000 chars are accepted.
  • Classification returns within 3 seconds.
  • "Predicted Family" is clearly displayed.
  • AI explanation answers "What is this?" in simple terms.
  • 3D viewer loads the structure automatically.

5.2 Researcher Batch Analysis

As a bioinformatics researcher, I want to upload a FASTA file with 20 unknowns, So that I can quickly filter them for specific transport proteins.

Acceptance Criteria:

  • Drag-and-drop .fasta support.
  • Progress bar shows batch processing status.
  • Result table allows sorting by "Family" and "Confidence".
  • "Export CSV" button downloads all inputs + predictions.
  • Failed sequences (e.g., non-standard AAs) are highlighted in red.

5.3 Error Handling

As a user, I want clear feedback when I enter invalid data, So that I know how to fix it without page refresh.

Acceptance Criteria:

  • Invalid characters (e.g., "B", "Z", numbers) trigger immediate red error below input.
  • API rate limit (429) shows "Too many requests, please wait 1m" toast.
  • Server error (500) shows a friendly "Service unavailable" message, not a stack trace.

6. UX/UI Flow

6.1 Analysis Flow

  1. Landing: User sees "Analyze Protein" CTA or "Try Sample".
  2. Input:
    • Action: User pastes sequence OR uploads file.
    • Feedback: Real-time validation (length/chars).
  3. Processing:
    • State: "Analyzing..." spinner overlay.
    • Action: Frontend calls /api/predict (and /api/fold in parallel).
  4. Results:
    • Success: Dashboard reveals with animation.
    • Visualization: Charts animate in (0 -> 100%).
    • Interaction: User can rotate 3D model, hover heatmap coordinates.

7. Data Dictionary

Protein Object (Internal & API)

FieldTypeDescription
sequencestringThe amino acid sequence (cleaned).
familystringPredicted label (e.g., "GLOBIN").
confidencefloatSoftmax probability (0.00-1.00).
pca_xfloatX-coordinate in 2D embedding space.
pca_yfloatY-coordinate in 2D embedding space.
pdb_datastringRaw PDB text for 3D viewer.
explanationstringAI-generated text block.

Batch Item Object

FieldTypeDescription
namestringFASTA header (e.g., ">Seq1").
sequencestringThe sequence content.
statusenumpending | loading | complete | error
resultProteinResult object (if complete).
errorstringError message (if error).

8. Success Metrics

MetricGoalTracking Method
Accuracy>95% Top-1 AccuracyTest set validation log
Latency<500ms (P95)API response time log
Retention>3 batch uploads/sessionClient-side analytics (future)
Error Rate<1% 5xx errorsServer error logs

9. Architecture

┌─────────────────────┐     ┌──────────────────────────┐     ┌─────────────────┐
│   React Frontend    │────▶│    Flask Backend (API)    │────▶│  ESMFold API    │
│   (Vite + Tailwind) │     │                          │     │  (Meta)         │
└─────────────────────┘     │  ┌─────────────────────┐ │     └─────────────────┘
                            │  │  ESM-2 Model (local) │ │
                            │  │  MLP Classifier      │ │     ┌─────────────────┐
                            │  │  PCA Visualization   │ │────▶│  Gemini 2.5     │
                            │  └─────────────────────┘ │     │  Flash API      │
                            └──────────────────────────┘     └─────────────────┘

Frontend Stack

TechnologyVersionPurpose
React19.2UI framework
Vite7.3Build tool / dev server
Tailwind CSS3.4Styling
Framer Motion12.xAnimations
Recharts3.7Embedding chart
NGL Viewer2.43D protein structure
Axios1.13HTTP client
Lucide React0.563Icons

Backend Stack

TechnologyPurpose
FlaskAPI server
PyTorch + TransformersESM-2 embedding extraction
scikit-learnMLP classifier + PCA
joblibModel serialization
google-genaiGemini API client

ML Pipeline

StageDetail
ModelESM-2 (facebook/esm2_t6_8M_UR50D) — 8M params, CPU-friendly
Embeddings320-dimensional per-sequence mean pooling
ClassifierMLP (scikit-learn) trained on ~2,000 PDB sequences
Classes321 protein families
Artifactsmodels/real_model.joblib, models/label_encoder.joblib

6. Pages & Components

Pages

PageRoutePurpose
Home/Landing page — hero, features, process, CTA
Analyzer/analyzeMain analysis workspace

Components

ComponentParentPurpose
InputSectionAnalyzerSequence input, FASTA upload, sample buttons
ResultsDashboardAnalyzerOrchestrates all result panels
EmbeddingChartResultsDashboardPCA scatter plot (Recharts)
StructureViewerResultsDashboard3D protein viewer (NGL)
SequenceHeatmapResultsDashboardResidue-level property heatmap
ProteinExplainerResultsDashboardAI-generated insights panel
BatchResultsAnalyzerSortable batch results table
SkeletonDashboardAnalyzerShimmer loading placeholders
ErrorBoundaryAppReact error boundary

7. API Contract

MethodEndpointRate LimitAuthDescription
POST/api/predict30/minOptionalClassify single sequence
POST/api/predict-batch5/minOptionalClassify up to 20 sequences
POST/api/fold10/minOptionalPredict 3D structure
POST/api/explain15/minOptionalAI biological explanation
GET/api/data60/minOptionalTraining data for PCA plot

Security

  • Input validation (regex, length limits)
  • CORS restricted to configured origins
  • Per-IP in-memory rate limiting
  • Optional X-API-Key header auth
  • Secure deserialization (joblib, not pickle)
  • Error sanitization (generic client messages)

8. Configuration

VariableRequiredDefaultPurpose
GEMINI_API_KEYYes (for /explain)Gemini AI insights
FLASK_DEBUGNofalseDebug mode
PORTNo5000Backend port
API_KEYNoEndpoint authentication
CORS_ORIGINSNolocalhost:5173Allowed origins

9. Non-Functional Requirements

RequirementTarget
PerformanceSingle prediction < 3s on CPU
ResponsivenessMobile-first, hamburger nav, responsive typography
AccessibilitySemantic HTML, aria labels on interactive elements
Loading UXSkeleton placeholders matching result layout
ExportCSV + print-to-PDF from dashboard
Error HandlingErrorBoundary + per-endpoint error states

10. Testing

SuiteCountToolCommand
Backend API tests19unittestvenv/bin/python -m unittest tests.test_api -v
Data loader tests3unittestvenv/bin/python -m unittest tests.test_data_loader -v
Frontend lintESLintcd frontend && npm run lint
Frontend unit testsVitestcd frontend && npx vitest run
CodeRabbitGitHub PR reviewAuto-review on push (chill mode)

11. Known Limitations & Future Work

Current Limitations

  • ESMFold API has intermittent SSL issues (esmatlas.com)
  • 321 families — limited coverage of full protein space
  • ESM-2 8M variant — smallest model, lower accuracy than larger variants
  • In-memory rate limiter resets on server restart
  • No user authentication / session persistence

Potential Enhancements

  • User accounts + saved analysis history
  • Upgrade to ESM-2 35M or 150M for better accuracy
  • Multiple Sequence Alignment (MSA) support
  • Comparison mode (classify 2 proteins side-by-side)
  • Real-time structure prediction (local ESMFold instead of API)
  • Dark mode toggle
  • Redis-backed rate limiting for production
  • CI/CD pipeline (GitHub Actions)
  • PWA support for offline-capable sequence analysis

12. File Structure

sem6/
├── app.py                      # Flask API server
├── requirements.txt            # Python dependencies
├── .env.example                # Environment template
├── PRD.md                      # ← This document
├── PLAN.md                     # GSD execution plan
├── STATE.md                    # GSD session memory
├── src/
│   ├── embedding_extractor.py  # ESM-2 embedding generation
│   ├── classifier.py           # MLP neural network
│   └── data_loader.py          # FASTA parsing & preprocessing
├── models/
│   ├── real_model.joblib       # Trained MLP classifier
│   └── label_encoder.joblib    # Label encoder (321 families)
├── data/
│   ├── embeddings_real.npy     # Training embeddings for PCA
│   └── labels_real.npy         # Training labels
├── tests/
│   ├── test_api.py             # API endpoint tests (22 total)
│   └── test_data_loader.py     # Data loader tests
├── frontend/
│   ├── src/
│   │   ├── App.jsx             # Router, Nav, Footer
│   │   ├── pages/
│   │   │   ├── Home.jsx        # Landing page
│   │   │   └── Analyzer.jsx    # Analysis workspace
│   │   ├── components/         # 9 React components
│   │   └── utils/exportUtils   # CSV/PDF export
│   └── package.json
├── scripts/                    # Training & utility scripts
└── .coderabbit.yaml            # CodeRabbit review config

13. Glossary

  • ESM-2: Evolutionary Scale Modeling (v2). A transformer-based protein language model by Meta AI.
  • ESMFold: An end-to-end atomic-level protein structure predictor based on ESM-2.
  • Embedding: A fixed-size vector representation (320-dim) of a protein sequence.
  • PCA: Principal Component Analysis. Dimensionality reduction technique (320D → 2D).
  • FASTA: Text-based format for representing nucleotide or amino acid sequences.
  • PDB: Protein Data Bank format. Atomic coordinate data for 3D structures.
  • Residue: A single monomer within the protein chain (i.e., one amino acid).
  • Gemini: Google's multimodal AI model, used here for text explanation.

What's inside

13 sections covering features, user stories, API contracts, architecture, components, testing, and known limitations.

Change this for your project

  • Replace Manzil777/protein-transformer-learning with your own repository name
  • Replace facebook/esm2_t6_8M_UR50D with your chosen model ID
  • Replace models/real_model.joblib and models/label_encoder.joblib with your trained artifacts
  • Replace GEMINI_API_KEY env var with your own API key or alternative provider

Where it goes

Keep it in your repository where the agent or team that needs it will read it.

Worth borrowing

  • Separate ML pipeline stages (embedding, classifier, PCA) into distinct modules for testability
  • Define acceptance criteria per user story to validate feature completeness
  • Document known limitations and future enhancements alongside the spec to set expectations

Related Documents