From 438176d3d328ddf85e0033f7b58d6a935772ef29 Mon Sep 17 00:00:00 2001 From: Tapasweni Pathak Date: Sat, 25 Feb 2023 22:29:51 +0530 Subject: [PATCH] Add base for c++ xeus-cling google collab mybinder.org notebooks --- README.md | 28 ++++++++++++++++- Tutorial_AASequence.ipynb | 66 +++++++++++++++++++++++++++++++++++++++ environment.yml | 7 +++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 Tutorial_AASequence.ipynb create mode 100644 environment.yml diff --git a/README.md b/README.md index 4db827c..1e77450 100644 --- a/README.md +++ b/README.md @@ -1 +1,27 @@ -# cling-notebooks \ No newline at end of file +# cling-notebooks + +This repository contains xeus-cling notebooks of OpenMS C++ code example files. + +Users can run in local or try it online on mybinder.org. + +## To run in local + +1. Create conda environment `cling-notebooks` using: `conda create -n cling-notebooks`. +2. Activate conda environment using: `conda activate cling-notebooks`. +3. Install xeus-cling using: `conda install xeus-cling -c conda-forge`. +4. Install jupyterlab using: `conda install jupyterlab -c conda-forge`. +5. Install openms using conda or bioconda following the instructions given [here](https://openms.readthedocs.io/en/latest/installations/installation-on-macos.html#install-via-conda-or-bioconda). +6. Browse for the `.ipynb` notebooks and click on run. + +## Browse the C++ notebooks online on mybinder.org + +https://mybinder.org/v2/gh/OpenMS/OpenMS/develop?urlpath=https%3A%2F%2Fgithub.com%2Ftapaswenipathak%2FOpenMS%2Fblob%2Fdevelop%2FTutorial_AASequence.ipynb + +## Browse the C++ notebooks on Google Collab + +## Troubleshooting + +Please read the issues having documentation on common errors you might get and how +to resolve them. + +Let us know if you get errors not already mentioned. diff --git a/Tutorial_AASequence.ipynb b/Tutorial_AASequence.ipynb new file mode 100644 index 0000000..a39b2ff --- /dev/null +++ b/Tutorial_AASequence.ipynb @@ -0,0 +1,66 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "182ebb96", + "metadata": {}, + "outputs": [], + "source": [ + "#include \n", + "#pragma base add_include_path(\"/Users/tapaswenipathak/miniconda3/envs/cling/include/OpenMS/\")\n", + "#include \"OpenMS/CHEMISTRY/AASequence.h\"\n", + "\n", + "using namespace OpenMS;\n", + "using namespace std;\n", + "\n", + "\n", + " // generate AASequence object from String\n", + " const String s = \"DEFIANGER\";\n", + " AASequence peptide1 = AASequence::fromString(s);\n", + "\n", + " // generate AASequence object from string literal\n", + " AASequence peptide2 = AASequence::fromString(\"PEPTIDER\");\n", + "\n", + " // extract prefix and suffix\n", + " AASequence prefix(peptide1.getPrefix(2));\n", + " AASequence suffix(peptide1.getSuffix(3));\n", + " cout << peptide1.toString() << \" \"\n", + " << prefix << \" \"\n", + " << suffix << endl;\n", + " \n", + " // create chemically modified peptide\n", + " AASequence peptide_meth_ox = AASequence::fromString(\"PEPTIDESEKUEM(Oxidation)CER\");\n", + " cout << peptide_meth_ox.toString() << \" \"\n", + " << peptide_meth_ox.toUnmodifiedString()\n", + " << endl;\n", + "\n", + " // mass of the full, uncharged peptide\n", + " double peptide_mass_mono = peptide_meth_ox.getMonoWeight();\n", + " cout << \"Monoisotopic mass of the uncharged, full peptide: \" << peptide_mass_mono << endl;\n", + "\n", + " double peptide_mass_avg = peptide_meth_ox.getAverageWeight();\n", + " cout << \"Average mass of the uncharged, full peptide: \" << peptide_mass_avg << endl;\n", + "\n", + " // mass of the 2+ charged b-ion with the given sequence\n", + " double ion_mass_2plus = peptide_meth_ox.getMonoWeight(Residue::BIon, 2);\n", + " cout << \"Mass of the doubly positively charged b-ion: \" << ion_mass_2plus << endl;\n", + "\n", + " // mass-to-charge ratio (m/z) of the 2+ charged b-ion and full peptide with the given sequence\n", + " cout << \"Mass-to-charge of the doubly positively charged b-ion: \" << peptide_meth_ox.getMZ(2, Residue::BIon) << endl;\n", + " cout << \"Mass-to-charge of the doubly positively charged peptide: \" << peptide_meth_ox.getMZ(2) << endl;\n", + "\n", + " // ... many more\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "C++17", + "language": "C++17", + "name": "xeus-cling-cpp17" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..4220173 --- /dev/null +++ b/environment.yml @@ -0,0 +1,7 @@ +name: openms +channels: + - openms + - conda-forge +dependencies: + - xeus-cling + - openms