Skip to content

Commit

Permalink
Merge branch 'main' into split_json_results
Browse files Browse the repository at this point in the history
  • Loading branch information
RobbinBouwmeester authored Jan 26, 2025
2 parents 9f18fca + b52149e commit 4172243
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 25 deletions.
18 changes: 10 additions & 8 deletions proteobench/datapoint/quant_datapoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ class Datapoint:
Attributes:
id (str): Unique identifier for the benchmark run.
software_name (str): Name of the software used in the benchmark.
software_version (int): Version of the software.
software_version (str): Version of the software.
search_engine (str): Name of the search engine used.
search_engine_version (int): Version of the search engine.
ident_fdr_psm (int): False discovery rate for PSMs.
ident_fdr_peptide (int): False discovery rate for peptides.
ident_fdr_protein (int): False discovery rate for proteins.
search_engine_version (str): Version of the search engine.
ident_fdr_psm (float): False discovery rate for PSMs.
ident_fdr_peptide (float): False discovery rate for peptides.
ident_fdr_protein (float): False discovery rate for proteins.
enable_match_between_runs (bool): Whether matching between runs is enabled.
precursor_mass_tolerance (str): Mass tolerance for precursor ions.
fragment_mass_tolerance (str): Mass tolerance for fragment ions.
Expand All @@ -74,7 +74,8 @@ class Datapoint:
is_temporary (bool): Whether the data is temporary.
intermediate_hash (str): Hash of the intermediate result.
results (dict): A dictionary of metrics for the benchmark run.
median_abs_epsilon (int): Median absolute epsilon value for the benchmark.
median_abs_epsilon (float): Median absolute epsilon value for the benchmark.
mean_abs_epsilon (float): Mean absolute epsilon value for the benchmark.
nr_prec (int): Number of precursors identified.
comments (str): Any additional comments.
proteobench_version (str): Version of the Proteobench tool used.
Expand All @@ -98,8 +99,8 @@ class Datapoint:
is_temporary: bool = True
intermediate_hash: str = ""
results: dict = None
median_abs_epsilon: int = 0
mean_abs_epsilon: int = 0
median_abs_epsilon: float = 0
mean_abs_epsilon: float = 0
nr_prec: int = 0
comments: str = ""
proteobench_version: str = ""
Expand Down Expand Up @@ -171,6 +172,7 @@ def generate_datapoint(
result_datapoint.results = results
result_datapoint.median_abs_epsilon = result_datapoint.results[default_cutoff_min_prec]["median_abs_epsilon"]
result_datapoint.mean_abs_epsilon = result_datapoint.results[default_cutoff_min_prec]["mean_abs_epsilon"]
result_datapoint.nr_prec = result_datapoint.results[default_cutoff_min_prec]["nr_prec"]

results_series = pd.Series(dataclasses.asdict(result_datapoint))

Expand Down
12 changes: 6 additions & 6 deletions proteobench/github/gh.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def __init__(
token: Optional[str] = None,
clone_dir: str = None,
clone_dir_pr: str = None,
proteobench_repo_name: str = "Proteobench/Results_Module2_quant_DDA",
proteobot_repo_name: str = "Proteobot/Results_Module2_quant_DDA",
proteobench_repo_name: str = "Proteobench/Results_quant_ion_DDA",
proteobot_repo_name: str = "Proteobot/Results_quant_ion_DDA",
username: str = "Proteobot",
):
"""
Expand All @@ -37,8 +37,8 @@ def __init__(
token (str | None, optional): GitHub access token for authenticated access. Defaults to None.
clone_dir (str): Directory where the repository will be cloned.
clone_dir_pr (str): Directory for cloning pull request repositories.
proteobench_repo_name (str, optional): Name of the Proteobench repository. Defaults to "Proteobench/Results_Module2_quant_DDA".
proteobot_repo_name (str, optional): Name of the Proteobot repository. Defaults to "Proteobot/Results_Module2_quant_DDA".
proteobench_repo_name (str, optional): Name of the Proteobench repository. Defaults to "Proteobench/Results_quant_ion_DDA".
proteobot_repo_name (str, optional): Name of the Proteobot repository. Defaults to "Proteobot/Results_quant_ion_DDA".
username (str, optional): GitHub username for authentication. Defaults to "Proteobot".
"""
self.token = token
Expand Down Expand Up @@ -112,7 +112,7 @@ def clone_repo(self) -> Repo:
Returns:
Repo: The local repository object.
"""
if self.token is None:
if self.token is None or self.token == "":
self.repo = self.clone_repo_anonymous()
else:
remote = f"https://{self.username}:{self.token}@github.com/{self.proteobench_repo_name}.git"
Expand All @@ -128,7 +128,7 @@ def clone_repo_pr(self) -> Repo:
Returns:
Repo: The local repository object for the pull request.
"""
if self.token is None:
if self.token is None or self.token == "":
self.repo = self.clone_repo_anonymous()
else:
remote = f"https://{self.username}:{self.token}@github.com/{self.proteobot_repo_name}.git"
Expand Down
17 changes: 11 additions & 6 deletions proteobench/io/params/peaks.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,17 @@ def read_peaks_settings(file_path: str) -> ProteoBenchParameters:
"""
# Try to read the file contents

try:
# Attempt to open and read the file
with open(file_path, encoding="utf-8") as f:
lines = f.readlines()
except Exception as e:
raise IOError(f"Failed to open or read the file at {file_path}. Error: {e}")
# Check if file_path is an UploadedFile instance
if hasattr(file_path, "read"):
# Assume it behaves like a file object
lines = file_path.read().decode("utf-8").splitlines()
else:
try:
# Attempt to open and read the file
with open(file_path, encoding="utf-8") as f:
lines = f.readlines()
except Exception as e:
raise IOError(f"Failed to open or read the file at {file_path}. Error: {e}")

# Remove any trailing newline characters from each line
lines = [line.strip() for line in lines]
Expand Down
4 changes: 2 additions & 2 deletions proteobench/modules/quant/lfq/ion/DDA/quant_lfq_ion_DDA.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class DDAQuantIonModule(QuantModule):
def __init__(
self,
token: str,
proteobench_repo_name: str = "Proteobench/Results_Module2_quant_DDA",
proteobot_repo_name: str = "Proteobot/Results_Module2_quant_DDA",
proteobench_repo_name: str = "Proteobench/Results_quant_ion_DDA",
proteobot_repo_name: str = "Proteobot/Results_quant_ion_DDA",
# TODO: Figure out how to do nicer relative calls
parse_settings_dir: str = os.path.abspath(
os.path.join(
Expand Down
6 changes: 3 additions & 3 deletions test/test_github_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def test_clone_repo_anonymous():
tmp_dir = TemporaryDirectory()
temp_dir_name = tmp_dir.name

github_repo = GithubProteobotRepo("", temp_dir_name, proteobot_repo_name="Proteobench/Results_Module2_quant_DDA")
github_repo = GithubProteobotRepo("", temp_dir_name, proteobot_repo_name="Proteobench/Results_quant_ion_DDA")
url = github_repo.get_remote_url_anon()
# assert that url equal 'https://github.com/Proteobench/Results_Module2_quant_DDA.git'
# assert url == 'https://github.com/Proteobench/Results_Module2_quant_DDA.git'
# assert that url equal 'https://github.com/Proteobench/Results_quant_ion_DDA.git'
# assert url == 'https://github.com/Proteobench/Results_quant_ion_DDA.git'
repo = github_repo.clone_repo_anonymous()
assert isinstance(repo, Repo)
jsonfile = github_repo.read_results_json_repo()
Expand Down

0 comments on commit 4172243

Please sign in to comment.