Bioinformatics tool outputs converter to JSON or YAML
Project description
Crimson
Crimson converts non-standard bioinformatics tool outputs to JSON or YAML.
Currently it can convert outputs of the following tools:
- FastQC (
fastqc
) - FusionCatcher (
fusioncatcher
) - samtools flagstat (
flagstat
) - Picard metrics tools (
picard
) - STAR log file (
star
) - STAR-Fusion hits table (
star-fusion
) - Variant Effect Predictor
plain text output (
vep
)
For each conversion, there are two execution options: as command line tool or as a Python
library function. The first alternative uses crimson
as a command-line tool. The second one
requires importing the crimson
library in your program.
Installation
Crimson is available on the Python Package Index
and you can install it via pip
:
$ pip install crimson
It is also available on
BioConda, both through the
conda
package manager or as a
Docker container.
For Docker execution, you may also use the GitHub Docker registry. This registry hosts the latest version, but does not host versions 1.1.0 or earlier.
docker pull ghcr.io/bow/crimson
Usage
As a command line tool
The general command is crimson {tool_name}
. By default, the output is written to
stdout
. For example, to use the picard
parser, you would execute:
$ crimson picard /path/to/a/picard.metrics
You can also write the output to a file by specifying a file name. The following
command writes the output to a file named converted.json
:
$ crimson picard /path/to/a/picard.metrics converted.json
Some parsers may accept additional input formats. The FastQC parser, for example, also accepts a path to a FastQC output directory as its input:
$ crimson fastqc /path/to/a/fastqc/dir
It also accepts a path to a zipped result:
$ crimson fastqc /path/to/a/fastqc_result.zip
When in doubt, use the --help
flag:
$ crimson --help # for the general help
$ crimson fastqc --help # for the parser-specific help, in this case FastQC
As a Python library function
The specific function to import is generally located at crimson.{tool_name}.parser
. So to
use the picard
parser in your program, you can do:
from crimson import picard
# You can specify the input file name as a string or path-like object...
parsed = picard.parse("/path/to/a/picard.metrics")
# ... or a file handle
with open("/path/to/a/picard.metrics") as src:
parsed = picard.parse(src)
Why?
- Not enough tools use standard output formats.
- Writing and re-writing the same parsers across different scripts is not a productive way to spend the day.
Local Development
Setting up a local development requires that you set up all of the supported Python versions. We use pyenv for this.
# Clone the repository and cd into it.
$ git clone https://github.com/bow/crimson
$ cd crimson
# Create your local development environment. This command also installs
# all supported Python versions using `pyenv`.
$ make env
# Run the test and linter suite to verify the setup.
$ make lint test
# When in doubt, just run `make` without any arguments.
$ make
Contributing
If you are interested, Crimson accepts the following types contribution:
- Documentation updates / tweaks (if anything seems unclear, feel free to open an issue)
- Bug reports
- Support for tools' outputs which can be converted to JSON or YAML
For any of these, feel free to open an issue in the issue tracker or submit a pull request.
License
Crimson is BSD-licensed. Refer to the LICENSE
file for the full license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file crimson-1.1.1.tar.gz
.
File metadata
- Download URL: crimson-1.1.1.tar.gz
- Upload date:
- Size: 20.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdc54961dbb29cfd9479c310f382475820e80f7158ebc2a732f756dc72b7978d |
|
MD5 | 0f04a6a17086b3f3eb80e0666528e683 |
|
BLAKE2b-256 | d34c5cae5b14b05e34db95b6438372f83b663afbf175e0e7d8c15332e2a30aaa |
File details
Details for the file crimson-1.1.1-py3-none-any.whl
.
File metadata
- Download URL: crimson-1.1.1-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 837db07437d983ada803aef456c76f6c6c792124f8e7fffae413377c1bf4c431 |
|
MD5 | 9e3e4d0ff45f3b871137556a91cb686a |
|
BLAKE2b-256 | 96925e3a134c20e2ee02ff86ac2bcdfe781172937467e49207f7d73ca62c8800 |