Skip to content

Commit

Permalink
fixed multiline issue with ref agilent reader
Browse files Browse the repository at this point in the history
  • Loading branch information
haeussma committed Nov 4, 2024
1 parent d21576d commit 0b5469b
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 31 deletions.
1 change: 1 addition & 0 deletions chromatopy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os

from .tools.analyzer import ChromAnalyzer
from .tools.molecule import Molecule
from .units.predefined import C, K, celsius, hour, kelvin, minute, second
11 changes: 7 additions & 4 deletions chromatopy/readers/agilent_rdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,14 @@ def align_and_concatenate_columns(row1, row2):
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)
]
if row2_columns:
aligned_columns = [
f"{col1}{col2}".strip()
for col1, col2 in zip(row1_columns, row2_columns)
]
return aligned_columns[1:-1]

return aligned_columns[1:-1]
return row1_columns[1:-1]

@staticmethod
def map_peak(peak_list: list[str]) -> Peak:
Expand Down
39 changes: 12 additions & 27 deletions chromatopy/tools/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,6 @@ def read_agilent(

try:
txt_path = next(directory.rglob("*.txt"))
print("sole path: ", txt_path, flush=True)
print(f"all txt paths: {list(directory.rglob('*.txt'))}", flush=True)
print(f"everything: {directory.rglob('*')}", flush=True)
try:
lines = AgilentRDLReader.read_file(str(txt_path))
if lines[0].startswith("┌─────"):
Expand Down Expand Up @@ -853,7 +850,7 @@ def process_chromatograms(
)

def visualize_all(
self, assigned_only: bool = False, dark_mode: bool = False
self, assigned_only: bool = False, dark_mode: bool = False, show: bool = False
) -> go.Figure:
"""Plots the fitted peaks of the chromatograms in an interactive figure.
Expand Down Expand Up @@ -1060,7 +1057,10 @@ def visualize_all(
template=theme,
)

return fig
if show:
fig.show()
else:
return fig

def add_standard(
self,
Expand Down Expand Up @@ -1220,26 +1220,11 @@ def visualize_spectra(self, dark_mode: bool = False) -> go.Figure:


if __name__ == "__main__":
data = "/Users/max/Documents/GitHub/martina-aldol-addition/data/aldehyde"
from pathlib import Path

exp_paths = Path(data).iterdir()

for folder_id, folder in enumerate(exp_paths):
if folder.is_dir():
print(folder.name)
concentration = float(folder.name.split(" ")[0])

analyzer = ChromAnalyzer.read_shimadzu(
path=folder, ph=7.0, temperature=25.0, mode="timecourse"
)

# analyzer.add_molecule(aldol, init_conc=concentration, conc_unit=mM)
path = "/Users/max/Documents/GitHub/jan-niklas/MjNK/Standard/Ado 60961"

if folder_id == 0:
print("first")
enzmldoc = analyzer.to_enzymeml(
name="varied initial aldehyde concentrations"
)
else:
analyzer.add_to_enzymeml(enzmldoc)
reader = ChromAnalyzer.read_agilent(
path=path,
mode="calibration",
ph=7,
temperature=25,
)

0 comments on commit 0b5469b

Please sign in to comment.