-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Added HPLC Reader (as tar archive) (#102)
build: added dependency: [BinaryParser](https://github.com/ComPlat/BinaryParser) split requirements for dev and prod environments: * production: use pre-built parser : target sys_platform == "linux" (linux_x86_64) and python_version == "3.12" * dev : build using wheel pybind11 --------- Co-authored-by: Martin <m.starman@live.comdd>
- Loading branch information
1 parent
fcc9284
commit e11249b
Showing
28 changed files
with
116 additions
and
42 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
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 |
---|---|---|
|
@@ -6,7 +6,6 @@ | |
import tempfile | ||
import uuid | ||
from collections import defaultdict | ||
|
||
from pathlib import Path | ||
|
||
import magic | ||
|
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
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
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,62 @@ | ||
import logging | ||
|
||
import hplc as ph | ||
|
||
from converter_app.readers.helper.base import Reader | ||
from converter_app.readers.helper.reader import Readers | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
class HplcReader(Reader): | ||
""" | ||
Reads tarballed hplc files with extension .tar.gz | ||
""" | ||
identifier = 'hplc_reader' | ||
priority = 5 | ||
|
||
def __init__(self, file, *tar_files): | ||
super().__init__(file, *tar_files) | ||
self.df = None | ||
self.temp_dir = None | ||
|
||
def check(self): | ||
""" | ||
:return: True if it fits | ||
""" | ||
|
||
if self.is_tar_ball: | ||
try: | ||
if len(self.file_content) > 1: | ||
self.df = ph.read_chromatograms(self.file_content[0].file_path) | ||
else: | ||
return False | ||
return True | ||
except ValueError: | ||
pass | ||
return False | ||
|
||
def prepare_tables(self): | ||
tables = [] | ||
|
||
keys = list(self.df.keys()) | ||
waves = [x for x in keys if x.startswith('Wave')] | ||
waves.sort() | ||
time = self.df['time'] | ||
for wave_key in waves: | ||
wave = self.df[wave_key] | ||
table = self.append_table(tables) | ||
kv = wave_key.split('_') | ||
table['metadata'][kv[0]] = str(kv[1]) | ||
table['metadata']['AllWaves'] = str(waves) | ||
for i, t in enumerate(time): | ||
table['rows'].append([t, float(wave[i])]) | ||
|
||
table['columns'] = [{ | ||
'key': str(idx), | ||
'name': f'{value}' | ||
} for idx, value in enumerate(['Time', 'Wavelength'])] | ||
return tables | ||
|
||
|
||
Readers.instance().register(HplcReader) |
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
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
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
import logging | ||
|
||
import xml.etree.ElementTree as ET | ||
|
||
from converter_app.models import File | ||
|
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
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 |
---|---|---|
@@ -1,15 +1,4 @@ | ||
defusedxml~=0.7.1 | ||
Flask~=2.0.2 | ||
Flask-Cors~=3.0.10 | ||
Flask-HTTPAuth~=4.5.0 | ||
gunicorn~=20.1.0 | ||
openpyxl~=3.0.9 | ||
python-dotenv~=0.19.2 | ||
python-magic~=0.4.24 | ||
gemmi~=0.6.6 | ||
xlrd~=2.0.1 | ||
Werkzeug~=2.2.2 | ||
jcamp~=1.2.2 | ||
PyMuPDF==1.23.7 | ||
pylint==3.0.3 | ||
str2bool~=1.1 | ||
-r default.txt | ||
|
||
binaryparser @ https://github.com/ComPlat/BinaryParser/releases/download/v1.0.0/BinaryParser-0.0.1-cp312-cp312-linux_x86_64.whl ; sys_platform == "linux" and python_version == "3.12" | ||
|
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,15 @@ | ||
defusedxml~=0.7.1 | ||
Flask~=2.0.2 | ||
Flask-Cors~=3.0.10 | ||
Flask-HTTPAuth~=4.5.0 | ||
gunicorn~=20.1.0 | ||
openpyxl~=3.0.9 | ||
python-dotenv~=0.19.2 | ||
python-magic~=0.4.24 | ||
gemmi~=0.6.6 | ||
xlrd~=2.0.1 | ||
Werkzeug~=2.2.2 | ||
jcamp~=1.2.2 | ||
PyMuPDF==1.23.7 | ||
pylint==3.0.3 | ||
str2bool~=1.1 |
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 |
---|---|---|
@@ -1,8 +1,12 @@ | ||
-r common.txt | ||
-r default.txt | ||
|
||
coverage | ||
pytest | ||
pytest-dotenv | ||
pytest-cov | ||
pytest-flask | ||
GitPython | ||
wheel | ||
setuptools | ||
pybind11 | ||
binaryparser @ git+https://github.com/ComPlat/BinaryParser@main |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import os | ||
import shutil | ||
import tempfile | ||
|
||
import git | ||
|
||
# Get the current script's directory | ||
|