{ "info": { "author": "Oregon Health & Sciences University", "author_email": "loneyf@ohsu.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Scientific/Engineering :: Bio-Informatics" ], "description": "# Immpload - Immport upload preparation\n\n[immpload](https://github.com/biodev/immpload)\nconverts input data files into files formatted from\n[Immport](http://www.immport.org/home) upload templates.\n\n## Prerequisites\n\n* Python3 with the [pip](https://pypi.org/project/pip/) package installer\n\n## Installation\n\n1. Install the `immpload` Python package and executable:\n\n pip install immpload\n\n## Usage\n\nThe simplest case copies input columns whose name matches\nthe corresponding output\n[Immport template](https://www.immport.org/resources/dataTemplates)\ncolumn:\n```\n$ immpload subjectAnimals /path/to/input/subjects.txt\n```\nwhich will create the Immport upload file `subjectAnimals.txt`\nin the current directory.\n\nTo place the output in a different directory, use the `-o` or\n`--outDir` option:\n```\n$ immpload -o /path/to/output subjectAnimals /path/to/input/subjects.xslx\n```\nNote that the input can be either a `.xslx` Excel spreadsheet\nor a tab-delimited text file.\n\nThe command:\n```\n$ immpload --help\n```\nshows all `immpload` arguments and options.\n\n## Mapping Configuration\n\nIt is often useful to specify the conversion mapping in a\n[YAML](https://en.wikipedia.org/wiki/YAML) configuration file.\nFor example, the following configuration:\n```\ncolumns:\n Subject ID: ID\n Arm Or Cohort ID: Cohort\n```\nconverts the `ID` and `Cohort` input values to `Subject ID` and\n`Arm Or Cohort ID` output values, resp. The command is invoked\nwith the `-c` or `--config` option, e.g:\n```\n$ immpload -o /path/to/output --config /path/to/conf/subjects.yaml \\\n subjectAnimals /path/to/input/subjects.xslx\n```\n\nThe configuration can include value mappings, e.g.:\n```\nvalues:\n Species: Mus musculus\n```\nsets the output `Species` to `Mus musculus` for all rows.\n\nThe configuration:\n```\ncolumns:\n Gender: Sex\nvalues:\n Gender:\n n/a: Not Specified\n```\ntransforms the input `Sex` value `n/a` to the output `Gender` value\n`Not Specified`. Other input values are copied without change.\n\n`immpload` can flatten each input row into several output rows based\non matching input column names against a pattern. For example, the\nconfiguration:\n```\ncolumns:\n Subject ID: ID\n Arm Or Cohort ID: Cohort\n Study Day: day\npatterns:\n Result Value Reported: D(?P\\d+)$\n```\nconverts an input row with columns `D1`, `D2` and `D3` into three\noutput rows with column `Study Day` values `1`, `2` and `3`\nand `Result Value Reported` values given by the `D1`, `D2` and `D3`\ninput values, resp.\n\nImmport upload data can be derived solely from fields embedded in\ncolumn names. For example, the configuration:\n```\ncolumns:\n Analyte Reported: analyte\npatterns:\n Analyte Reported: (?P.+)_(?P.+)_(?P.+)$\n```\nmatches the input column names against the given pattern and\nwrites one output row per matching column with the `Analyte Reported`\ncolumn set to the embedded _analyte_ match value. In this case,\nno other input rows are read besides the first header row of column\nnames. Note that `Analyte Reported` is assigned the match value\nrather than the matching column value.\n\n## Defaults\n\n`immpload` supplies certain required output columns with a reasonable\ndefault, as follows:\n\n* Animal Subjects (`subjectAnimals.txt`)\n * `Age Unit` - `Days`\n * `Age Event` - `Age at infection`\n\n* Experiment Samples (`experimentSamples.*.txt`)\n * `Experiment ID` - lower-case, underscored `Experiment Name`\n * `Biosample ID` - `Expsample ID`, if present, otherwise the\n lower-case, underscored `Biosample Name`, if present,\n otherwise derived from the `Subject ID`, `Treatment ID`\n and `Experiment ID`\n * `Expsample ID` - `Biosample ID` (defaulted, if necessary)\n* Treatments (`treatments.txt`)\n * `Name` - derived from the values and units\n * `User Defined ID` - lower-case, underscored `Name`\n * `Use Treatment?` - default is `Yes`\n* Assessments (`assessments.txt`)\n * `Planned Visit ID` - `Study ID` followed by `d` and the `Study Day`\n * `Panel Name Reported` - copied from the `Assessment Type`\n * `Assessment Panel ID` - derived from the `Panel Name Reported`\n * `User Defined ID` - derived from the `Subject ID`,\n `Planned Visit ID` and `Component Name Reported`\n\nThe default is set if and only if the mapped column value is missing.\n\nDefaults are disabled with the `--no-defaults` option, e.g.:\n```\n$ immpload -o /path/to/output --config /path/to/conf/subjects.yaml \\\n --no-defaults subjectAnimals /path/to/input/subjects.xslx\n```\nThis is useful when submitting an update to an existing upload.\n\n## Validation\n\nBy default, `imppload` checks the output for required fields. If a\nrequired field is missing, then an error message is displayed and\nprocessing is halted.\n\nValidation is disabled with the `--no-validate` option, e.g.:\n```\n$ immpload -o /path/to/output --config /path/to/conf/subjects.yaml \\\n --no-validate subjectAnimals /path/to/input/subjects.xslx\n```\nAs with `no-defaults`, `no-validate` is useful when submitting an\nupdate to an existing upload.\n\n## Callbacks\n\nFor advanced usage, the `immpload` Python module can be used directly\nin a Python script with a callback function, e.g.:\n```\nfrom immpload import munger\n\ndef add_results(in_row, in_col_ndx_map, out_col_ndx_map, out_row):\n \"\"\"\n Modifies the output row after the configuration-based conversion.\n\n :param: in_row: the input data row\n :param: in_col_ndx_map: the input {column: index} dictionary\n :param: out_col_ndx_map: the output {column: index} dictionary\n :param: out_row :the output row\n :return: a list of rows derived from the given output row\n \"\"\"\n ###\n ### Modify out_row or create new output rows here...\n ###\n # Return an array of rows.\n return [out_row]\n\n# Convert the input file.\nmunger.munge('assessments', /path/to/input.xslx, callback=add_results)\n```\n\nThe `munger.munge` method signature is as follows:\n```\ndef munge(template, *in_files, config=None, out_dir=None,\n sheet=None, input_filter=None, callback=None, **kwargs):\n \"\"\"\n Builds the Immport upload file for the given input file.\n The template is a supported Immport template name, e.g.\n `assessments`. The output is the Immport upload file,\n e.g. `assessments,txt`, placed in the output directory.\n\n The keyword arguments (_kwargs_) are static output\n _column_`=`_value_ definitions that are applied to every\n output row. The column name can be underscored, e.g.\n `Study_ID`.\n\n Output validation is disabled by default, but recommended\n for new uploads. Enable validation by setting the _validate_\n flag parameter to `True`.\n\n :param template: the required Immport template name\n :param in_files: the input file(s) to munge\n :param config: the configuration dictionary or file name\n of list of file names\n :param out_dir: the target location (default current directory)\n :param sheet: for an Excel workbook input file, the sheet to open\n :param input_filter: optional input row validator which has\n parameter in_row and returns whether the row is valid\n :param callback: optional callback with parameters\n in_row, in_col_ndx_map, out_col_ndx_map and out_row returning\n an array of rows to write to the output file\n :param defaults_opt: flag indicating whether to add defaults to the\n output (default `True`)\n :param validate_opt: flag indicating whether to validate the\n output for required fields (default `True`)\n :param append_opt: append rather than overwrite an existing output\n file (default False)\n :param kwargs: the optional static _column_`=`_value_ definitions\n :return: the output file name\n \"\"\"\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/biodev/imppload/", "keywords": "Immpload", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "immpload", "package_url": "https://pypi.org/project/immpload/", "platform": "Any", "project_url": "https://pypi.org/project/immpload/", "project_urls": { "Homepage": "https://github.com/biodev/imppload/" }, "release_url": "https://pypi.org/project/immpload/1.1.2/", "requires_dist": null, "requires_python": "", "summary": "Immport upload preparation", "version": "1.1.2" }, "last_serial": 5782716, "releases": { "1.0.1": [ { "comment_text": "", "digests": { "md5": "47f8c1a135cbebe9fadf49646314d6ad", "sha256": "cec090bf4d294e258ec2e183cc2ba0511a0b483c2a017738dec9bd6e617c6970" }, "downloads": -1, "filename": "immpload-1.0.1.tar.gz", "has_sig": false, "md5_digest": "47f8c1a135cbebe9fadf49646314d6ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12252, "upload_time": "2019-07-31T21:15:32", "url": "https://files.pythonhosted.org/packages/b3/9e/fce412a4882fad67f7884ce82b560b286353b09ec0378da0d9ae3a059ad4/immpload-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "97d7914cf467b8b62f3f13e5c54da763", "sha256": "577dfdffd7c4c965592441a98b697547bcfa74dab3452cd6642852171deeadf9" }, "downloads": -1, "filename": "immpload-1.0.2.tar.gz", "has_sig": false, "md5_digest": "97d7914cf467b8b62f3f13e5c54da763", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9535, "upload_time": "2019-07-31T21:33:52", "url": "https://files.pythonhosted.org/packages/d6/e8/7cee3e47572e4ccaca12a1144b713bf02a8a5e86647f65a50b160dd9d30f/immpload-1.0.2.tar.gz" } ], "1.0.3": [ { "comment_text": "", "digests": { "md5": "031cb94525088d16673eaf4e93db86f2", "sha256": "17823e6547f90b2daf514b3324698233e1b0e8b10bf5ea621121e8d105639fad" }, "downloads": -1, "filename": "immpload-1.0.3.tar.gz", "has_sig": false, "md5_digest": "031cb94525088d16673eaf4e93db86f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9505, "upload_time": "2019-07-31T21:42:17", "url": "https://files.pythonhosted.org/packages/97/c4/fdd1060bc5ca95452009e56340ad2f6b16b0f678aeaee20aebf90eb4ed49/immpload-1.0.3.tar.gz" } ], "1.0.4": [ { "comment_text": "", "digests": { "md5": "7554e4ad604e3bc6f510d1fd45c33505", "sha256": "12f2fa0b6ea45dc1a100560f84d3e7b342273565b9bec137e1caa153fad3fe06" }, "downloads": -1, "filename": "immpload-1.0.4.tar.gz", "has_sig": false, "md5_digest": "7554e4ad604e3bc6f510d1fd45c33505", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9520, "upload_time": "2019-07-31T21:58:52", "url": "https://files.pythonhosted.org/packages/f9/57/76ed81a4beffd50582f23107f473b60226398a0449a7967e4a9ef0f38281/immpload-1.0.4.tar.gz" } ], "1.0.5": [ { "comment_text": "", "digests": { "md5": "2db6a0ff531e0c6f22338cf7bbda1f04", "sha256": "45dead7f590959c840001bc9ee102c7aebcd7632a2416b705b89315484e214c8" }, "downloads": -1, "filename": "immpload-1.0.5.tar.gz", "has_sig": false, "md5_digest": "2db6a0ff531e0c6f22338cf7bbda1f04", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11439, "upload_time": "2019-08-19T19:27:53", "url": "https://files.pythonhosted.org/packages/9a/2c/5c362750163c6bf793645b5d75615a65b5ba609f2a1f4c51439b2f760a17/immpload-1.0.5.tar.gz" } ], "1.1.1": [ { "comment_text": "", "digests": { "md5": "42cccaa3a18a203deacbfe7c34470443", "sha256": "c7d3dc9d9f0558857f3bb821e3c9755dc916092dd7aabb32624f065194e7ed51" }, "downloads": -1, "filename": "immpload-1.1.1.tar.gz", "has_sig": false, "md5_digest": "42cccaa3a18a203deacbfe7c34470443", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16270, "upload_time": "2019-09-04T01:16:43", "url": "https://files.pythonhosted.org/packages/68/75/8afe4d056abb1fc80461b94c80c3a02f6f78a3132bb4750b2ebb82b912dd/immpload-1.1.1.tar.gz" } ], "1.1.2": [ { "comment_text": "", "digests": { "md5": "c65c5ecf7014b42081181c36b3fdb664", "sha256": "c9e143287efcfafbe302a9c561d056aede56cf5b9eb883de185f77044368fced" }, "downloads": -1, "filename": "immpload-1.1.2.tar.gz", "has_sig": false, "md5_digest": "c65c5ecf7014b42081181c36b3fdb664", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16250, "upload_time": "2019-09-04T17:48:03", "url": "https://files.pythonhosted.org/packages/30/1b/9b69a65845ff24bae007c1387ef13a6e6bea3c8b5df2831dc0836c254540/immpload-1.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "c65c5ecf7014b42081181c36b3fdb664", "sha256": "c9e143287efcfafbe302a9c561d056aede56cf5b9eb883de185f77044368fced" }, "downloads": -1, "filename": "immpload-1.1.2.tar.gz", "has_sig": false, "md5_digest": "c65c5ecf7014b42081181c36b3fdb664", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16250, "upload_time": "2019-09-04T17:48:03", "url": "https://files.pythonhosted.org/packages/30/1b/9b69a65845ff24bae007c1387ef13a6e6bea3c8b5df2831dc0836c254540/immpload-1.1.2.tar.gz" } ] }