This directory contains Python scripts demonstrating how to programmatically query the DigestedProteinDB database via its public REST API. DigestedProteinDB is a high-performance database of theoretically digested proteins, designed to support peptide identification in mass spectrometry (MS) experiments.
- Python 3.7+
requestslibrary
Install the dependency with:
pip install requestsA self-contained example script that demonstrates the three most common query patterns against the DigestedProteinDB REST API endpoint:
GET https://digestedproteindb.pbf.hr/search.php
| Example | Description |
|---|---|
| 1 | Search by an explicit mass range (mass1 / mass2 parameters) |
| 2 | Search by a peptide amino acid sequence — the script computes the monoisotopic mass locally and queries with a configurable mass tolerance (±0.02 Da by default) |
| 3 | Retrieve a specific page of results using the page and pageSize parameters |
| Parameter | Type | Description |
|---|---|---|
mass1 |
float | Lower bound of the mass range (Da, inclusive) |
mass2 |
float | Upper bound of the mass range (Da, inclusive) |
page |
integer | Page number (default: 1) |
pageSize |
integer | Results per page (default: 10, max: 1000) |
The API returns JSON with the following structure:
{
"totalResult": 431,
"page": 1,
"pageSize": 10,
"duration": "00:00:00.024",
"memory": "2012 MB",
"result": [
{
"1247.5001": [
{
"seq": "SSSTSSTDSTTST",
"acc": ["A0A822EEP4"]
}
]
}
]
}result— list of objects keyed by the peptide mass; each value is a list of peptidesseq— peptide amino acid sequence (single-letter code)acc— list of UniProt accession numbers of proteins containing this peptide
python example_rest_api.pyExpected output (truncated):
=================================================================
Example 1: search by mass range (1247.50 – 1247.52)
=================================================================
Total results : 118
Page : 1 / pageSize=5
Duration : 00:00:00.001
Memory : 2012 MB
-----------------------------------------------------------------
Mass: 1247.5001 Sequence: SSSTSSTDSTTST Acc: A0A822EEP4
Mass: 1247.5002 Sequence: SWGDHNCHHR Acc: M7BXC7
...
The helper functions can be imported and used directly in your own scripts or Jupyter notebooks:
from example_rest_api import search_by_mass, search_by_peptide
# Query a narrow mass window around a measured MS peak
results = search_by_mass(mass1=1500.70, mass2=1500.72, page_size=100)
# Or search by sequence with a custom tolerance
results = search_by_peptide("ALELFR", tolerance_da=0.01, page_size=50)
for item in results["result"]:
for mass, peptides in item.items():
for pep in peptides:
print(pep["seq"], pep["acc"])Full API documentation is available at:
https://digestedproteindb.pbf.hr/rest.php