-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from michabirklbauer/develop
Develop
- Loading branch information
Showing
18 changed files
with
33,930 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This workflow will lint with Python 3.10 | ||
# e.g. check for syntax errors and undefined names | ||
# Reference workflow provided by (c) GitHub | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: peptide_matching_game | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
pull_request: | ||
branches: [ master ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.10' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics |
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 Micha Birklbauer, FH OOE Campus Hagenberg BIN Research Group | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,33 @@ | ||
# peptide-matching-game | ||
Peptide Matching Game Solution Browser | ||
# Peptide Matching Game | ||
|
||
A simple game to illustrate how peptide identification in mass spectra works | ||
using database search engines like [MS Amanda](https://pubs.acs.org/doi/full/10.1021/pr500202e). | ||
|
||
## Usage | ||
|
||
**How the game works:** | ||
- Read through the [game instructions](https://github.com/michabirklbauer/peptide_matching_game/blob/master/Game_Rules.pdf). | ||
|
||
**Setting up the game:** | ||
- Print the [game poster](https://github.com/michabirklbauer/peptide_matching_game/blob/master/Game_Poster.pdf). | ||
- Print at least one copy of each spectrum in `spectrum_cards`. | ||
- Print the [game instructions](https://github.com/michabirklbauer/peptide_matching_game/blob/master/Game_Rules.pdf) for people to understand the game. | ||
- [Optional] Set up your own game solution browser or use [https://michabirklbauer.github.io/peptide_matching_game/](https://michabirklbauer.github.io/peptide_matching_game/) so people are able to check their solutions. | ||
|
||
**Setting up the game solution browser:** | ||
- Install requirements: `pip install -r requirements.txt` | ||
- Run streamlit app: `streamlit run streamlit_app.py` | ||
- Alternatively pull and run the docker container: `docker run -p 8501:8501 michabirklbauer/peptidematchinggame:latest` | ||
- Open your browser and navigate to `localhost:8501`. | ||
|
||
## References | ||
|
||
- PDB structure [3RFM](https://www.rcsb.org/structure/3RFM) by [Dore et al.](http://dx.doi.org/10.1016/j.str.2011.06.014) is shown on the poster. | ||
|
||
## License | ||
|
||
- [MIT](https://github.com/michabirklbauer/peptide_matching_game/blob/master/LICENSE) | ||
|
||
## Contact | ||
|
||
- [[email protected]](mailto:[email protected]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from matplotlib import pyplot as plt | ||
import ms2pip.single_prediction | ||
import spectrum_utils.spectrum as spectrum | ||
import spectrum_utils.plot as spectrum_plot | ||
|
||
## 5 x 4 matrix | ||
|
||
peptide_1 = "PLPGER" | ||
peptide_2 = "FIYAYR" | ||
peptide_3 = "GEQVSLR" | ||
peptide_4 = "DRYIAIR" | ||
peptide_5 = "ARSTLQK" | ||
|
||
# a 3 - easy | ||
# y4 matches only 3 | ||
peptides_1 = ["PLFGER", "PLHGER", "PLPGER", "PLGGER"] | ||
# b 2 - medium | ||
# b3 is only correct in 2 | ||
peptides_2 = ["FIFAYR", "FIYAYR", "FIHAYR", "FIKAYR"] | ||
# c 3 - medium | ||
# b3 intensity only matches 3 | ||
peptides_3 = ["GEQASLR", "GEQTSLR", "GEQVSLR", "GEQSSLR"] | ||
# d 1 - hard | ||
# b3 and y4 only correct in 1 | ||
peptides_4 = ["DRYIAIR", "DRYFAIR", "DRYWAIR", "DRYPAIR"] | ||
# e 4 - hard | ||
# b4 and b5 of 1, 2 are too intense, b4 of 3 is off by ~15 Da | ||
peptides_5 = ["ARSILQK", "ARSLLQK", "ARSSLQK", "ARSTLQK"] | ||
|
||
gridlines = False | ||
|
||
|
||
all_peptides = [peptides_1, | ||
peptides_2, | ||
peptides_3, | ||
peptides_4, | ||
peptides_5] | ||
|
||
def get_spectrum(peptide_sequence, charge = 1): | ||
|
||
model = ms2pip.single_prediction.SinglePrediction() | ||
mz, intensity, annotation = model.predict(peptide_sequence, "-", charge, model = "HCD2021") | ||
identifier = f"{peptide_sequence}/{charge}/-" | ||
precursor_mz = model.mod_info.calc_precursor_mz(peptide_sequence, "-", charge) | ||
mod_dict = model._modifications_to_dict("-") | ||
spectrum_annotation = model._get_sus_annotation(mz, annotation) | ||
|
||
s = spectrum.MsmsSpectrum(identifier, | ||
precursor_mz, | ||
charge, | ||
mz, | ||
intensity, | ||
annotation = spectrum_annotation, | ||
peptide = peptide_sequence, | ||
modifications = mod_dict) | ||
|
||
return s | ||
|
||
def main(): | ||
fig, axs = plt.subplots(5,4, figsize = (25,20), dpi = 300, tight_layout = True) | ||
i = 0 | ||
rows = ["A", "B", "C", "D", "E"] | ||
for peptide_group in all_peptides: | ||
j = 0 | ||
for peptide in peptide_group: | ||
s = get_spectrum(peptide) | ||
spectrum_plot.spectrum(s, ax = axs[i, j]) | ||
axs[i, j].set_title(rows[i] + str(j + 1) + " - " + peptide) | ||
axs[i, j].set_xlim([0, 900]) | ||
axs[i, j].grid(visible = gridlines, which = "both") | ||
j += 1 | ||
i += 1 | ||
|
||
plt.savefig("result.svg") | ||
|
||
def main2(): | ||
rows = ["A", "B", "C", "D", "E"] | ||
for i, peptide in enumerate([peptide_1, peptide_2, peptide_3, peptide_4, peptide_5]): | ||
s = get_spectrum(peptide) | ||
fig = plt.figure(figsize = (8,4.5)) | ||
plt.title("Peptide Group " + rows[i]) | ||
spectrum_plot.spectrum(s) | ||
plt.xlim([0, 900]) | ||
plt.grid(visible = gridlines, which = "both") | ||
plt.savefig(rows[i] + ".svg") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
main2() |
Oops, something went wrong.