Skip to content

Commit

Permalink
Add BlobClient.get_chrom_signal()
Browse files Browse the repository at this point in the history
  • Loading branch information
ctapobep committed Jan 4, 2025
1 parent 2aa370c commit 074b38b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ All the necessary functionality is exposed from `peakselsdk.Peaksel` class - jus

# Working with source code

1. Install [uv](https://github.com/astral-sh/uv) build tool and run `uv build`
1. Install [uv](https://github.com/astral-sh/uv) build tool and run: `uv venv && uv sync && uv build`
2. In PyCharm mark `src` as Sources Root and `test` as Test Sources Root
3. To run the tests `./test.sh`
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "elsci-peaksel-sdk"
version = "1.0.1"
version = "1.1.0"
description = "SDK to upload and manage chromatographic injections and other data in Elsci Peaksel"
readme = "README.md"
requires-python = ">=3.11"
Expand Down
15 changes: 15 additions & 0 deletions python/src/peakselsdk/blob/BlobClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@ class BlobClient:
def __init__(self, settings: HttpClient):
self.http: HttpClient = settings

def get_chrom_signal(self, blob_id: str) -> tuple[float,...]:
"""
Gets the intensities of the points on a chromatogram. Note, that the time-axis is kept in the DetectorRun
and is shared across all chromatograms in that run, use `get_detector_run_domain(another_blob_id)` to get it.
:param blob_id: is taken from `Chromatogram.eid`
:return: intensities of the chromatogram points
"""
return self._get_1d_floats(blob_id)

def get_detector_run_domain(self, blob_id: str) -> tuple[float,...]:
"""
Returns the time-axis for this run, it's shared across all chromatograms of this detector.
:param blob_id: `DetectorRun.eid`
:return:
"""
return self._get_1d_floats(blob_id)

def get_spectra(self, blob_id: str) -> list[Spectrum]:
Expand Down
8 changes: 8 additions & 0 deletions python/test/sdktest/test_InjectionClientHappyPath.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def test_upload_injection_with_spectra(self):
self.assertChromsExpected(j)
self.assertDrDomainExpected(peaksel.blobs().get_detector_run_domain(j.detectorRuns[0].blobs.domain))
self.assertSpectraExpected(peaksel.blobs().get_spectra(j.detectorRuns[0].blobs.spectra))
# There's no particular order at the moment. Typically, TIC is returned first, so hardcoding 0th chrom for now
self.assertChromSignalExpected(peaksel.blobs().get_chrom_signal(j.chromatograms[0].signalId))

j = self.assertCanAddPeak(j)

batch_id: str = peaksel.batches().assign_injections([j.eid], batch_name="some batch")
Expand Down Expand Up @@ -119,5 +122,10 @@ def assertDrDomainExpected(self, x):
self.assertEqual(8249, len(x))
self.assertEqual(3.0904500484466553, x[0])

def assertChromSignalExpected(self, signal: tuple[float,...]):
self.assertEqual(8249, len(signal))
self.assertEqual(10523.0, signal[0])


if __name__ == '__main__':
unittest.main()

0 comments on commit 074b38b

Please sign in to comment.