This is an API based on Proteomics API. Json data was fetched using:
https://www.proteomicsdb.org/proteomicsdb/logic/api/proteinpeptideresult.xsodata/InputParams(PROTEINFILTER='Q92769')/Results?$select=ENTRY_NAME,PROTEIN_NAME,CHROMOSOME_NAME,GENE_NAME,STRAND,PEPTIDE_SEQUENCE,PEPTIDE_MASS,PUBMEDID&$format=json
I left out some fields because I wanted to make a simple schema.
Be sure to setup FLASK_APP environment variable.
ex.
export FLASK_APP=protein-api.py
After setting the environment variables, you can:
- Test the app
flask test
- Initialize DB
flask db init
flask migrate -m "Initial migration"
will make a migration script.flask db upgrade
is equivalent to callingdb.create_all()
- Populate DB with test data.
flask populate
will add protein sequences from cleaned-protein.json file.
- Run the api locally (default will be localhost:5000) with
flask run
The application uses flask-httpauth for JWT token authentication.
Using httpie
http --json GET http://127.0.0.1:5000/api/v1/proteins/
Either way using Postman you can receive/send json data.
5 routes:
- GET http://localhost:5000/api/v1/proteins/
GET ALL ENTRIES - GET http://localhost:5000/api/v1/protein/{id}
GET single entry with specified id. e.g. [...]/protein/5 - POST http://localhost:5000/api/v1/proteins/ {json}
CREATE a new protein entry - PUT http://localhost:5000/api/v1/protein/{id}
UPDATE protein's pubmed id - DELETE http://localhost:5000/api/v1/protein/{id}
DELETE protein entry with id e.g. [...]/protein/5