{ "cells": [ { "cell_type": "markdown", "id": "5a242f0d", "metadata": {}, "source": [ "# Library manipulation scripts\n", "\n", "This notebook showcases several useful commands that allow following library manipulations:\n", "\n", "- Library concatenation (`molli merge`)\n", "- Subset selection based on regular expression (`molli pick`)\n", "- Collect descriptive statistics (`molli stats`)" ] }, { "cell_type": "markdown", "id": "b257f789", "metadata": {}, "source": [ "## `molli merge`\n", "\n", "When several files (.mlib / .clib) are specified as positional arguments, those files are sequentially read (without interpretation!) and written into a new file.\n", "Linux style glob patterns are supported: `molli merge *.clib`\n", "\n", "**It is the user's responsibility to ensure homogeneous inputs**" ] }, { "cell_type": "code", "execution_count": 4, "id": "2721d25c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "usage: molli merge [-h] -o [-c COMMENT] [--overwrite] [--sort]\n", " sources [sources ...]\n", "\n", "Merge several molli libraries into a single file\n", "\n", "positional arguments:\n", " sources List of library files (or glob patterns)\n", "\n", "options:\n", " -h, --help show this help message and exit\n", " -o , --output \n", " Merge the files into this output file\n", " -c COMMENT, --comment COMMENT\n", " Specify a text based comment to override the uKV\n", " default\n", " --overwrite Overwrite the target files if they exist (default is\n", " false)\n", " --sort Sort the keys before writing\n" ] } ], "source": [ "!molli merge --help" ] }, { "cell_type": "markdown", "id": "af5babf3", "metadata": {}, "source": [] }, { "cell_type": "markdown", "id": "2621ee72", "metadata": {}, "source": [ "## `molli pick`\n", "\n", "This script iterates over a library keys, attempting to match key to each of patterns specified as positional arguments that follow.\n", "For full documentation on regular expressions, see [Python re module documentation](https://docs.python.org/3/library/re.html)\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "usage: molli pick [-h] [-f FILE] [-o ] [--overwrite] [--sort]\n", " source [patterns ...]\n", "\n", "Merge several molli libraries into a single file\n", "\n", "positional arguments:\n", " source Library file\n", " patterns List of regular expressions to match\n", "\n", "options:\n", " -h, --help show this help message and exit\n", " -f FILE, --file FILE Specify the name patterns from file\n", " -o , --output \n", " Merge the files into this output file\n", " --overwrite Overwrite the target files if they exist (default is\n", " false)\n", " --sort Sort the keys before writing\n" ] } ], "source": [ "!molli pick --help" ] } ], "metadata": { "kernelspec": { "display_name": "molli", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.11" } }, "nbformat": 4, "nbformat_minor": 5 }