-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from hgb-bin-proteomics/develop
v1.2.2
- Loading branch information
Showing
2 changed files
with
96 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ | |
# [email protected] | ||
|
||
# version tracking | ||
__version = "1.2.1" | ||
__date = "2024-07-18" | ||
__version = "1.2.2" | ||
__date = "2024-07-21" | ||
|
||
# REQUIREMENTS | ||
# pip install pandas | ||
|
@@ -310,6 +310,7 @@ def get_positions_in_protein(row: pd.Series) -> Dict[str, int]: | |
return {"A": pep_pos_A + xl_pos_A, "B": pep_pos_B + xl_pos_B} | ||
|
||
##### DECOY GENERATION ##### | ||
# decoy generation implemented as described by Zhang et al. here: https://doi.org/10.1021/acs.jproteome.7b00614 | ||
|
||
def generate_decoy_csm(row: pd.Series, crosslinker: str = CROSSLINKER) -> pd.Series: | ||
""" | ||
|
@@ -722,7 +723,7 @@ def main(spectra_file: Union[List[str], List[BinaryIO]] = SPECTRA_FILE, | |
iRT_m: float = iRT_PARAMS["iRT_m"], | ||
iRT_t: float = iRT_PARAMS["iRT_t"], | ||
is_streamlit: bool = False, | ||
save_output: bool = True) -> pd.DataFrame: | ||
save_output: bool = True) -> Dict[str, pd.DataFrame]: | ||
|
||
if is_streamlit: | ||
print("INFO: Creating spectral library with input files:\nSpectra: " + | ||
|
@@ -991,7 +992,7 @@ def main(spectra_file: Union[List[str], List[BinaryIO]] = SPECTRA_FILE, | |
print("SUCCESS: Decoy Spectral library created with filename:") | ||
print(".".join(csms_file.split(".")[:-1]) + "_spectralLibraryDECOY.csv") | ||
|
||
return spectral_library | ||
return {"TargetLib": spectral_library, "DecoyLib": spectral_library_decoy} | ||
|
||
##### SCRIPT ##### | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,77 +5,108 @@ | |
# https://github.com/michabirklbauer/ | ||
# [email protected] | ||
|
||
# check output shape | ||
# check output shape target | ||
def test1_spectral_library_exporter(): | ||
|
||
from create_spectral_library import main | ||
|
||
sl = main() | ||
sl = sl["TargetLib"] | ||
|
||
assert sl.shape[0] == 12 and sl.shape[1] == 27 | ||
|
||
# check values | ||
# check values target | ||
def test2_spectral_library_exporter(): | ||
|
||
from create_spectral_library import main | ||
|
||
sl = main() | ||
sl = sl["TargetLib"] | ||
|
||
value_tests = True | ||
|
||
if str(sl.loc[0, "FragmentCharge"]) != "1": | ||
value_tests = False | ||
if str(sl.loc[0, "FragmentType"]) != "y": | ||
value_tests = False | ||
if str(sl.loc[0, "FragmentNumber"]) != "1": | ||
value_tests = False | ||
if str(sl.loc[0, "FragmentPepId"]) != "0": | ||
value_tests = False | ||
if str(sl.loc[0, "CLContainingFragment"]) != "False": | ||
value_tests = False | ||
|
||
if str(sl.loc[1, "FragmentCharge"]) != "1": | ||
value_tests = False | ||
if str(sl.loc[1, "FragmentType"]) != "b": | ||
value_tests = False | ||
if str(sl.loc[1, "FragmentNumber"]) != "2": | ||
value_tests = False | ||
if str(sl.loc[1, "FragmentPepId"]) != "0": | ||
value_tests = False | ||
if str(sl.loc[1, "CLContainingFragment"]) != "True": | ||
value_tests = False | ||
|
||
if str(sl.loc[2, "FragmentCharge"]) != "1": | ||
value_tests = False | ||
if str(sl.loc[2, "FragmentType"]) != "b": | ||
value_tests = False | ||
if str(sl.loc[2, "FragmentNumber"]) != "2": | ||
value_tests = False | ||
if str(sl.loc[2, "FragmentPepId"]) != "0": | ||
value_tests = False | ||
if str(sl.loc[2, "CLContainingFragment"]) != "True": | ||
value_tests = False | ||
|
||
if str(sl.loc[3, "FragmentCharge"]) != "1": | ||
value_tests = False | ||
if str(sl.loc[3, "FragmentType"]) != "y": | ||
value_tests = False | ||
if str(sl.loc[3, "FragmentNumber"]) != "3": | ||
value_tests = False | ||
if str(sl.loc[3, "FragmentPepId"]) != "0": | ||
value_tests = False | ||
if str(sl.loc[3, "CLContainingFragment"]) != "False": | ||
value_tests = False | ||
|
||
if str(sl.loc[11, "FragmentCharge"]) != "1": | ||
value_tests = False | ||
if str(sl.loc[11, "FragmentType"]) != "y": | ||
value_tests = False | ||
if str(sl.loc[11, "FragmentNumber"]) != "5": | ||
value_tests = False | ||
if str(sl.loc[11, "FragmentPepId"]) != "1": | ||
value_tests = False | ||
if str(sl.loc[11, "CLContainingFragment"]) != "False": | ||
value_tests = False | ||
|
||
assert value_tests | ||
assert str(sl.loc[0, "ModifiedPeptide"]) == "KQQGHR_KQQGHR" | ||
assert str(sl.loc[0, "FragmentCharge"]) == "1" | ||
assert str(sl.loc[0, "FragmentType"]) == "y" | ||
assert str(sl.loc[0, "FragmentNumber"]) == "1" | ||
assert str(sl.loc[0, "FragmentPepId"]) == "0" | ||
assert str(sl.loc[0, "CLContainingFragment"]) == "False" | ||
|
||
assert str(sl.loc[1, "ModifiedPeptide"]) == "KQQGHR_KQQGHR" | ||
assert str(sl.loc[1, "FragmentCharge"]) == "1" | ||
assert str(sl.loc[1, "FragmentType"]) == "b" | ||
assert str(sl.loc[1, "FragmentNumber"]) == "2" | ||
assert str(sl.loc[1, "FragmentPepId"]) == "0" | ||
assert str(sl.loc[1, "CLContainingFragment"]) == "True" | ||
|
||
assert str(sl.loc[2, "ModifiedPeptide"]) == "KQQGHR_KQQGHR" | ||
assert str(sl.loc[2, "FragmentCharge"]) == "1" | ||
assert str(sl.loc[2, "FragmentType"]) == "b" | ||
assert str(sl.loc[2, "FragmentNumber"]) == "2" | ||
assert str(sl.loc[2, "FragmentPepId"]) == "0" | ||
assert str(sl.loc[2, "CLContainingFragment"]) == "True" | ||
|
||
assert str(sl.loc[3, "ModifiedPeptide"]) == "KQQGHR_KQQGHR" | ||
assert str(sl.loc[3, "FragmentCharge"]) == "1" | ||
assert str(sl.loc[3, "FragmentType"]) == "y" | ||
assert str(sl.loc[3, "FragmentNumber"]) == "3" | ||
assert str(sl.loc[3, "FragmentPepId"]) == "0" | ||
assert str(sl.loc[3, "CLContainingFragment"]) == "False" | ||
|
||
assert str(sl.loc[11, "ModifiedPeptide"]) == "KQQGHR_KQQGHR" | ||
assert str(sl.loc[11, "FragmentCharge"]) == "1" | ||
assert str(sl.loc[11, "FragmentType"]) == "y" | ||
assert str(sl.loc[11, "FragmentNumber"]) == "5" | ||
assert str(sl.loc[11, "FragmentPepId"]) == "1" | ||
assert str(sl.loc[11, "CLContainingFragment"]) == "False" | ||
|
||
# check output shape decoy | ||
def test3_spectral_library_exporter(): | ||
|
||
from create_spectral_library import main | ||
|
||
sl = main() | ||
sl = sl["DecoyLib"] | ||
|
||
assert sl.shape[0] == 22 and sl.shape[1] == 27 | ||
|
||
# check values decoy | ||
def test4_spectral_library_exporter(): | ||
|
||
from create_spectral_library import main | ||
|
||
sl = main() | ||
sl = sl["DecoyLib"] | ||
|
||
assert str(sl.loc[0, "ModifiedPeptide"]) == "HGQQKR_HGQQKR" | ||
assert str(sl.loc[0, "FragmentCharge"]) == "1" | ||
assert str(sl.loc[0, "FragmentType"]) == "y" | ||
assert str(sl.loc[0, "FragmentNumber"]) == "1" | ||
assert str(sl.loc[0, "FragmentPepId"]) == "0" | ||
assert str(sl.loc[0, "CLContainingFragment"]) == "False" | ||
|
||
assert str(sl.loc[1, "ModifiedPeptide"]) == "HGQQKR_HGQQKR" | ||
assert str(sl.loc[1, "FragmentCharge"]) == "1" | ||
assert str(sl.loc[1, "FragmentType"]) == "b" | ||
assert str(sl.loc[1, "FragmentNumber"]) == "2" | ||
assert str(sl.loc[1, "FragmentPepId"]) == "0" | ||
assert str(sl.loc[1, "CLContainingFragment"]) == "False" | ||
|
||
assert str(sl.loc[2, "ModifiedPeptide"]) == "HGQQKR_HGQQKR" | ||
assert str(sl.loc[2, "FragmentCharge"]) == "1" | ||
assert str(sl.loc[2, "FragmentType"]) == "y" | ||
assert str(sl.loc[2, "FragmentNumber"]) == "3" | ||
assert str(sl.loc[2, "FragmentPepId"]) == "0" | ||
assert str(sl.loc[2, "CLContainingFragment"]) == "True" | ||
|
||
assert str(sl.loc[3, "ModifiedPeptide"]) == "HGQQKR_HGQQKR" | ||
assert str(sl.loc[3, "FragmentCharge"]) == "1" | ||
assert str(sl.loc[3, "FragmentType"]) == "y" | ||
assert str(sl.loc[3, "FragmentNumber"]) == "3" | ||
assert str(sl.loc[3, "FragmentPepId"]) == "0" | ||
assert str(sl.loc[3, "CLContainingFragment"]) == "True" | ||
|
||
assert str(sl.loc[21, "ModifiedPeptide"]) == "HGQQKR_HGQQKR" | ||
assert str(sl.loc[21, "FragmentCharge"]) == "1" | ||
assert str(sl.loc[21, "FragmentType"]) == "y" | ||
assert str(sl.loc[21, "FragmentNumber"]) == "5" | ||
assert str(sl.loc[21, "FragmentPepId"]) == "1" | ||
assert str(sl.loc[21, "CLContainingFragment"]) == "True" |