|
|
|
@ -5,7 +5,7 @@ Parsing the numerical output from Sensovations Sensospot image analysis.
@@ -5,7 +5,7 @@ Parsing the numerical output from Sensovations Sensospot image analysis.
|
|
|
|
|
|
|
|
|
|
__version__ = "2.0.0" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import logging |
|
|
|
|
import pathlib |
|
|
|
|
from typing import Union |
|
|
|
|
|
|
|
|
@ -16,6 +16,9 @@ from . import columns # noqa: F401
@@ -16,6 +16,9 @@ from . import columns # noqa: F401
|
|
|
|
|
from .csv_parser import parse_csv_folder |
|
|
|
|
from .xml_parser import parse_xml_folder |
|
|
|
|
|
|
|
|
|
logging.basicConfig(level=logging.DEBUG) |
|
|
|
|
logger = logging.getLogger("sensospot_parser") |
|
|
|
|
|
|
|
|
|
DEFAULT_OUTPUT_FILENAME = "collected_data.csv" |
|
|
|
|
|
|
|
|
|
PathLike = Union[str, pathlib.Path] |
|
|
|
@ -38,6 +41,9 @@ def parse_folder(source: PathLike, *, quiet: bool = False) -> pandas.DataFrame:
@@ -38,6 +41,9 @@ def parse_folder(source: PathLike, *, quiet: bool = False) -> pandas.DataFrame:
|
|
|
|
|
return parse_xml_folder(source) |
|
|
|
|
except ValueError: |
|
|
|
|
pass |
|
|
|
|
logger.info( |
|
|
|
|
"Could not parse xml results file, using fall-back csv parsing" |
|
|
|
|
) |
|
|
|
|
return parse_csv_folder(source, quiet=quiet) |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -68,14 +74,28 @@ def parse_folder(source: PathLike, *, quiet: bool = False) -> pandas.DataFrame:
@@ -68,14 +74,28 @@ def parse_folder(source: PathLike, *, quiet: bool = False) -> pandas.DataFrame:
|
|
|
|
|
default=False, |
|
|
|
|
help="Ignore sanity check for csv file parsing", |
|
|
|
|
) |
|
|
|
|
def main(sources, output, quiet=False): # noqa: FBT002 |
|
|
|
|
@click.option( |
|
|
|
|
"-v", |
|
|
|
|
"--verbose", |
|
|
|
|
help="Set verbosity of log, add multiple -vv for more verbose logging", |
|
|
|
|
count=True, |
|
|
|
|
) |
|
|
|
|
def main(sources, output, verbose, quiet=False): # noqa: FBT002 |
|
|
|
|
"""Parses the measurement results of the Sensospot reader |
|
|
|
|
|
|
|
|
|
The resulting output is either echoed to stdout or saved to a file. |
|
|
|
|
|
|
|
|
|
At first parsing the assay result xml file is tried. |
|
|
|
|
I this doesn't work, the fallback is to parse the csv files. |
|
|
|
|
If this doesn't work, the fallback is to parse the csv files. |
|
|
|
|
""" |
|
|
|
|
|
|
|
|
|
if verbose == 0: |
|
|
|
|
logging.disable() |
|
|
|
|
elif verbose == 1: |
|
|
|
|
logging.disable(level=logging.DEBUG) |
|
|
|
|
else: |
|
|
|
|
logging.disable(level=logging.NOTSET) |
|
|
|
|
|
|
|
|
|
paths = (pathlib.Path(source) for source in sources) |
|
|
|
|
collection = (parse_folder(source, quiet=quiet) for source in paths) |
|
|
|
|
result = ( |
|
|
|
|