This project builds a clean and reproducible pipeline to extract PSSM and structural features from protein sequences, starting only from g_data.csv.
- Input:
g_data.csvinside thedata/directory. - Goal: Generate individual
.fastafiles, one per protein.
Problem:
The original g_data.csv contained the amino acid 'U' (Selenocysteine), which causes errors in:
- SPOT-1D
- PSI-BLAST
- PSSM matrix generation
Solution:
- Manually replaced all occurrences of
'U'with'X'directly ing_data.csv. - Then generated
.fastafiles.
- Downloaded SwissProt database (
uniprot_sprot.fasta) from UniProt FTP. - Unzipped the database.
- Created a BLAST+ database using:
makeblastdb -in uniprot_sprot.fasta -dbtype prot- Ran PSI-BLAST (
psiblast) for each.fastafile insidedata/fasta_files/. - Used the SwissProt BLAST database prepared earlier.
- Settings used:
- Number of iterations: 3
- E-value cutoff: 0.001
- Saved the output
.pssmfiles inside thepssm_outputs/folder.
Command used to run multiple PSI-BLAST jobs in parallel:
bash code/run_psiblast.shAfter generating .pssm files from PSI-BLAST, the following features were extracted:
| Feature Set | Number of Features |
|---|---|
| PSSM-AAO (Amino Acid Occurrence) | 20 |
| PSSM-SD (Standard Deviation over Segments) | 80 |
| PSSM-SAC (Sequence Autocovariance) | 100 |
Each .pssm file was processed using the following scripts:
code/extract_pssm_aao.py→ outputsfeatures/pssm_aao.csvcode/extract_pssm_sd.py→ outputsfeatures/pssm_sd.csvcode/extract_pssm_sac.py→ outputsfeatures/pssm_sac.csv
- PSSM-AAO: Summation of scores across all amino acids.
- PSSM-SD: Mean and standard deviation values across 4 segments.
- PSSM-SAC: Autocovariance of scores across 5 segments with a lag of 10.
- Cloned SPOT-1D-Single into the
SPOT-1D-Single/folder. - Downloaded and extracted pre-trained models and standardization files (
means_single.pkl,stds_single.pkl). - Modified SPOT-1D-Single to:
- Accept
.fastafile paths directly. - Output predictions into the
spot1d_outputs/folder.
- Accept
- Always pass the output folder (
spot1d_outputs/) as--save_path, not individual filenames. - SPOT-1D automatically names each
.csvfile after the protein ID.
python code/run_spot1d_batch.pyThe batch script picks each .fasta file from data/fasta_files/, runs SPOT-1D prediction, and saves the corresponding .csv output in spot1d_outputs/.
Following the generation of SPOT-1D outputs, the following structural features were extracted:
| Feature Set | Number of Features |
|---|---|
| ASA Bigram | 1 |
| SS3 Autocovariance (Lag 10) | 30 |
| Torsion Composition (Phi, Psi, Theta, Tau) | 4 |
- Cleaned Protein_IDs by removing
>and whitespace. - Merged all six features using
Protein_IDas the key. - Joined with labels from
g_data.csv.
python merge_features.py
python merge_labels.pyOutput: final_training_data.csv
- SVM (RBF kernel) —
C=3000,γ=0.005 - K-Nearest Neighbors
- Naive Bayes
- Random Forest
- Bagging Classifier
- ANN (MLPClassifier)
- Train/Test Split (80/20)
- 10-Fold Cross-Validation
- Jackknife (LOOCV)
| Model | 10-Fold CV Accuracy | Jackknife Accuracy |
|---|---|---|
| SVM | 67.11% | 67.88% |
| K-NN | 68.25% | – |
| Naive Bayes | 60.63% | – |
| Random Forest | 73.05% | 72.66% |
| Bagging | 71.14% | 71.89% |
| ANN (MLP) | 72.26% | 71.51% |
✅ Best Performer: Random Forest
✅ Most Consistent: Random Forest & ANN
- 10-Fold CV accuracy comparison saved as:
Evaluation/accuracy_plot.png
Scripts used:
code/extract_asa_bigram.py→ outputsfeatures/asa_bigram.csvcode/extract_ss3_autocov.py→ outputsfeatures/ss3_autocov.csvcode/extract_torsion_composition.py→ outputsfeatures/torsion_composition.csv
- ASA Bigram: Mean of ASA[i] × ASA[i+2] across sequence.
- SS3 Autocovariance: Measures autocorrelation for Coil (C), Helix (H), and Strand (E) probabilities across 10 lags.
- Torsion Composition: A simple means of torsion angles is Phi, Psi, Theta, Tau.
ML_Final_project/
|
├── data/
│ └── fasta_files/ # All input .fasta files
├── pssm_outputs/ # PSI-BLAST output .pssm files
├── spot1d_outputs/ # SPOT-1D-Single output .csv files
├── features/ # Extracted feature CSVs
│ ├── pssm_aao.csv
│ ├── pssm_sac.csv
│ ├── pssm_sd.csv
│ ├── asa_bigram.csv
│ ├── ss3_autocov.csv
│ └── torsion_composition.csv
├── code/
│ ├── run_psiblast.sh
│ ├── run_spot1d_batch.py
│ ├── extract_pssm_aao.py
│ ├── extract_pssm_sd.py
│ ├── extract_pssm_sac.py
│ ├── extract_asa_bigram.py
│ ├── extract_ss3_autocov.py
│ └── extract_torsion_composition.py
├── SPOT-1D-Single/ # SPOT-1D model code and models
├── README.md
├── environment.yml
└── requirements.txt
python generate_fasta.py
bash code/run_psiblast.sh
python code/run_spot1d_batch.py
python extract_all_features.py
python merge_features.py
python merge_labels.py
python train_svm.py
python train_cv.py
python train_jackknife.py- Replaced invalid amino acid 'U' with 'X' early to prevent PSI-BLAST and SPOT-1D failures.
- Standardized
.fastafile generation. - Corrected file path handling inside SPOT-1D-Single.
- Created clean, parallelized batch processing.
- Safely handled missing output files and sequences during feature extraction.
- Cleaned inconsistent header formats
- Merged features and labels robustly
- Handled class imbalance (Fold2 had very few samples)
