Skip to content

Commit

Permalink
enable selection of alternative peptdeep models
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgWa committed Aug 19, 2024
1 parent fd8e675 commit de8441c
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 2 deletions.
3 changes: 3 additions & 0 deletions alphadia/constants/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ library_prediction:
# set path for custom peptdeep model. If set to null, the default model will be used
peptdeep_model_path: null

# set peptdeep model type. Possible values are 'generic', 'phospho', 'digly'. If set to null, the generic model will be used
peptdeep_model_type: null

# define custom alphabase modifications not part of unimod or alphabase
# also used for decoy channels
custom_modififcations:
Expand Down
11 changes: 11 additions & 0 deletions alphadia/libtransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def __init__(
nce: int = 25,
instrument: str = "Lumos",
peptdeep_model_path: str | None = None,
peptdeep_model_type: str | None = None,
fragment_types: list[str] | None = None,
max_fragment_charge: int = 2,
) -> None:
Expand All @@ -279,6 +280,10 @@ def __init__(
peptdeep_model_path : str, optional
Path to a folder containing PeptDeep models. If not provided, the default models will be used.
peptdeep_model_type : str, optional
Use other peptdeep models provided by the peptdeep model manager. Default is None.
Possible values are ['generic','phospho','digly']
fragment_types : List[str], optional
Fragment types to predict. Default is ["b", "y"].
Expand All @@ -296,6 +301,7 @@ def __init__(
self.instrument = instrument
self.mp_process_num = mp_process_num
self.peptdeep_model_path = peptdeep_model_path
self.peptdeep_model_type = peptdeep_model_type

self.fragment_types = fragment_types
self.max_fragment_charge = max_fragment_charge
Expand All @@ -313,6 +319,11 @@ def forward(self, input: SpecLibBase) -> SpecLibBase:
device = utils.get_torch_device(self.use_gpu)

model_mgr = ModelManager(device=device)

if self.peptdeep_model_type is not None:
logging.info(f"Loading PeptDeep models of type {self.peptdeep_model_type}")
model_mgr.load_installed_models(self.peptdeep_model_type)

if self.peptdeep_model_path is not None:
if not os.path.exists(self.peptdeep_model_path):
raise ValueError(
Expand Down
3 changes: 3 additions & 0 deletions alphadia/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ def _parse_modifications(mod_str: str) -> list[str]:
peptdeep_model_path=self.config["library_prediction"][
"peptdeep_model_path"
],
peptdeep_model_type=self.config["library_prediction"][
"peptdeep_model_type"
],
fragment_types=self.config["library_prediction"][
"fragment_types"
].split(";"),
Expand Down
16 changes: 14 additions & 2 deletions gui/workflows/PeptideCentric.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,23 @@
]
},
{
"id": "checkpoint_folder_path",
"name": "PeptDeep Model",
"id": "peptdeep_model_path",
"name": "PeptDeep Model Path",
"value": "",
"description": "Select a custom PeptDeep model for library prediction. This can be a DDA or DIA trained model. Please make sure that you use the same instrument type and NCE for prediction as the model was trained on.",
"type": "singleFolderSelection"
},
{
"id": "peptdeep_model_type",
"name": "PeptDeep Model Type",
"value": "generic",
"description": "Select a custom pretrained PeptDeep model for library prediction. Possible values are 'generic', 'phospho' and 'digly'.",
"type": "dropdown",
"options": [
"generic",
"phospho",
"digly"
]
}

]
Expand Down

0 comments on commit de8441c

Please sign in to comment.