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

Development #39

Merged
merged 6 commits into from
Sep 25, 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
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.1.5
current_version = 0.2.0
commit = True
tag = False
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)(?P<build>\d+))?
Expand Down
11 changes: 0 additions & 11 deletions .gitconfig

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,5 @@ alphabase/logs
*sidebar.yml
*_proc
*_quarto.yml
# .gitconfig is now autogenerated
.gitconfig
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ AlphaBase
<img src="https://github.com/MannLabs/alphabase/workflows/Default%20installation%20and%20tests/badge.svg" /></a>
<a href="https://github.com/MannLabs/alphabase/workflows/Publish%20on%20PyPi%20and%20release%20on%20GitHub/badge.svg" alt="GUI and PyPi releases">
<img src="https://github.com/MannLabs/alphabase/workflows/Publish%20on%20PyPi%20and%20release%20on%20GitHub/badge.svg"/></a>
<a href="https://pypi.org/project/peptdeep" alt="pypi">
<a href="https://pypi.org/project/alphabase" alt="pypi">
<img src="https://img.shields.io/pypi/v/alphabase" /></a>
<a href="https://pypi.org/project/alphabase" alt="release">
<img src="https://img.shields.io/pypi/dm/alphabase?color=blue&label=pip%20downloads"/></a>
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.1.5"
__version__ = "0.2.0"
__license__ = "Apache"
__description__ = "An open-source Python package of the AlphaPept ecosystem"
__author__ = "Mann Labs"
Expand Down
2 changes: 2 additions & 0 deletions alphabase/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,8 @@
'alphabase/psm_reader/psm_reader.py'),
'alphabase.psm_reader.psm_reader.PSMReaderBase._translate_score': ( 'psm_reader/psm_reader.html#psmreaderbase._translate_score',
'alphabase/psm_reader/psm_reader.py'),
'alphabase.psm_reader.psm_reader.PSMReaderBase.add_modification_mapping': ( 'psm_reader/psm_reader.html#psmreaderbase.add_modification_mapping',
'alphabase/psm_reader/psm_reader.py'),
'alphabase.psm_reader.psm_reader.PSMReaderBase.filter_psm_by_modifications': ( 'psm_reader/psm_reader.html#psmreaderbase.filter_psm_by_modifications',
'alphabase/psm_reader/psm_reader.py'),
'alphabase.psm_reader.psm_reader.PSMReaderBase.import_file': ( 'psm_reader/psm_reader.html#psmreaderbase.import_file',
Expand Down
3 changes: 2 additions & 1 deletion alphabase/constants/const_files/protease.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ enterokinase: '(?<=[DE]{3})K'
factor xa: '(?<=[AFGILTVM][DE]G)R'
formic acid: 'D'
glutamyl endopeptidase: 'E'
glu-c: 'E'
granzyme b: '(?<=IEP)D'
hydroxylamine: 'N(?=G)'
iodosobenzoic acid: 'W'
Expand All @@ -36,6 +37,6 @@ 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/P: '([KR])'
trypsin/p: '([KR])'
non-specific: '()'
no-cleave: '_'
31 changes: 17 additions & 14 deletions alphabase/peptide/fragment.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def init_fragment_by_precursor_dataframe(
):
'''
Init zero fragment dataframe for the `precursor_df`. If
the `reference_fragment_df` is provided, it will generate
the dataframe based on the reference. Otherwise it
the `reference_fragment_df` is provided, the result dataframe's
length will be the same as reference_fragment_df. Otherwise it
generates the dataframe from scratch.

Parameters
Expand Down Expand Up @@ -184,7 +184,9 @@ def init_fragment_by_precursor_dataframe(
# we can just `del precursor_df['frag_start_idx']` before call this function.
'''
if 'frag_start_idx' not in precursor_df.columns:
fragment_df, start_indices, end_indices = init_zero_fragment_dataframe(
(
fragment_df, start_indices, end_indices
) = init_zero_fragment_dataframe(
precursor_df.nAA.values,
charged_frag_types,
dtype=dtype
Expand All @@ -211,12 +213,12 @@ def init_fragment_by_precursor_dataframe(
if _fr in reference_fragment_df.columns
]]
else:
fragment_df = init_fragment_dataframe_from_other(
reference_fragment_df[[
_fr for _fr in charged_frag_types
if _fr in reference_fragment_df.columns
]],
dtype=dtype
fragment_df = pd.DataFrame(
np.zeros((
len(reference_fragment_df),
len(charged_frag_types)
)),
columns = charged_frag_types
)
return fragment_df

Expand Down Expand Up @@ -602,11 +604,12 @@ def create_fragment_mz_dataframe(
if _fr in reference_fragment_df.columns
]]
else:
fragment_mz_df = init_fragment_dataframe_from_other(
reference_fragment_df[[
_fr for _fr in charged_frag_types
if _fr in reference_fragment_df.columns
]]
fragment_mz_df = pd.DataFrame(
np.zeros((
len(reference_fragment_df),
len(charged_frag_types)
)),
columns = charged_frag_types
)
else:
fragment_mz_df = init_fragment_by_precursor_dataframe(
Expand Down
4 changes: 2 additions & 2 deletions alphabase/protein/fasta.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,9 @@ def __init__(self,
self.n_miss_cleave = max_missed_cleavages
self.peptide_length_min = peptide_length_min
self.peptide_length_max = peptide_length_max
if protease in protease_dict:
if protease.lower() in protease_dict:
self.regex_pattern = re.compile(
protease_dict[protease]
protease_dict[protease.lower()]
)
else:
self.regex_pattern = re.compile(
Expand Down
12 changes: 11 additions & 1 deletion alphabase/psm_reader/psm_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,16 @@ def __init__(self,
def psm_df(self)->pd.DataFrame:
return self._psm_df

def add_modification_mapping(self, modification_mapping:dict):
if (
modification_mapping is None or
len(modification_mapping) == 0
):
return

self.modification_mapping.update(modification_mapping)
self.set_modification_mapping(self.modification_mapping)

def set_modification_mapping(self, modification_mapping:dict):
if modification_mapping is None:
self._init_modification_mapping()
Expand Down Expand Up @@ -444,7 +454,7 @@ def filter_psm_by_modifications(self, include_mod_set = set([
self._psm_df.reset_index(drop=True, inplace=True)


# %% ../../nbdev_nbs/psm_reader/psm_reader.ipynb 16
# %% ../../nbdev_nbs/psm_reader/psm_reader.ipynb 18
class PSMReaderProvider:
def __init__(self):
self.reader_dict = {}
Expand Down
9 changes: 0 additions & 9 deletions nbdev_nbs/constants/aa.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -630,15 +630,6 @@
"display_name": "Python 3.8.3 ('base')",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.8.3"
},
"vscode": {
"interpreter": {
"hash": "8a3b27e141e49c996c9b863f8707e97aabd49c4a7e8445b9b783b34e4a21a9b2"
}
}
},
"nbformat": 4,
Expand Down
9 changes: 0 additions & 9 deletions nbdev_nbs/constants/element.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,6 @@
"display_name": "Python 3.8.3 ('base')",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.8.3"
},
"vscode": {
"interpreter": {
"hash": "8a3b27e141e49c996c9b863f8707e97aabd49c4a7e8445b9b783b34e4a21a9b2"
}
}
},
"nbformat": 4,
Expand Down
Loading