SKILL.md
Version Compatibility
Reference examples tested with: pandas 2.2+
Before using code patterns, verify installed versions match. If versions differ:
- Python:
pip show <package>thenhelp(module.function)to check signatures
If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.
Epitope Prediction
"Predict B-cell and T-cell epitopes in my protein" → Identify immunogenic regions in antigens for vaccine design using sequence-based and structure-based prediction tools.
- Python: IEDB API for B-cell epitope prediction (BepiPred)
- Python:
mhcflurryfor T-cell epitope MHC binding prediction
B-Cell Epitope Prediction
Goal: Predict linear B-cell epitopes from protein sequence using IEDB prediction tools.
Approach: Submit sequence to IEDB B-cell prediction API with selectable method (BepiPred-2.0 recommended) and parse tab-separated results.
BepiPred-2.0 (Sequence-Based)
import requests
def predict_bcell_epitopes_iedb(sequence, method='bepipred2'):
'''Predict B-cell epitopes using IEDB API
Methods:
- bepipred2: Deep learning (recommended)
- bepipred: Original BepiPred
- emini: Surface accessibility
- kolaskar-tongaonkar: Antigenicity
- parker: Hydrophilicity
BepiPred-2.0 uses deep learning on crystal structures
Threshold: >0.5 predicted as epitope (default)
'''
url = 'http://tools-cluster-interface.iedb.org/tools_api/bcell/'
params = {
'method': method,
'sequence_text': sequence
}
response = requests.post(url, data=params)
# Parse response (tab-separated)
lines = response.text.strip().split('\n')
header = lines[0].split('\t')
data = [line.split('\t') for line in lines[1:]]
return header, data
Parse BepiPred Results
import pandas as pd
def parse_bepipred_results(header, data, threshold=0.5):
'''Parse BepiPred output and identify epitope regions
Output columns:
- Position: Amino acid position
- Residue: Amino acid
- Score: BepiPred score (higher = more likely epitope)
Epitope threshold:
- >0.5: Default, balanced sensitivity/specificity
- >0.6: More stringent, fewer false positives
- >0.4: More sensitive, more candidates
'''
df = pd.DataFrame(data, columns=header)
df['Score'] = df['Score'].astype(float)
df['Position'] = df['Position'].astype(int)
# Identify epitope regions
df['is_epitope'] = df['Score'] > threshold
# Find continuous epitope regions
epitopes = []
current_epitope = []
for _, row in df.iterrows():
if row['is_epitope']:
current_epitope.append(row)
else:
if len(current_epitope) >= 5: # Minimum epitope length
epitopes.append({
'start': current_epitope[0]['Position'],
'end': current_epitope[-1]['Position'],
'sequence': ''.join(r['Residue'] for r in current_epitope),
'avg_score': sum(r['Score'] for r in current_epitope) / len(current_epitope)
})
current_epitope = []
return df, epitopes
