-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added agilent rdl * updated docs * Bump version to 0.9.6 in pyproject.toml * fixed unicode decode error * added debug print * Fix debug print statement and update file path string formatting * Update pytest command to include verbose output * Update pytest command to include verbose output * Fix assertion error in test_windows * Refactor debug print statements and flush output in analyzer.py * Refactor debug print statements and flush output in analyzer.py * Refactor debug print statements and improve error handling in analyzer.py * Refactor debug print statements and add error handling in analyzer.py * Refactor file reading in AgilentRDLReader to specify UTF-8 encoding * Refactor debug print statements and remove unnecessary variables in analyzer.py * Refactor debug print statements and update error handling in analyzer.py * Refactor debug print statements and update error handling in analyzer.py * Refactor error handling in analyzer.py
- Loading branch information
Showing
16 changed files
with
295,815 additions
and
295,476 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,4 +27,4 @@ jobs: | |
- name: Run tests with pytest | ||
run: | | ||
poetry run pytest --nbval-lax | ||
poetry run pytest --nbval-lax -s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import re | ||
from typing import Tuple | ||
|
||
from chromatopy.model import Chromatogram, Data, Measurement, Peak | ||
from chromatopy.readers.abstractreader import AbstractReader | ||
|
||
|
||
class AgilentRDLReader(AbstractReader): | ||
def read(self): | ||
measurements = [] | ||
for path_id, path in enumerate(self.file_paths): | ||
lines = self.read_file(path) | ||
|
||
peak_data, sample_name, signal = self.extract_information(lines) | ||
|
||
peak_data = [ | ||
self.align_and_concatenate_columns(*pair) for pair in peak_data | ||
] | ||
peaks = [self.map_peak(peak) for peak in peak_data] | ||
|
||
sample_name = self.align_and_concatenate_columns(*sample_name)[1] | ||
|
||
wavelength = self.extract_wavelength(signal) | ||
|
||
data = Data( | ||
value=self.values[path_id], | ||
unit=self.unit, | ||
data_type=self.mode, | ||
) | ||
|
||
chromatogram = Chromatogram(peaks=peaks, wavelength=wavelength) | ||
|
||
measurements.append( | ||
Measurement( | ||
id=f"m{path_id}", | ||
chromatograms=[chromatogram], | ||
temperature=self.temperature, | ||
temperature_unit=self.temperature_unit, | ||
ph=self.ph, | ||
data=data, | ||
) | ||
) | ||
|
||
if not self.silent: | ||
self.print_success(len(measurements)) | ||
|
||
return measurements | ||
|
||
@staticmethod | ||
def read_file(file_path: str) -> list[str]: | ||
with open(file_path, "r", encoding="utf-8") as file: | ||
lines = file.readlines() | ||
|
||
return lines | ||
|
||
@staticmethod | ||
def extract_information(lines: list[str]) -> Tuple[list[list[str]], list[str], str]: | ||
data = [] | ||
for i, line in enumerate(lines): | ||
# Check for first line with float values after space and pipe characters | ||
if re.search(r"^\s{2}β\s+\d+\.\d+\s+β", line): | ||
line_pair = [line] | ||
|
||
if lines[i + 1].startswith(" β"): | ||
line_pair.append(lines[i + 1]) | ||
else: | ||
line_pair.append("") | ||
|
||
data.append(line_pair) | ||
|
||
if "βSample Name β" in line: | ||
sample_name = [line] | ||
if lines[i + 1].startswith(" β"): | ||
sample_name.append(lines[i + 1]) | ||
else: | ||
sample_name.append("") | ||
|
||
if "βSignal:β" in line: | ||
signal = line | ||
|
||
return data, sample_name, signal | ||
|
||
@staticmethod | ||
def extract_wavelength(line: str) -> int | None: | ||
pattern = r"Sig=(\d+)" | ||
|
||
match = re.search(pattern, line) | ||
if match: | ||
return int(match.group(1)) | ||
else: | ||
return None | ||
|
||
@staticmethod | ||
def align_and_concatenate_columns(row1, row2): | ||
# Split each string by the vertical bar 'β' and strip whitespace from each column | ||
row1_columns = [col.strip() for col in re.split(r"β", row1) if col] | ||
row2_columns = [col.strip() for col in re.split(r"β", row2) if col] | ||
|
||
# Concatenate aligned columns | ||
aligned_columns = [ | ||
f"{col1}{col2}".strip() for col1, col2 in zip(row1_columns, row2_columns) | ||
] | ||
|
||
return aligned_columns[1:-1] | ||
|
||
@staticmethod | ||
def map_peak(peak_list: list[str]) -> Peak: | ||
return Peak( | ||
retention_time=float(peak_list[0]), | ||
type=peak_list[1], | ||
width=float(peak_list[2]), | ||
area=float(peak_list[3]), | ||
amplitude=float(peak_list[4]), | ||
percent_area=float(peak_list[5]), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
βCross Sequence Summary Report β | ||
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
βSample Name βM2_MJ_ β | ||
β β100_min β | ||
ββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
βββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
βSignal:βDAD1A,Sig=254,4 Ref=360,100 β | ||
βββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
βββββββββ¬ββββ¬βββββββββ¬βββββββββ¬ββββββββ¬βββββββββ¬ββββββββββββββββββββββββββββββ | ||
β RT βTypβ Width β Area β Heightβ Area% βName β | ||
β [min] βe β [min] β β β β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 0.698 βBV β 0.4062 β 53. β 7.2642β 0.3671 β β | ||
β β β β 0992 β β β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 1.169 βVV β 0.8468 β 6094. β 783.β 42. βAMP@1,169min β | ||
β β β β 3336 β 0775β 1289 β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 2.756 βVB β 0.4315 β 14. β 1.9341β 0.0982 β β | ||
β β β β 2114 β β β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 3.331 βBV β 0.7823 β 7620. β 925.β 52. βADP@3,327min β | ||
β β β β 7030 β 5433β 6804 β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 3.974 βVB β 1.5648 β 381. β 55.β 2.6397 β β | ||
β β β β 8593 β 0016β β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 5.770 βBB β 1.0452 β 301. β 22.β 2.0856 βATP@5,720min β | ||
β β β β 7014 β 1066β β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β β β Sum β 14465. β β β β | ||
β β β β 9079 β β β β | ||
βββββββββ΄ββββ΄βββββββββ΄βββββββββ΄ββββββββ΄βββββββββ΄ββββββββββββββββββββββββββββββ | ||
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββ | ||
βD:\CDSProjects\JNS\Report β Printed: 2024-10-20 β Page 1 of 1 β | ||
βTemplates\Export_for_ β 16:25:44+02:00 β β | ||
βpython.rdl [Rev. 2.0] β β β | ||
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
βCross Sequence Summary Report β | ||
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
βSample Name βM2_MJ_ β | ||
β β100_min β | ||
ββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
βββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
βSignal:βDAD1A,Sig=254,4 Ref=360,100 β | ||
βββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
βββββββββ¬ββββ¬βββββββββ¬βββββββββ¬ββββββββ¬βββββββββ¬ββββββββββββββββββββββββββββββ | ||
β RT βTypβ Width β Area β Heightβ Area% βName β | ||
β [min] βe β [min] β β β β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 0.698 βBV β 0.4062 β 53. β 7.2642β 0.3671 β β | ||
β β β β 0992 β β β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 1.169 βVV β 0.8468 β 6094. β 783.β 42. βAMP@1,169min β | ||
β β β β 3336 β 0775β 1289 β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 2.756 βVB β 0.4315 β 14. β 1.9341β 0.0982 β β | ||
β β β β 2114 β β β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 3.331 βBV β 0.7823 β 7620. β 925.β 52. βADP@3,327min β | ||
β β β β 7030 β 5433β 6804 β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 3.974 βVB β 1.5648 β 381. β 55.β 2.6397 β β | ||
β β β β 8593 β 0016β β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β 5.770 βBB β 1.0452 β 301. β 22.β 2.0856 βATP@5,720min β | ||
β β β β 7014 β 1066β β β | ||
βββββββββΌββββΌβββββββββΌβββββββββΌββββββββΌβββββββββΌββββββββββββββββββββββββββββββ€ | ||
β β β Sum β 14465. β β β β | ||
β β β β 9079 β β β β | ||
βββββββββ΄ββββ΄βββββββββ΄βββββββββ΄ββββββββ΄βββββββββ΄ββββββββββββββββββββββββββββββ | ||
βββββββββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββ¬ββββββββββββββββββ | ||
βD:\CDSProjects\JNS\Report β Printed: 2024-10-20 β Page 1 of 1 β | ||
βTemplates\Export_for_ β 16:25:44+02:00 β β | ||
βpython.rdl [Rev. 2.0] β β β | ||
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ |
Oops, something went wrong.