Skip to content

Commit

Permalink
Add peak-report and chromatogram commands.
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed Jan 17, 2024
1 parent 322ca99 commit a7eb7d3
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 0 deletions.
2 changes: 2 additions & 0 deletions formate.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ known_third_party = [
"consolekit",
"domdf_python_tools",
"gunshotmatch_pipeline",
"gunshotmatch_reports",
"libgunshotmatch",
"libgunshotmatch_mpl",
"numpy",
"scikit_learn",
]
Expand Down
55 changes: 55 additions & 0 deletions gunshotmatch_cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
import click
from consolekit.options import version_option
from consolekit.versions import get_version_callback
from gunshotmatch_reports.chromatogram import build_chromatogram_report
from gunshotmatch_reports.peaks import build_peak_report
from libgunshotmatch_mpl.peakviewer import load_project

# this package
import gunshotmatch_cli
Expand Down Expand Up @@ -189,5 +192,57 @@ def decision_tree(projects_toml: str = "projects.toml", unknown_toml: str = "unk
# print("take:", list(take))


@click.argument("projects_toml", default="projects.toml")
@main.command()
def peak_report(projects_toml: str = "projects.toml") -> None:
"""
Generate peak reports for the projects.
"""

# 3rd party
from domdf_python_tools.paths import PathPlus
from gunshotmatch_pipeline.projects import Projects
from gunshotmatch_pipeline.utils import project_plural

projects = Projects.from_toml(PathPlus(projects_toml).read_text())
output_dir = PathPlus(projects.global_settings.output_directory).abspath()

print(f"Generating peak reports for {len(projects)} {project_plural(len(projects))}:")
for project_name in projects.per_project_settings:
print(f" {project_name}")
print(f"Saving to {output_dir.as_posix()!r}")

for project_name in projects.per_project_settings:
project = load_project(output_dir / (project_name + ".gsmp"))

build_peak_report(project)


@click.argument("projects_toml", default="projects.toml")
@main.command()
def chromatograms(projects_toml: str = "projects.toml") -> None:
"""
Generate chromatogram reports for the projects.
"""

# 3rd party
from domdf_python_tools.paths import PathPlus
from gunshotmatch_pipeline.projects import Projects
from gunshotmatch_pipeline.utils import project_plural

projects = Projects.from_toml(PathPlus(projects_toml).read_text())
output_dir = PathPlus(projects.global_settings.output_directory).abspath()

print(f"Generating chromatograms for {len(projects)} {project_plural(len(projects))}:")
for project_name in projects.per_project_settings:
print(f" {project_name}")
print(f"Saving to {output_dir.as_posix()!r}")

for project_name in projects.per_project_settings:
project = load_project(output_dir / (project_name + ".gsmp"))

build_chromatogram_report(project)


if __name__ == "__main__":
main()
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ click>=8.1.7
consolekit>=1.5.2
domdf-python-tools>=3.6.1
gunshotmatch-pipeline>=0.1.1
gunshotmatch-reports>=0.1.0
libgunshotmatch>=0.4.0
libgunshotmatch-mpl>=0.1.0.post1
numpy>=1.22
scikit-learn>=1.3.2

0 comments on commit a7eb7d3

Please sign in to comment.