Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
sorenwacker committed May 12, 2022
0 parents commit c0c0b98
Show file tree
Hide file tree
Showing 156 changed files with 172,277 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM python:3.7
EXPOSE 9999

RUN mkdir -p /data

COPY requirements.txt .
COPY local_wheels/dash_uploader-0.5.0-py3-none-any.whl /local_wheels/dash_uploader-0.5.0-py3-none-any.whl

RUN pip3 install -r requirements.txt

COPY . /app
WORKDIR /app
RUN pip3 install .

ENV MINT_DATA_DIR /data

ENV SQLALCHEMY_DATABASE_URI sqlite:///data/mint.db

RUN pip install local_wheels/dash_uploader-0.5.0-py3-none-any.whl

CMD ./entrypoint.sh

50 changes: 50 additions & 0 deletions InnoSetup/InnoSetupScript.iss
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "MINT"
#define MyAppVersion "0.0.56"
#define MyAppPublisher "Lewis Research Group (University of Calgary)"
#define MyAppURL "https://github.com/sorenwacker/ms-mint"
#define MyAppExeName "Mint.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application. Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{652041E1-F20B-404B-887C-5BF4D059631F}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion}
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={autopf}\{#MyAppName}
DisableProgramGroupPage=yes
LicenseFile=C:\Users\soere\workspace\ms-mint\LICENSE
InfoBeforeFile=C:\Users\soere\workspace\ms-mint\README.md
; Remove the following line to run in administrative install mode (install for all users.)
PrivilegesRequired=lowest
OutputBaseFilename=mysetup
SetupIconFile=C:\Users\soere\workspace\ms-mint\ms_mint\static\logo\logo.ico
Compression=lzma
SolidCompression=yes
WizardStyle=modern

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

[Files]
Source: "C:\Users\soere\workspace\ms-mint\dist\Mint\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
Source: "C:\Users\soere\workspace\ms-mint\dist\Mint\*"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon

[Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent

6 changes: 6 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Copyright 2019 Soren Wacker
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.
5 changes: 5 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
include setup.cfg
include versioneer.py
include ms_mint/_version.py
include static/ChEBI-Chem.parquet
include static/ChEBI-Groups.parquet
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

publish:
rm dist/*.*
python3 setup.py sdist bdist_wheel
python3 -m twine upload --repository ms-mint dist/ms*mint-*

lint:
flake8

test:
pytest --cov=ms_mint --cov-report html
rm images/coverage.svg
coverage-badge -o images/coverage.svg

pyinstaller:
cd specfiles && pyinstaller --onedir --noconfirm Mint__onedir__.spec --additional-hooks-dir=hooks

docs:
mkdocs build && mkdocs gh-deploy

deploy:
python setup.py sdist bdist_wheel
python -m twine upload --repository ms-mint dist/ms*mint-*
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[![Python package](https://github.com/sorenwacker/ms-mint/actions/workflows/pythonpackage.yml/badge.svg)](https://github.com/sorenwacker/ms-mint/actions/workflows/pythonpackage.yml)
[![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/5178/badge)](https://bestpractices.coreinfrastructure.org/projects/5178)
![](images/coverage.svg)
[![Github All Releases](https://img.shields.io/github/downloads/sorenwacker/ms-mint/total.svg)]()
[![CodeQL](https://github.com/sorenwacker/ms-mint/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/sorenwacker/ms-mint/actions/workflows/codeql-analysis.yml)
[![Docker Image CI](https://github.com/sorenwacker/ms-mint/actions/workflows/docker-image.yml/badge.svg)](https://github.com/sorenwacker/ms-mint/actions/workflows/docker-image.yml)

![](docs/image/MINT-logo.jpg)

# MINT (Metabolomics Integrator)

The Metabolomics Integrator (MINT) is a post-processing tool for liquid chromatography-mass spectrometry (LCMS) based metabolomics.
Metabolomics is the study of all metabolites (small chemical compounds) in a biological sample e.g. from bacteria or a human blood sample.
The metabolites can be used to define biomarkers used in medicine to find treatments for diseases or for the development of diagnostic tests
or for the identification of pathogens such as methicillin resistant _Staphylococcus aureus_ (MRSA).
More information on how to install and run the program can be found in the [Documentation](https://sorenwacker.github.io/ms-mint/) or check out the
[Quickstart](https:///sorenwacker.github.io/ms-mint/quickstart/) to jump right into it.

# Browser based as standalone application or server based

![](./docs/image/distributions.png)

A demo server is available [here](https://mint.resistancedb.org). Be mindful, you share the server with others.

# Metabolomics with Python

MINT originally started as Python project. The core of MINT is a Python class for targeted metabolomics that can be used independent of the graphical application.

from ms_mint.notebook import Mint
mint.ms_files = glob('/path/to/files/*mzML')
mint.peaklist_files = '/path/to/peaklist/file/peaklist.csv'
mint.run()
mint.results

![Mint Jupyter Results](./docs/image/jupyter_results.png "Mint Jupyter Results")


# Contributions are welcome
MINT integrates open-source software and packages into a Python library for metabolomics with a browser based GUI. It is programmed by scientists for scientists to contribute to better and faster science integrating best practices of data management and computer science. Contributions are welcome that improve the efficiency of the code, bug fixes, feature implementations, security enhancements among others. If you want to contribute to MINT please send me a notification.

### How to contribute

#### Errors, Feedback, Feature Requests
If you encounter an error, if you have a request for a new feature, or for general feedback, please open a new ticket at the [issue tracker](https://github.com/sorenwacker/ms-mint/issues).

#### Code contributions
If your are up to enhance the codebase yourself, we ask you to followowing steps:

1. fork the repository
1. implement the new feature or bug-fix
1. add corresponding tests
2. run `flake8`
3. submit a pull request

#### Code standards
Before submitting a pull request please run `flake8`.

## Get in touch

Open an [issue](https://github.com/sorenwacker/ms-mint/issues) or join the [slack](https://ms-mint.slack.com/) channel.

# Acknowledgements
This project would not be possible without the help of the open-source community.
The tools and resources provided by GitHub, Docker-Hub, the Python Package Index, as well the answers from dedicated users on [Stackoverflow](stackoverflow.com)
and the [Plotly community](https://community.plotly.com/), as well as the free open-source packages used are the foundation of this project.
Several people have made direct contributions to the codebase and we are extremely grateful for that.

- @rokm refactored the specfile for `Pyinstaller` to create a windows package.
- @bucknerns helped with the configuration of the `versioneer` file.

Last but not least, we want to thank all the users and early adopters that drive the development with feature requests and bug reports.

37 changes: 37 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "MINT Server",
"description": "MINT server with authentification wrapper",
"keywords": [
"Flask",
"Dash",
"Plotly"
],
"repository": "https://github.com/sorenwacker/ms-mint",
"success_url": "/",
"env": {
"SECRET_KEY": {
"description": "A secret key for verifying the integrity of signed cookies.",
"generator": "secret"
},
"FLASK_APP": {
"description": "app/entrypoint.sh",
"value": "dashapp"
}
},
"formation": {
"web": {
"quantity": 1,
"size": "free"
}
},
"addons": [
{
"plan": "heroku-postgresql:hobby-dev"
}
],
"buildpacks": [
{
"url": "heroku/python"
}
]
}
44 changes: 44 additions & 0 deletions docs/background.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Background

## What is LCMS?
A typical biological sample, such as human blood or agar with some kind of bacteria, can contain thousands of [metabolites](https://en.wikipedia.org/wiki/Metabolite) such as sugars, alcohols, amino acids, nucleotides and more. To meassure the composition of such a sample [mass spectrometry](https://en.wikipedia.org/wiki/Mass_spectrometry) can be used.

However, many metabolites share exact masses with other metabolites and therefore would be undistiguishable in the mass spectrometer.
Therefore, compounds are sorted using [column chromatography](https://en.wikipedia.org/wiki/Column_chromatography) and spread out over time.
The metabolites that enter the column at the same time interact with the column in different ways based on their specific stereochemistry.
These interactions let compounds move faster or slower through the column and therefore the compounds will elude at different times.
That way various metabolites can be analysed successively over certain timeframe rather than simultaneously.

The mass spectrometer that follows the chromatographic column meassures the masses given at each point in time and returns a time dependent spectrogram.
An example of a LSMS meassurement is visualized in the following figure:

![](image/demo_Saureus_sample_raw.png)<br/>
_**Figure 1:**_ A 2D-histogram of a MS1 recorded intensities taken over time span of 10 minutes. Shown are m/z values between 100 and 600 [Da/z].

If we zoom into this figure to a very narrow band of masses the traces of individual metabolites can be observed. The
trace of succinate (or [succinic acid](https://en.wikipedia.org/wiki/Succinic_acid)) is shown here:

![](image/demo_Saureus_sample_raw_succinate.png)<br/>
_**Figure 2:**_ A zoom into the 2D histogram shown in figure 1.

This illustrates how dense and precise the information in a LCMS messurement is. For comparison the M/Z value of an electron is 5.489e-4.


## Processing LCMS data
After the data has been collected on a mass spectrometer (MS) and stored in a (usually) vendor specific format the data can be subjected to analysis.
To process data with MINT the data has to be provided in an open format (mzML or mzXML).

Instead of analysing the raw LCMS data it is common practise to deconvolute the data and sum up the signal of individual metabolites.
The processed data should be proportional to the amount of metabolite in the sample.
However, the meassured intensities will not reflect the relative concentrations between different compounds, only between different samples.
For example, due to different ion efficiences compound **A** might have a stronger signal than compound **B** even if the
compound **B** is present at higher concentration. Therefore, the intensities can only be use to compare relative amounts.
To estimate absolute concentrations a calibration curve has to be created for every single metabolite.

The binning transforms the semi-structured data into a structured format where each column stands for one particular metabolite.
Often the data is normalized for each metabolite to reflect the relative intensities across multiple samples.
The structured data can then be subjected to common data anayses such as dimensionality reduction, or clustering analysis.


![](image/hierarchical_clustering.png )<br/>
_**Figure 3:**_ Clustering analysis for a small set of metabolites across 12 different samples including 3 different pathogens (EC: _E. coli_, SA: _S. aureus_, CA: _C. albicans_).
35 changes: 35 additions & 0 deletions docs/developer-notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Developer Notes
python3 setup.py sdist bdist_wheel
python3 -m twine upload --repository ms-mint dist/ms*mint-*

## Windows executables
pyinstaller --onedir --noconfirm specfiles\Mint__onedir__.spec --additional-hooks-dir=hooks

## Documentation deployment

mkdocs build && mkdocs gh-deploy

## Example NGINX config

location /mint/ {
client_max_body_size 10G;
proxy_pass http://localhost:9999;
#rewrite ^/mint/(.*) /$1 break;

proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}

Then start MINT with `--serve-path='\mint\'`.


## Additional packages

To run tests and code optimization you need the
following packages:

conda install flake8 pytest mkdocs
Empty file added docs/docker.md
Empty file.
5 changes: 5 additions & 0 deletions docs/gallery.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Gallery


![](./gallery/Mint-plate-layout.png)

Binary file added docs/gallery/Mint-plate-layout.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit c0c0b98

Please sign in to comment.