Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphinx doc #56

Merged
merged 18 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.2.0
current_version = 0.2.1
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand All @@ -15,6 +15,8 @@ serialize =

[bumpversion:file:./settings.ini]

[bumpversion:file:./docs/conf.py]

[bumpversion:file:./release/one_click_linux_gui/control]

[bumpversion:file:./release/one_click_linux_gui/create_installer_linux.sh]
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ instance/

# Sphinx documentation
docs/_build/
docs/build/

# PyBuilder
target/
Expand Down Expand Up @@ -138,7 +139,7 @@ alphabase/logs

# nbdev2
*.gitattributes
*_docs*
_docs*
# *_quarto.yml
# *sidebar.yml
*_proc*
Expand Down
27 changes: 27 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Build documentation in the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF
formats: all

conda:
environment: misc/conda_dev_env.yaml

# # Optionally set the version of Python and requirements required to build your docs
# python:
# version: 3.8
# install:
# - requirements: requirements/requirements.txt
# - method: pip
# path: .
# extra_requirements:
# - plotting
# - development
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,13 @@ please see [GitHub Pages](https://mannlabs.github.io/alphabase/)

## About

An open-source Python package of the AlphaPept ecosystem from the [Mann
Labs at the Max Planck Institute of
Biochemistry](https://www.biochem.mpg.de/mann) and the [University of
Copenhagen](https://www.cpr.ku.dk/research/proteomics/mann/). It
provides basic functionalities for AlphaPept ecosystem.
The infrastructure package of AlphaX ecosystem for MS proteomics.

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

## License

AlphaBase was developed by the [Mann Labs at the Max Planck Institute of
Biochemistry](https://www.biochem.mpg.de/mann) and the [University of
Copenhagen](https://www.cpr.ku.dk/research/proteomics/mann/) and is
AlphaBase was developed by the [Mann Labs at the Max Planck Institute of Biochemistry](https://www.biochem.mpg.de/mann) and the [University of Copenhagen](https://www.cpr.ku.dk/research/proteomics/mann/) and is
freely available with an [Apache License](LICENSE.txt). External Python
packages (available in the [requirements](requirements) folder) have
their own licenses, which can be consulted on their respective websites.
Expand Down
2 changes: 1 addition & 1 deletion alphabase/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@


__project__ = "alphabase"
__version__ = "0.2.0"
__version__ = "0.2.1"
__license__ = "Apache"
__description__ = "An open-source Python package of the AlphaPept ecosystem"
__author__ = "Mann Labs"
Expand Down
635 changes: 3 additions & 632 deletions alphabase/_modidx.py

Large diffs are not rendered by default.

22 changes: 6 additions & 16 deletions alphabase/constants/aa.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,25 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbdev_nbs/constants/aa.ipynb.

# %% auto 0
__all__ = ['AA_CHEM', 'AA_ASCII_MASS', 'AA_DF', 'AA_formula', 'reset_AA_mass', 'reset_AA_df', 'calc_sequence_mass',
'calc_AA_masses_for_same_len_seqs', 'calc_sequence_masses_for_same_len_seqs',
'calc_AA_masses_for_var_len_seqs']

# %% ../../nbdev_nbs/constants/aa.ipynb 2
import os
import pandas as pd
import numpy as np

from typing import Union, Tuple

from ..yaml_utils import load_yaml
from alphabase.yaml_utils import load_yaml

from alphabase.constants.element import (
calc_mass_from_formula,
MASS_H2O, parse_formula,
)

from ._const import CONST_FILE_FOLDER
from alphabase.constants._const import CONST_FILE_FOLDER

# %% ../../nbdev_nbs/constants/aa.ipynb 3
# We use all 128 ASCII code to represent amino acids for flexible extensions in the future.
# The amino acid masses are stored in 128-lengh array :py:data:`AA_ASCII_MASS`.
# If an ASCII code is not in `AA_CHEM`, the mass will be set as a large value to disable MS search.
AA_CHEM:dict = load_yaml(
os.path.join(CONST_FILE_FOLDER, 'amino_acid.yaml')
)

# %% ../../nbdev_nbs/constants/aa.ipynb 5
def reset_AA_mass()->np.ndarray:
"""AA mass in np.array with shape (128,)"""
AA_ASCII_MASS = np.ones(128)*1e8
Expand All @@ -53,14 +46,13 @@ def reset_AA_df():
#: 128-len AA dataframe
AA_DF:pd.DataFrame = reset_AA_df()

#: AA to formula dict of dict. For example: {'K': {'C': n, 'O': m, ...}}
# AA to formula dict of dict. For example: {'K': {'C': n, 'O': m, ...}}
AA_formula:dict = {}
for aa, formula, mass in AA_DF.values:
AA_formula[aa] = dict(
parse_formula(formula)
)

# %% ../../nbdev_nbs/constants/aa.ipynb 8
def calc_sequence_mass(
sequence: str
)->np.ndarray:
Expand All @@ -77,7 +69,6 @@ def calc_sequence_mass(
'''
return AA_ASCII_MASS[np.array(sequence,'c').view(np.int8)]

# %% ../../nbdev_nbs/constants/aa.ipynb 10
def calc_AA_masses_for_same_len_seqs(
sequence_array: np.ndarray
)->np.ndarray:
Expand Down Expand Up @@ -132,7 +123,6 @@ def calc_sequence_masses_for_same_len_seqs(
)+MASS_H2O


# %% ../../nbdev_nbs/constants/aa.ipynb 19
def calc_AA_masses_for_var_len_seqs(
sequence_array: np.ndarray
)->np.ndarray:
Expand Down
2 changes: 1 addition & 1 deletion alphabase/constants/atom.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .element import *
from alphabase.constants.element import *
3 changes: 2 additions & 1 deletion alphabase/constants/const_files/protease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ thermolysin: '[^DE](?=[AFILMV])'
thrombin: '((?<=G)R(?=G))|((?<=[AFGILTVM][AFGILTVWA]P)R(?=[^DE][^DE]))'
trypsin_full: '([KR](?=[^P]))|((?<=W)K(?=P))|((?<=M)R(?=P))'
trypsin_exception: '((?<=[CD])K(?=D))|((?<=C)K(?=[HY]))|((?<=C)R(?=K))|((?<=R)R(?=[HR]))'
trypsin: '([KR](?=[^P]))'
trypsin_not_p: '([KR](?=[^P]))'
trypsin: '([KR])'
trypsin/p: '([KR])'
non-specific: '()'
no-cleave: '_'
15 changes: 1 addition & 14 deletions alphabase/constants/const_files/psm_reader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ alphapept:
maxquant:
reader_type: maxquant
rt_unit: minute
mod_sep: '()'
underscore_for_ncterm: True
fixed_C57: True
column_mapping:
'sequence': 'Sequence'
Expand All @@ -51,33 +49,27 @@ maxquant:
'Acetyl@Protein N-term':
- '_(Acetyl (Protein N-term))'
- '_(ac)'
- '_(UniMod:1)'
'Carbamidomethyl@C':
- 'C(Carbamidomethyl (C))'
- 'C(UniMod:4)'
'Oxidation@M':
- 'M(Oxidation (M))'
- 'M(ox)'
- 'M(UniMod:35)'
'Phospho@S':
- 'S(Phospho (S))'
- 'S(Phospho (ST))'
- 'S(Phospho (STY))'
- 'S(ph)'
- 'S(UniMod:21)'
- 'pS'
'Phospho@T':
- 'T(Phospho (T))'
- 'T(Phospho (ST))'
- 'T(Phospho (STY))'
- 'T(ph)'
- 'T(UniMod:21)'
- 'pT'
'Phospho@Y':
- 'Y(Phospho (Y))'
- 'Y(Phospho (STY))'
- 'Y(ph)'
- 'Y(UniMod:21)'
- 'pY'
'Deamidated@N': ['N(Deamidation (NQ))','N(de)']
'Deamidated@Q': ['Q(Deamidation (NQ))','Q(de)']
Expand Down Expand Up @@ -145,8 +137,6 @@ msfragger_pepxml:
diann:
reader_type: diann
rt_unit: minute
mod_sep: '()'
underscore_for_ncterm: False
fixed_C57: False
csv_sep: "\t"
column_mapping:
Expand All @@ -166,8 +156,6 @@ diann:
spectronaut_report:
reader_type: spectronaut_report
rt_unit: minute
mod_sep: '[]'
underscore_for_ncterm: True
fixed_C57: False
csv_sep: ','
column_mapping:
Expand All @@ -177,11 +165,10 @@ spectronaut_report:
'genes': 'PG.Genes'
'uniprot_ids': 'PG.UniProtIds'
'charge': 'charge'
modification_mapping: 'maxquant'
spectronaut:
reader_type: spectronaut
rt_unit: irt
mod_sep: '[]'
underscore_for_ncterm: True
fixed_C57: False
csv_sep: "\t"
mod_seq_columns:
Expand Down
16 changes: 2 additions & 14 deletions alphabase/constants/element.py
Original file line number Diff line number Diff line change
@@ -1,28 +1,18 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbdev_nbs/constants/element.ipynb.

# %% auto 0
__all__ = ['common_const_dict', 'MASS_PROTON', 'MASS_ISOTOPE', 'MAX_ISOTOPE_LEN', 'EMPTY_DIST', 'CHEM_INFO_DICT',
'CHEM_MONO_MASS', 'CHEM_ISOTOPE_DIST', 'CHEM_MONO_IDX', 'MASS_H2O', 'MASS_NH3', 'truncate_isotope',
'reset_elements', 'load_elem_yaml', 'parse_formula', 'calc_mass_from_formula']

# %% ../../nbdev_nbs/constants/element.ipynb 2
import os
import numpy as np
import numba

from ..yaml_utils import load_yaml
from alphabase.yaml_utils import load_yaml

from ._const import CONST_FILE_FOLDER
from alphabase.constants._const import CONST_FILE_FOLDER

# %% ../../nbdev_nbs/constants/element.ipynb 3
common_const_dict:dict = load_yaml(
os.path.join(CONST_FILE_FOLDER, 'common_constants.yaml')
)

MASS_PROTON:float = common_const_dict['MASS_PROTON']
MASS_ISOTOPE:float = common_const_dict['MASS_ISOTOPE']

# %% ../../nbdev_nbs/constants/element.ipynb 5
MAX_ISOTOPE_LEN = common_const_dict['MAX_ISOTOPE_LEN']
EMPTY_DIST = np.zeros(MAX_ISOTOPE_LEN)
EMPTY_DIST[0] = 1
Expand Down Expand Up @@ -75,7 +65,6 @@ def truncate_isotope(
trunc_start = len(isotopes)-MAX_ISOTOPE_LEN-1
return mono_idx-trunc_start-1, trunc_start+1, trunc_end

# %% ../../nbdev_nbs/constants/element.ipynb 7
#: chemical element information in dict defined by `nist_element.yaml`
CHEM_INFO_DICT = {}

Expand Down Expand Up @@ -164,7 +153,6 @@ def load_elem_yaml(yaml_file:str):
)
)

# %% ../../nbdev_nbs/constants/element.ipynb 9
def parse_formula(
formula:str
)->list:
Expand Down
10 changes: 0 additions & 10 deletions alphabase/constants/isotope.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbdev_nbs/constants/isotope.ipynb.

# %% auto 0
__all__ = ['abundance_convolution', 'one_element_dist', 'formula_dist', 'IsotopeDistribution']

# %% ../../nbdev_nbs/constants/isotope.ipynb 3
import numba
import numpy as np
import typing
Expand All @@ -14,7 +8,6 @@
truncate_isotope, parse_formula
)

# %% ../../nbdev_nbs/constants/isotope.ipynb 4
@numba.njit
def abundance_convolution(
d1:np.ndarray,
Expand Down Expand Up @@ -55,7 +48,6 @@ def abundance_convolution(
mono_idx, start, end = truncate_isotope(ret, mono_idx)
return ret[start:end], mono_idx

# %% ../../nbdev_nbs/constants/isotope.ipynb 6
@numba.njit
def one_element_dist(
elem: str,
Expand Down Expand Up @@ -125,7 +117,6 @@ def formula_dist(
calc_dist, mono_idx = abundance_convolution(calc_dist, mono_idx, _dist, _mono)
return calc_dist, mono_idx

# %% ../../nbdev_nbs/constants/isotope.ipynb 23
def _calc_one_elem_cum_dist(
element_cum_dist:np.ndarray,
element_cum_mono:np.ndarray
Expand Down Expand Up @@ -154,7 +145,6 @@ def _calc_one_elem_cum_dist(
element_cum_mono[1]
)

# %% ../../nbdev_nbs/constants/isotope.ipynb 24
class IsotopeDistribution:
def __init__(self,
max_elem_num_dict:dict = {
Expand Down
Loading