This program processes the excel files generated by the XXXX measurement tool to introduce two new sheets:
- An
Aggregates
sheet, that places the metabolites in rows, with each colum representing the areas of different injections - An
Aggregates_formulas
sheet, that contains formulas averaging values in the first introduced sheet
The program has been written as an extensible solution to the needs of a specific lab, however it is meant to be readable and extensible by anyone with average programming skills.
At its core, the program may be used as simply as ${PATH}/excel_converter.py -f <input_filename> -o <output_filename>
. Keep in mind that the output filename MUST contain the .xlsx
suffix. Without the -o <output_filename>
option, the program will simply log the contents of the two sheets it generates.
Below is the help message generated from version 0.1.0
of the tool:
usage: excel_converter.py [-h] -f FILENAME [-o OUTPUT] [-l NOR_LEUCINE_KEY]
[--log-level LOG_LEVEL]
[--log-level-cli {DEBUG,INFO,WARNING,ERROR,CRITICAL,10,20,30,40,50}]
[--log-level-file {DEBUG,INFO,WARNING,ERROR,CRITICAL,10,20,30,40,50}]
[--log-no-cli] [--log-in-file]
options:
-h, --help show this help message and exit
-f FILENAME, --filename FILENAME
The input file to parse
-o OUTPUT, --output OUTPUT
The file to output results into
-l NOR_LEUCINE_KEY, --nor-leucine-key NOR_LEUCINE_KEY
The name of the sheet containing the Nor-Leucine data
--log-level LOG_LEVEL
Log level to use
--log-level-cli {DEBUG,INFO,WARNING,ERROR,CRITICAL,10,20,30,40,50}
Log level to use for CLI. Using this force-enables CLI
logging with maximum priority
--log-level-file {DEBUG,INFO,WARNING,ERROR,CRITICAL,10,20,30,40,50}
Log level to use. Using this force-enables file
logging with max priority
--log-no-cli Skip CLI logging
--log-in-file Activate logging to file
Option | Comment |
---|---|
-f / --filename |
The file to parse and extend. Must have a well-known format |
-o / --output |
The file to create with the results. |
-l / --nor-leucine-key |
Key of the sheet containing the baseline metabolite. Defaults to Nor |
Option | Comment |
---|---|
--log-level |
The global log-level to set. Does not impact activation of types of logging |
--log-level-cli |
Level CLI logging will use. Activates CLI logging if set with maximum precedence |
--log-level-file |
Level file logging will use. Activates file logging if set with maximum precedence |
--log-no-cli |
Deactivates CLI logging (on by default). No impact if CLI level is set |
--log-in-file |
Activates file logging (off by default). If file level is set automatically True |
The log levels one can set can have a value of:
Level | Significance |
---|---|
10 / DEBUG |
Be very verbose. Will show intermediate steps of processing and internals of the function of the script |
20 / INFO |
Be verbose a regular amount. This is the default level for most programs, including the CLI of this one |
30 / WARNING |
Be silent, only showing warning or above messages. Warning means things almost failed but didn't |
40 / ERROR |
Be very silent, only printing out messages if an error has occured |
50 / CRITICAL |
Be extrememly silent, only reporting catastrophic failure. This is meaningless for this software |
It is recommended to keep CLI output in INFO
level (default) and activate file-logging (default level: DEBUG
) if more information is
needed. The logfile can be found in the path from which the script was called and will be named as <program_name without .py suffix>.log
NOTE: For steps to run in Docker
under MS Windows ™️ see RUN_IN_WINDOWS
The executable also comes wrapped in a docker image, for the convenience of users. It may be called thus
FILES_FOLDER=<PATH_TO_YOUR_FILES_FOLDER>
docker run --user $(stat ${FILES_FOLDER} -c '%u:%g') -v ${FILES_FOLDER}:/opt/excel_converter/files/ -ti constantinosstsolomonides/excel_converter:0.1.0
Note that the --rm
is optional, and is used to avoid having instances taking-up space after exiting
This will result in getting an interactive prompt within the container, while having user and group the same as the calling user. It may lead to getting a prompt that seems like a warning, as follows:
groups: cannot find name for group ID XXXX
I have no name!@a4aca2b6b8d8:/opt/excel_converter$
(XXXX
will be a number). That is normal, and will happen because the container can't know every possible group ID, so it will complain, but will result in the output file having the right permissions. By executing the above command, the files will be found under /opt/excel_converter/files/
, while the executable will by default be under /opt/excel_converter/
. The PATH
environment variable has been modified, so the script can be called with the simple use of its name: excel_converter.py
. If file logs are being requested, it is advised to first change path into the files folder, so it survives after the container exits:
FILES_FOLDER=<PATH_TO_YOUR_FILES_FOLDER>
docker run --user $(stat ${FILES_FOLDER} -c '%u:%g') -v ${FILES_FOLDER}:/opt/excel_converter/files/ -ti constantinosstsolomonides/excel_converter:0.1.0
I have no name!@a4aca2b6b8d8:/opt/excel_converter$ cd /opt/excel_converter/files/
I have no name!@d0a1ed5bba54:/opt/excel_converter/files$ excel_converter.py ...
It is for that reason also very important that the output file is also placed in the /opt/excel_converter/files
folder.
Another message that may appear at least once will be the following:
$ docker run --entrypoint=/bin/bash --user $(stat . -c '%u:%g') -v .:/opt/excel_converter/files/ --rm -ti constantinosstsolomonides/excel_converter:0.1.0
Unable to find image 'constantinosstsolomonides/excel_converter:0.1.0' locally
0.1.0: Pulling from constantinosstsolomonides/excel_converter
Digest: sha256:4a88b48c566636a7dac6848157c9a8eaf8922c6aaf347cbea0c517bdfc660b75
Status: Downloaded newer image for constantinosstsolomonides/excel_converter:0.1.0
This is also perfectly normal, it happens because the image is not available locally, so it needs to be pulled before being used.