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

Misc improvements #390

Merged
merged 4 commits into from
Dec 5, 2024
Merged
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
48 changes: 29 additions & 19 deletions alphadia/planning.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import socket
from datetime import datetime
from importlib import metadata
from pathlib import Path

import alphabase
Expand Down Expand Up @@ -48,16 +49,23 @@ def __init__(

Parameters
----------
raw_data : list

output_folder : str
output folder to save the results

raw_path_list : list
list of input file locations

config_path : str, optional
yaml file containing the default config.
library_path : str, optional
path to the spectral library file. If not provided, the library is built from fasta files

config_update_path : str, optional
yaml file to update the default config.
fasta_path_list : list, optional
list of fasta file locations to build the library from

config_update : dict, optional
config_base_path : str, optional
yaml file containing the default config.

config : dict, optional
dict to update the default config. Can be used for debugging purposes etc.

quant_path : str, optional
Expand Down Expand Up @@ -96,7 +104,7 @@ def __init__(
# print environment
self.log_environment()

# 1. default config path is not defined in the function definition to account for for different path separators on different OS
# 1. default config path is not defined in the function definition to account for different path separators on different OS
if config_base_path is None:
# default yaml config location under /misc/config/config.yaml
config_base_path = os.path.join(
Expand All @@ -113,7 +121,7 @@ def __init__(
update_config = Config("user defined")
update_config.from_dict(config)
else:
update_config = config
update_config = config # TODO what is it in this case?

self.config.update([update_config], print_modifications=True)

Expand All @@ -130,15 +138,6 @@ def __init__(

torch.set_num_threads(self.config["general"]["thread_count"])

@property
def raw_path_list(self) -> list[str]:
"""List of input files locations."""
return self._raw_path_list

@raw_path_list.setter
def raw_path_list(self, raw_path_list: list[str]):
self._raw_path_list = raw_path_list

@property
def config(self) -> Config:
"""Dict with all configuration parameters for the extraction."""
Expand All @@ -158,14 +157,22 @@ def spectral_library(self, spectral_library: SpecLibFlat) -> None:
self._spectral_library = spectral_library

def log_environment(self):
logger.progress("=================== Environment ===================")
logger.progress("================ AlphaX Environment ===============")
logger.progress(f"{'alphatims':<15} : {alphatims.__version__:}")
logger.progress(f"{'alpharaw':<15} : {alpharaw.__version__}")
logger.progress(f"{'alphabase':<15} : {alphabase.__version__}")
logger.progress(f"{'alphapeptdeep':<15} : {peptdeep.__version__}")
logger.progress(f"{'directlfq':<15} : {directlfq.__version__}")
logger.progress("===================================================")

logger.progress("================= Pip Environment =================")
pip_env = [
f"{dist.metadata['Name']}=={dist.version}"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about using debug Level logging. Bit I guess it doesnt hurt to have this by default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you will never need this until you need it, so I would leave it on by default

what about the progress level anyway? could this not be INFO?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is that progress has the important stuff and is colored green so you can find it faster when checking output

for dist in metadata.distributions()
]
logger.progress(" ".join(pip_env))
logger.progress("===================================================")

def init_alphabase(self):
"""Init alphabase by registering custom modifications."""

Expand Down Expand Up @@ -393,7 +400,10 @@ def run(

def clean(self):
if not self.config["general"]["save_library"]:
os.remove(os.path.join(self.output_folder, "speclib.hdf"))
try:
os.remove(os.path.join(self.output_folder, "speclib.hdf"))
except Exception as e:
logger.exception(f"Error deleting library: {e}")


def _log_exception_event(
Expand Down
Loading