Skip to content

Commit

Permalink
Merge pull request #548 from MannLabs/develop
Browse files Browse the repository at this point in the history
Develop 0.5.0
  • Loading branch information
straussmaximilian authored May 22, 2023
2 parents 8aa80c8 + 86bc43c commit e884f8f
Show file tree
Hide file tree
Showing 80 changed files with 3,027 additions and 1,911 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.4.9
current_version = 0.5.0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/quick_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- name: Run Alphapept on Thermo (IRT_Thermo_Win)
run: |
conda activate alphapept
python test_ci.py "${{ env.TMP_FOLDER }}" thermo_irt "${{ secrets.MONGODB_PW }}"
python test_ci.py "${{ env.TMP_FOLDER }}" thermo_irt
- name: Run Alphapept on Bruker (IRT_Bruker_Win)
run: |
conda activate alphapept
python test_ci.py "${{ env.TMP_FOLDER }}" bruker_irt "${{ secrets.MONGODB_PW }}"
python test_ci.py "${{ env.TMP_FOLDER }}" bruker_irt
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,6 @@ checklink/cookies.txt
logs
_docs/
sidebar.yml

_proc/

27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
FROM jupyter/base-notebook:python-3.8

USER root

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
build-essential \
libgomp1 \
gnupg \
ca-certificates \
&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
&& echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list \
&& apt update \
&& apt install -y mono-devel \
&& wget https://github.com/MannLabs/alphapept/blob/master/alphapept/ext/bruker/FF/linux64/libtbb.so.2 \
&& mv libtbb.so.2 /usr/lib/

RUN conda install -c anaconda pytables==3.6.1
RUN conda install -c conda-forge pythonnet
RUN conda install numba==0.55.2 numpy==1.20.3 pandas==1.4.3

COPY . .
RUN pip install ".[stable,gui-stable]"


CMD ["bash"]
14 changes: 8 additions & 6 deletions Dockerfile_bruker
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
FROM ubuntu:20.04

RUN apt-get update && apt-get install build-essential -y
RUN apt-get install python3-pip -y
RUN apt-get install python3-pip procps -y

WORKDIR /home/alphapept/
COPY . .

RUN pip install .
RUN pip install "alphapept[stable,gui-stable]"

RUN apt-get install libgomp1 -y
RUN cp /usr/local/lib/python3.8/dist-packages/alphapept/ext/bruker/FF/linux64/libtbb.so.2 /usr/lib/libtbb.so.2

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/python3.8/dist-packages/alphapept/ext/bruker/FF/linux64/
RUN chmod 555 -R /usr/local/lib/python3.8/dist-packages/alphapept/ext/bruker/FF/linux64/uff-cmdline2

RUN pip install "numpy<1.24.0"
RUN pip install "sqlalchemy<2.0"

CMD ["bash"]
39 changes: 20 additions & 19 deletions Dockerfile_thermo
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
FROM python:3.8.3
FROM jupyter/base-notebook:python-3.8

# Mono: 5.20
USER root

RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
&& echo "deb http://download.mono-project.com/repo/debian stretch/snapshots/5.20 main" > /etc/apt/sources.list.d/mono-official.list \
&& apt-get update \
&& apt-get install -y clang \
&& apt-get install -y mono-devel=5.20\* \
&& rm -rf /var/lib/apt/lists/* /tmp/*
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
apt-utils \
build-essential \
libgomp1 \
gnupg \
ca-certificates \
&& apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF \
&& echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list \
&& apt update \
&& apt install -y mono-devel \
&& wget https://github.com/MannLabs/alphapept/blob/master/alphapept/ext/bruker/FF/linux64/libtbb.so.2 \
&& mv libtbb.so.2 /usr/lib/

# Pythonnet: 2.5.0 (from PyPI)
# Note: pycparser must be installed before pythonnet can be built
RUN conda install -c anaconda pytables==3.6.1
RUN conda install -c conda-forge pythonnet>=2.5.0
RUN conda install numba==0.55.2 numpy==1.20.3 pandas==1.4.3

RUN pip install pycparser \
&& pip install pythonnet==2.5.0
RUN pip install "alphapept[stable,gui-stable]"

WORKDIR /home/alphapept/
COPY . .

RUN pip install -r requirements.txt
RUN pip install .

CMD ["bash"]
CMD ["bash"]
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ AlphaPept as a package within the environment; see below.
Linux](https://www.mono-project.com/download/stable/#download-lin).
NOTE, the installed mono version should be at least 6.10, which
requires you to add the ppa to your trusted sources!
6. Install pythonnet with `pip install pythonnet==2.5.2`
6. Install pythonnet with `pip install pythonnet>=2.5.2`

------------------------------------------------------------------------

Expand Down Expand Up @@ -172,7 +172,7 @@ AlphaPept as a package within the environment; see below.
Make sure that the Path matches to your version (Here 6.12.0)
- Save everything and execute `. ~/.zshrc`

4. Install pythonnet with `pip install pythonnet==2.5.2`
4. Install pythonnet with `pip install pythonnet>=2.5.2`

------------------------------------------------------------------------

Expand Down Expand Up @@ -227,6 +227,33 @@ installed on Windows machines via a one-click installer. Download the
latest version
[here](https://github.com/MannLabs/alphapept/releases/latest).

## Docker

It is possible to run AlphaPept in a docker container. For this, we
provide two Dockerfiles: `Dockerfile_thermo` and `Dockerfile_bruker`,
depending on which filetypes you want to analyse. They are split because
of drastically different requirements.

To run, navigate to the AlphaPept repository and rename the dockerfile
you want to use, e.g. `Dockerfile_thermo` to `Dockerfile`.

- Build the image with: `docker build -t docker-alphapept:latest .`
- To run use
`docker run -p 8505:8505 -v /Users/username/Desktop/docker:/home/alphapept/ docker-alphapept:latest alphapept gui`
(Note that -v maps a local folder for convient file transfer)
- Access the AlphaPept GUI via `localhost:8505` in your browser.
- Note 1: The Thermo Dockerfile is built on a Jupyter image, so you can
also start a jupyter instance:
`docker run -p 8888:8888 -v /Users/username/Desktop/docker:/home/jovyan/ docker-alphapept:latest jupyter notebook --allow-root`

### Docker Troubleshooting on M1-Mac

- The Thermo dockerfile was tested on an M1-Mac. Resources were set to
18GB RAM and 2 CPUs, 200 GB disk
- It was possible to build the Bruker dockerfile with the platform tag
`--platform linux/amd64`. However, it was very slow and the Bruker
file is not recommended for an M1-Mac. Windows worked nicely.

## Additional Documentation

The documentation is automatically built based on the jupyter notebooks
Expand Down
3 changes: 2 additions & 1 deletion alphapept/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
__version__ = "0.4.9"
__version__ = "0.5.0"

__requirements__ = {
"": "requirements/requirements.txt",
"develop": "requirements/requirements_develop.txt",
"gui": "requirements/requirements_gui.txt",
"legacy": "requirements/requirements_legacy.txt",
}
2 changes: 1 addition & 1 deletion alphapept/__version__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
AUTHOR_EMAIL = "straussmaximilian@gmail.com"
COPYRIGHT = "Mann Labs"
BRANCH = "master"
VERSION_NO = "0.4.9"
VERSION_NO = "0.5.0"
MIN_PYTHON = "3.6"
MAX_PYTHON = "4"
AUDIENCE = "Developers"
Expand Down
3 changes: 3 additions & 0 deletions alphapept/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
'alphapept.chem.get_average_formula': ('chem.html#get_average_formula', 'alphapept/chem.py'),
'alphapept.chem.mass_to_dist': ('chem.html#mass_to_dist', 'alphapept/chem.py'),
'alphapept.chem.numba_bin': ('chem.html#numba_bin', 'alphapept/chem.py')},
'alphapept.clr_utils': {},
'alphapept.constants': { 'alphapept.constants.Isotope': ('constants.html#isotope', 'alphapept/constants.py'),
'alphapept.constants.Isotope.__init__': ('constants.html#isotope.__init__', 'alphapept/constants.py'),
'alphapept.constants.get_mass_dict': ('constants.html#get_mass_dict', 'alphapept/constants.py')},
Expand Down Expand Up @@ -260,10 +261,12 @@
'alphapept.io.get_local_intensity': ('io.html#get_local_intensity', 'alphapept/io.py'),
'alphapept.io.get_most_abundant': ('io.html#get_most_abundant', 'alphapept/io.py'),
'alphapept.io.get_peaks': ('io.html#get_peaks', 'alphapept/io.py'),
'alphapept.io.import_sciex_as_alphapept': ('io.html#import_sciex_as_alphapept', 'alphapept/io.py'),
'alphapept.io.index_ragged_list': ('io.html#index_ragged_list', 'alphapept/io.py'),
'alphapept.io.list_to_numpy_f32': ('io.html#list_to_numpy_f32', 'alphapept/io.py'),
'alphapept.io.load_bruker_raw': ('io.html#load_bruker_raw', 'alphapept/io.py'),
'alphapept.io.load_mzml_data': ('io.html#load_mzml_data', 'alphapept/io.py'),
'alphapept.io.load_sciex_raw': ('io.html#load_sciex_raw', 'alphapept/io.py'),
'alphapept.io.load_thermo_raw': ('io.html#load_thermo_raw', 'alphapept/io.py'),
'alphapept.io.one_over_k0_to_CCS': ('io.html#one_over_k0_to_ccs', 'alphapept/io.py'),
'alphapept.io.parse_mq_seq': ('io.html#parse_mq_seq', 'alphapept/io.py'),
Expand Down
42 changes: 42 additions & 0 deletions alphapept/clr_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import clr
import os
import numpy as np

clr.AddReference('System')
# from System.Runtime.InteropServices import Marshal
# from System import IntPtr, Int64
# def DotNetArrayToNPArray(src):
# '''
# See https://github.com/mobiusklein/ms_deisotope/blob/90b817d4b5ae7823cfe4ad61c57119d62a6e3d9d/ms_deisotope/data_source/thermo_raw_net.py#L217
# '''
# if src is None:
# return np.array([], dtype=np.float64)
# dest = np.empty(len(src), dtype=np.float64)
# Marshal.Copy(
# src, 0,
# IntPtr.__overloads__[Int64](dest.__array_interface__['data'][0]),
# len(src))
# return dest

from System.Runtime.InteropServices import GCHandle, GCHandleType
import ctypes
def DotNetArrayToNPArray(src):
'''
See https://mail.python.org/pipermail/pythondotnet/2014-May/001527.html
'''
if src is None:
return np.array([], dtype=np.float64)
src_hndl = GCHandle.Alloc(src, GCHandleType.Pinned)
try:
src_ptr = src_hndl.AddrOfPinnedObject().ToInt64()
bufType = ctypes.c_double*len(src)
cbuf = bufType.from_address(src_ptr)
dest = np.frombuffer(cbuf, dtype=cbuf._type_).copy()
finally:
if src_hndl.IsAllocated: src_hndl.Free()
return dest

ext_dir = os.path.join(
os.path.dirname(__file__),
'ext'
)
1 change: 1 addition & 0 deletions alphapept/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ def __init__(self, m0:int, dm:int, intensities:np.ndarray):
protease_dict["trypsin_exception"] = "((?<=[CD])K(?=D))|((?<=C)K(?=[HY]))|((?<=C)R(?=K))|((?<=R)R(?=[HR]))"
protease_dict["non-specific"] = "()"
protease_dict["trypsin"] = "([KR](?=[^P]))"
protease_dict["trypsin/p"] = "[KR]"

# %% ../nbs/10_constants.ipynb 25
from numba.typed import Dict
Expand Down
2 changes: 1 addition & 1 deletion alphapept/fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def get_missed_cleavages(sequences:list, n_missed_cleavages:int) -> list:
list (of str): the sequences with missed cleavages.
"""
missed = []
for k in range(len(sequences)-n_missed_cleavages):
for k in range(len(sequences)-n_missed_cleavages+1):
missed.append(''.join(sequences[k-1:k+n_missed_cleavages]))

return missed
Expand Down
4 changes: 3 additions & 1 deletion alphapept/feature_finding.py
Original file line number Diff line number Diff line change
Expand Up @@ -1875,6 +1875,8 @@ def find_features(to_process:tuple, callback:Union[Callable, None] = None, paral
datatype='bruker'
elif ext.lower() == '.mzml':
datatype='mzml'
elif ext.lower() == '.wiff':
datatype='sciex'
else:
raise NotImplementedError('File extension {} not understood.'.format(ext))

Expand Down Expand Up @@ -1905,7 +1907,7 @@ def find_features(to_process:tuple, callback:Union[Callable, None] = None, paral
if not settings['workflow']["find_features"]:
features = query_data_to_features(query_data)
else:
if datatype in ['thermo','mzml']:
if datatype in ['thermo','mzml','sciex']:

from alphapept.constants import averagine_aa, isotopes

Expand Down
2 changes: 1 addition & 1 deletion alphapept/gui/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import alphapept.constants
import alphapept.settings

@st.cache
@st.cache_data
def load_mods(path):
df = pd.read_csv(path, delimiter="\t")
return df
Expand Down
Loading

0 comments on commit e884f8f

Please sign in to comment.