gunshotmatch-reports
PDF Report Generation for GunShotMatch.
Docs |
|
---|---|
Tests |
|
PyPI |
|
Activity |
|
QA |
|
Other |
Installation
python3 -m pip install gunshotmatch-reports --user
python3 -m pip install git+https://github.com/GunShotMatch/gunshotmatch-reports@master --user
Contents
gunshotmatch_reports.alignment
CSV reports of alignment between reference projects and unknown samples.
New in version 0.5.0.
Classes:
|
Represents data for a peak in a CSV report. |
Functions:
|
Returns CSV report for the alignment between the given projects. |
|
Returns CSV report for the alignment between the given projects and unknown. |
|
Return data for the CSV report for given peak in the given project. |
-
namedtuple
CSVRow
(peak_no='', name='', rt='', area='', area_percentage='', match_factor='')[source] Bases:
NamedTuple
Represents data for a peak in a CSV report.
- Fields
-
__repr__
() Return a nicely formatted representation string
-
csv_two_projects
(p1, padded_p1_cp, p2, padded_p2_cp)[source] Returns CSV report for the alignment between the given projects.
- Parameters
p1 (
Project
) – The first project.padded_p1_cp (
MutableSequence
[Optional
[ConsolidatedPeak
]]) – Padded consolidated peak list for the first project.p2 (
Project
) – The second project.padded_p2_cp (
MutableSequence
[Optional
[ConsolidatedPeak
]]) – Padded consolidated peak list for the second project.
- Return type
-
csv_two_projects_and_unknown
(p1, padded_p1_cp, p2, padded_p2_cp, u, padded_u_cp, *, pair_only=False)[source] Returns CSV report for the alignment between the given projects and unknown.
- Parameters
p1 (
Project
) – The first project.padded_p1_cp (
MutableSequence
[Optional
[ConsolidatedPeak
]]) – Padded consolidated peak list for the first project.p2 (
Project
) – The second project.padded_p2_cp (
MutableSequence
[Optional
[ConsolidatedPeak
]]) – Padded consolidated peak list for the second project.u (
Project
) – The unknown sample.padded_u_cp (
MutableSequence
[Optional
[ConsolidatedPeak
]]) – Padded consolidated peak list for the unknown sample.pair_only (
bool
) – Only show peaks in common between two or more of the projects/unknown. DefaultFalse
.
- Return type
gunshotmatch_reports.chromatogram
PDF Chromatogram Generator.
Functions:
|
Construct a chromatogram report for the given project and write to the chosen file. |
gunshotmatch_reports.peaks
Peak Report Generator.
Classes:
|
Class for producing CSV peak reports. |
|
Helper class for peak metadata for insertion into a PDF or CSV report. |
|
Summary data for a |
Functions:
|
Construct a peak report for the given project and write to the chosen file. |
-
class
CSVReports
(project)[source] Bases:
object
Class for producing CSV peak reports.
- Parameters
project (
Project
) – A GunShotMatch project.
New in version 0.4.0.
Methods:
Produce an overview report of the peaks, giving the name, retention time and peak area of the peaks.
Produce a summary report of the peaks, giving the individual retention times and hits.
-
overview_csv
()[source] Produce an overview report of the peaks, giving the name, retention time and peak area of the peaks.
The output columns are as follows:
Peak No.
Name – The name of the top hit
Rt – Mean retention time
Area – Mean peak area
Area % – Mean peak area as a percentage of the largest peak
MF – Mean match factor for the top hit
Rejected – Whether the peak has been rejected (e.g. with PeakViewer)
The peaks are sorted from largest to smallest.
- Return type
-
summary_csv
()[source] Produce a summary report of the peaks, giving the individual retention times and hits.
The table for each peak mirrors the table in the PDF peak report (
build_peak_report()
). The peaks are sorted from largest to smallest.- Return type
-
class
PeakMetadataTable
(project)[source] Bases:
object
Helper class for peak metadata for insertion into a PDF or CSV report.
- Parameters
project (
Project
) – A GunShotMatch project.
New in version 0.3.0.
Attributes:
Peak areas as percentage of largest peak
The total number of peaks in the project.
Maximum number of rows for the metadata table.
A GunShotMatch project.
Methods:
get_summary_for_peak
(peak, peak_number)Return a formatted summary of the peak.
get_table_for_peak
(peak, peak_number)Return tabulated data on the peak, with individual peak areas, retention times, and the top 5 hits.
-
area_percentages
Peak areas as percentage of largest peak
-
get_summary_for_peak
(peak, peak_number)[source] Return a formatted summary of the peak.
- Parameters
peak (
ConsolidatedPeak
)peak_number (
int
) – The peak number, 1-indexed.
- Return type
-
get_table_for_peak
(peak, peak_number)[source] Return tabulated data on the peak, with individual peak areas, retention times, and the top 5 hits.
-
max_peak_number
The total number of peaks in the project.
-
num_rows
Maximum number of rows for the metadata table.
-
project
A GunShotMatch project.
-
namedtuple
PeakSummary
(peak_no, name, rt, area, area_percentage, mf, rejected)[source] Bases:
NamedTuple
Summary data for a
ConsolidatedPeak
.Formatted for insertion into a PDF or CSV peak report.
New in version 0.3.0.
- Fields
peak_no (
str
) – Peak number, 1-indexedname (
str
) – The name of the top hitrt (
str
) – Mean retention timearea (
str
) – Mean peak areaarea_percentage (
str
) – Mean peak area as a percentage of the largest peakmf (
str
) – Mean match factor for the top hitrejected (
str
) – Whether the peak has been rejected (e.g. with PeakViewer)
-
__repr__
() Return a nicely formatted representation string
gunshotmatch_reports.utils
Utility functions.
Functions:
|
Extend list to the given length with fillvalue. |
|
Convert a matplotlib figure to a reportlab drawing. |
|
Save a PDF without a creation date. |
|
Save an SVG with fixed hashsalt and without a creation date. |
|
Scale reportlab.graphics.shapes.Drawing() object while maintaining aspect ratio. |
-
figure_to_drawing
(figure)[source] Convert a matplotlib figure to a reportlab drawing.
- Parameters
figure (
Figure
)- Return type
Drawing
Contributing
gunshotmatch-reports
uses tox to automate testing and packaging,
and pre-commit to maintain code quality.
Install pre-commit
with pip
and install the git hook:
python -m pip install pre-commit
pre-commit install
Coding style
formate is used for code formatting.
It can be run manually via pre-commit
:
pre-commit run formate -a
Or, to run the complete autoformatting suite:
pre-commit run -a
Automated tests
Tests are run with tox
and pytest
.
To run tests for a specific Python version, such as Python 3.6:
tox -e py36
To run tests for all Python versions, simply run:
tox
Build documentation locally
The documentation is powered by Sphinx. A local copy of the documentation can be built with tox
:
tox -e docs
Downloading source code
The gunshotmatch-reports
source code is available on GitHub,
and can be accessed from the following URL: https://github.com/GunShotMatch/gunshotmatch-reports
If you have git
installed, you can clone the repository with the following command:
git clone https://github.com/GunShotMatch/gunshotmatch-reports
Cloning into 'gunshotmatch-reports'...
remote: Enumerating objects: 47, done.
remote: Counting objects: 100% (47/47), done.
remote: Compressing objects: 100% (41/41), done.
remote: Total 173 (delta 16), reused 17 (delta 6), pack-reused 126
Receiving objects: 100% (173/173), 126.56 KiB | 678.00 KiB/s, done.
Resolving deltas: 100% (66/66), done.

Downloading a ‘zip’ file of the source code
Building from source
The recommended way to build gunshotmatch-reports
is to use tox:
tox -e build
The source and wheel distributions will be in the directory dist
.
If you wish, you may also use pep517.build or another PEP 517-compatible build tool.
License
gunshotmatch-reports
is licensed under the MIT License
A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.
Permissions | Conditions | Limitations |
---|---|---|
|
|
Copyright (c) 2024 Dominic Davis-Foster
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
OR OTHER DEALINGS IN THE SOFTWARE.
View the Function Index or browse the Source Code.