-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ion mobility prediction support through IM2Deep
- Loading branch information
Showing
4 changed files
with
89 additions
and
4 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
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
"""Module for ion mobility prediction with IM²Deep.""" | ||
|
||
import logging | ||
|
||
import pandas as pd | ||
from psm_utils import PSMList | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class IonMobility: | ||
"""Predict ion mobility using IM²Deep.""" | ||
|
||
def __init__(self, processes=1) -> None: | ||
# Lazy import to avoid loading loading heavy dependencies when not needed | ||
try: | ||
from im2deep.im2deep import predict_ccs # noqa: F401 | ||
|
||
self.predict_fn = predict_ccs | ||
self.processes = processes | ||
except ImportError as e: | ||
raise ImportError( | ||
"The 'im2deep' package is required for ion mobility prediction." | ||
) from e | ||
|
||
def add_im_predictions(self, psm_list: PSMList) -> None: | ||
"""Add ion mobility predictions to the PSMList.""" | ||
logger.info("Predicting ion mobility...") | ||
predictions: pd.Series = self.predict_fn( | ||
psm_list, write_output=False, n_jobs=self.processes | ||
) | ||
psm_list["ion_mobility"] = predictions.values |
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
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