RiboMetric 0.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- RiboMetric-0.1.2/AUTHORS.rst +13 -0
- RiboMetric-0.1.2/CONTRIBUTING.rst +128 -0
- RiboMetric-0.1.2/HISTORY.rst +8 -0
- RiboMetric-0.1.2/LICENSE +22 -0
- RiboMetric-0.1.2/MANIFEST.in +12 -0
- RiboMetric-0.1.2/PKG-INFO +20 -0
- RiboMetric-0.1.2/README.rst +41 -0
- RiboMetric-0.1.2/RiboMetric/RiboMetric.py +387 -0
- RiboMetric-0.1.2/RiboMetric/__init__.py +5 -0
- RiboMetric-0.1.2/RiboMetric/cli.py +17 -0
- RiboMetric-0.1.2/RiboMetric/file_parser.py +314 -0
- RiboMetric-0.1.2/RiboMetric/html_report.py +79 -0
- RiboMetric-0.1.2/RiboMetric/json_output.py +43 -0
- RiboMetric-0.1.2/RiboMetric/metrics.py +107 -0
- RiboMetric-0.1.2/RiboMetric/modules.py +451 -0
- RiboMetric-0.1.2/RiboMetric/plots.py +716 -0
- RiboMetric-0.1.2/RiboMetric/qc.py +210 -0
- RiboMetric-0.1.2/RiboMetric.egg-info/PKG-INFO +20 -0
- RiboMetric-0.1.2/RiboMetric.egg-info/SOURCES.txt +46 -0
- RiboMetric-0.1.2/RiboMetric.egg-info/dependency_links.txt +1 -0
- RiboMetric-0.1.2/RiboMetric.egg-info/entry_points.txt +2 -0
- RiboMetric-0.1.2/RiboMetric.egg-info/not-zip-safe +1 -0
- RiboMetric-0.1.2/RiboMetric.egg-info/top_level.txt +1 -0
- RiboMetric-0.1.2/docs/Makefile +20 -0
- RiboMetric-0.1.2/docs/authors.rst +1 -0
- RiboMetric-0.1.2/docs/conf.py +164 -0
- RiboMetric-0.1.2/docs/contributing.rst +1 -0
- RiboMetric-0.1.2/docs/history.rst +1 -0
- RiboMetric-0.1.2/docs/index.rst +20 -0
- RiboMetric-0.1.2/docs/installation.rst +51 -0
- RiboMetric-0.1.2/docs/make.bat +36 -0
- RiboMetric-0.1.2/docs/readme.rst +1 -0
- RiboMetric-0.1.2/docs/usage.rst +7 -0
- RiboMetric-0.1.2/setup.cfg +23 -0
- RiboMetric-0.1.2/setup.py +56 -0
- RiboMetric-0.1.2/tests/__init__.py +1 -0
- RiboMetric-0.1.2/tests/test_RiboMetric.py +66 -0
- RiboMetric-0.1.2/tests/test_data/1000_entry.gff +1000 -0
- RiboMetric-0.1.2/tests/test_data/1000_entry_RiboMetric.tsv +6 -0
- RiboMetric-0.1.2/tests/test_data/1000_entry_RibosomeProfiler.tsv +6 -0
- RiboMetric-0.1.2/tests/test_data/parsed_test.csv +10002 -0
- RiboMetric-0.1.2/tests/test_data/test.bam +0 -0
- RiboMetric-0.1.2/tests/test_data/test.csv +6 -0
- RiboMetric-0.1.2/tests/test_metrics.py +41 -0
- RiboMetric-0.1.2/tests/test_modules.py +67 -0
- RiboMetric-0.1.2/tests/test_parser.py +10 -0
- RiboMetric-0.1.2/tests/test_plots.py +63 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
.. highlight:: shell
|
|
2
|
+
|
|
3
|
+
============
|
|
4
|
+
Contributing
|
|
5
|
+
============
|
|
6
|
+
|
|
7
|
+
Contributions are welcome, and they are greatly appreciated! Every little bit
|
|
8
|
+
helps, and credit will always be given.
|
|
9
|
+
|
|
10
|
+
You can contribute in many ways:
|
|
11
|
+
|
|
12
|
+
Types of Contributions
|
|
13
|
+
----------------------
|
|
14
|
+
|
|
15
|
+
Report Bugs
|
|
16
|
+
~~~~~~~~~~~
|
|
17
|
+
|
|
18
|
+
Report bugs at https://github.com/JackCurragh/Ribosome/issues.
|
|
19
|
+
|
|
20
|
+
If you are reporting a bug, please include:
|
|
21
|
+
|
|
22
|
+
* Your operating system name and version.
|
|
23
|
+
* Any details about your local setup that might be helpful in troubleshooting.
|
|
24
|
+
* Detailed steps to reproduce the bug.
|
|
25
|
+
|
|
26
|
+
Fix Bugs
|
|
27
|
+
~~~~~~~~
|
|
28
|
+
|
|
29
|
+
Look through the GitHub issues for bugs. Anything tagged with "bug" and "help
|
|
30
|
+
wanted" is open to whoever wants to implement it.
|
|
31
|
+
|
|
32
|
+
Implement Features
|
|
33
|
+
~~~~~~~~~~~~~~~~~~
|
|
34
|
+
|
|
35
|
+
Look through the GitHub issues for features. Anything tagged with "enhancement"
|
|
36
|
+
and "help wanted" is open to whoever wants to implement it.
|
|
37
|
+
|
|
38
|
+
Write Documentation
|
|
39
|
+
~~~~~~~~~~~~~~~~~~~
|
|
40
|
+
|
|
41
|
+
RiboMetric could always use more documentation, whether as part of the
|
|
42
|
+
official RiboMetric docs, in docstrings, or even on the web in blog posts,
|
|
43
|
+
articles, and such.
|
|
44
|
+
|
|
45
|
+
Submit Feedback
|
|
46
|
+
~~~~~~~~~~~~~~~
|
|
47
|
+
|
|
48
|
+
The best way to send feedback is to file an issue at https://github.com/JackCurragh/RiboMetric/issues.
|
|
49
|
+
|
|
50
|
+
If you are proposing a feature:
|
|
51
|
+
|
|
52
|
+
* Explain in detail how it would work.
|
|
53
|
+
* Keep the scope as narrow as possible, to make it easier to implement.
|
|
54
|
+
* Remember that this is a volunteer-driven project, and that contributions
|
|
55
|
+
are welcome :)
|
|
56
|
+
|
|
57
|
+
Get Started!
|
|
58
|
+
------------
|
|
59
|
+
|
|
60
|
+
Ready to contribute? Here's how to set up `RiboMetric` for local development.
|
|
61
|
+
|
|
62
|
+
1. Fork the `RiboMetric` repo on GitHub.
|
|
63
|
+
2. Clone your fork locally::
|
|
64
|
+
|
|
65
|
+
$ git clone git@github.com:your_name_here/RiboMetric.git
|
|
66
|
+
|
|
67
|
+
3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development::
|
|
68
|
+
|
|
69
|
+
$ mkvirtualenv RiboMetric
|
|
70
|
+
$ cd RiboMetric/
|
|
71
|
+
$ python setup.py develop
|
|
72
|
+
|
|
73
|
+
4. Create a branch for local development::
|
|
74
|
+
|
|
75
|
+
$ git checkout -b name-of-your-bugfix-or-feature
|
|
76
|
+
|
|
77
|
+
Now you can make your changes locally.
|
|
78
|
+
|
|
79
|
+
5. When you're done making changes, check that your changes pass flake8 and the
|
|
80
|
+
tests, including testing other Python versions with tox::
|
|
81
|
+
|
|
82
|
+
$ flake8 RiboMetric tests
|
|
83
|
+
$ python setup.py test or pytest
|
|
84
|
+
$ tox
|
|
85
|
+
|
|
86
|
+
To get flake8 and tox, just pip install them into your virtualenv.
|
|
87
|
+
|
|
88
|
+
6. Commit your changes and push your branch to GitHub::
|
|
89
|
+
|
|
90
|
+
$ git add .
|
|
91
|
+
$ git commit -m "Your detailed description of your changes."
|
|
92
|
+
$ git push origin name-of-your-bugfix-or-feature
|
|
93
|
+
|
|
94
|
+
7. Submit a pull request through the GitHub website.
|
|
95
|
+
|
|
96
|
+
Pull Request Guidelines
|
|
97
|
+
-----------------------
|
|
98
|
+
|
|
99
|
+
Before you submit a pull request, check that it meets these guidelines:
|
|
100
|
+
|
|
101
|
+
1. The pull request should include tests.
|
|
102
|
+
2. If the pull request adds functionality, the docs should be updated. Put
|
|
103
|
+
your new functionality into a function with a docstring, and add the
|
|
104
|
+
feature to the list in README.rst.
|
|
105
|
+
3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check
|
|
106
|
+
https://travis-ci.com/JackCurragh/RiboMetric/pull_requests
|
|
107
|
+
and make sure that the tests pass for all supported Python versions.
|
|
108
|
+
|
|
109
|
+
Tips
|
|
110
|
+
----
|
|
111
|
+
|
|
112
|
+
To run a subset of tests::
|
|
113
|
+
|
|
114
|
+
$ pytest tests.test_RiboMetric
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
Deploying
|
|
118
|
+
---------
|
|
119
|
+
|
|
120
|
+
A reminder for the maintainers on how to deploy.
|
|
121
|
+
Make sure all your changes are committed (including an entry in HISTORY.rst).
|
|
122
|
+
Then run::
|
|
123
|
+
|
|
124
|
+
$ bump2version patch # possible: major / minor / patch
|
|
125
|
+
$ git push
|
|
126
|
+
$ git push --tags
|
|
127
|
+
|
|
128
|
+
Travis will then deploy to PyPI if tests pass.
|
RiboMetric-0.1.2/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023, Jack Tierney
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
include AUTHORS.rst
|
|
2
|
+
include CONTRIBUTING.rst
|
|
3
|
+
include HISTORY.rst
|
|
4
|
+
include LICENSE
|
|
5
|
+
include README.rst
|
|
6
|
+
|
|
7
|
+
recursive-include tests *
|
|
8
|
+
recursive-exclude * __pycache__
|
|
9
|
+
recursive-exclude * *.py[co]
|
|
10
|
+
recursive-exclude sample_data *
|
|
11
|
+
|
|
12
|
+
recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: RiboMetric
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: A python command-line utility for the generation of comprehensive reports on the quality of ribosome profiling (Ribo-Seq) datasets
|
|
5
|
+
Home-page: https://github.com/JackCurragh/RiboMetric
|
|
6
|
+
Author: Jack Tierney
|
|
7
|
+
Author-email: jackcurragh@gmail.com
|
|
8
|
+
License: MIT license
|
|
9
|
+
Keywords: RiboMetric
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Natural Language :: English
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Requires-Python: >=3.8
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
License-File: AUTHORS.rst
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
================
|
|
2
|
+
RiboMetric
|
|
3
|
+
================
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
.. image:: https://img.shields.io/pypi/v/RiboMetric.svg
|
|
7
|
+
:target: https://pypi.python.org/pypi/RiboMetric
|
|
8
|
+
|
|
9
|
+
.. image:: https://readthedocs.org/projects/RiboMetric/badge/?version=latest
|
|
10
|
+
:target: https://RiboMetric.readthedocs.io/en/latest/?version=latest
|
|
11
|
+
:alt: Documentation Status
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
.. image:: https://pyup.io/repos/github/JackCurragh/RiboMetric/shield.svg
|
|
15
|
+
:target: https://pyup.io/repos/github/JackCurragh/RiboMetric/
|
|
16
|
+
:alt: Updates
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
A python command-line utility for the generation of comprehensive reports on the quality of ribosome profiling (Ribo-Seq) datasets
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
* Free software: MIT license
|
|
24
|
+
* Documentation: https://RiboMetric.readthedocs.io.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Features
|
|
28
|
+
--------
|
|
29
|
+
|
|
30
|
+
There are a number of limitations to running RiboMetric at the moment. These include:
|
|
31
|
+
|
|
32
|
+
* Transciptomic alignments are required in BAM format
|
|
33
|
+
* GFF annotations from Ensembl are also requried
|
|
34
|
+
|
|
35
|
+
Credits
|
|
36
|
+
-------
|
|
37
|
+
|
|
38
|
+
This package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.
|
|
39
|
+
|
|
40
|
+
.. _Cookiecutter: https://github.com/audreyr/cookiecutter
|
|
41
|
+
.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Main module for RiboMetric
|
|
3
|
+
Handles the command line interface and calls the appropriate functions
|
|
4
|
+
|
|
5
|
+
Many different input combinations are possible.
|
|
6
|
+
|
|
7
|
+
Minimal Set:
|
|
8
|
+
-b, --bam <path> : Path to the bam file
|
|
9
|
+
|
|
10
|
+
With this set the calculations will potentially less reliable and no gene
|
|
11
|
+
feature information will be included in the output
|
|
12
|
+
|
|
13
|
+
Standard Set:
|
|
14
|
+
-b, --bam <path> : Path to the bam file
|
|
15
|
+
-g, --gff <path> : Path to the gff file
|
|
16
|
+
|
|
17
|
+
with this set the calculations will be more reliable and gene feature
|
|
18
|
+
information will be included in the output
|
|
19
|
+
|
|
20
|
+
Full Set:
|
|
21
|
+
-b, --bam <path> : Path to the bam file
|
|
22
|
+
-g, --gff <path> : Path to the gff file
|
|
23
|
+
-t, --transcriptome <path> : Path to the transcriptome fasta file
|
|
24
|
+
|
|
25
|
+
with this set the calculations will contain the post information in its
|
|
26
|
+
output but will take longest to run
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
Optional Arguments:
|
|
30
|
+
-n, --name <str> : Name of the sample being analysed
|
|
31
|
+
(default: filename of bam file)
|
|
32
|
+
-S, --subsample <int> : Number of reads to subsample from the bam file
|
|
33
|
+
(default: 10000000)
|
|
34
|
+
-T, --transcripts <int> : Number of transcripts to consider
|
|
35
|
+
(default: 100000)
|
|
36
|
+
-c, --config <path> : Path to the config file
|
|
37
|
+
(default: config.yaml)
|
|
38
|
+
|
|
39
|
+
Output:
|
|
40
|
+
--json : Output the results as a json file
|
|
41
|
+
--html : Output the results as an html file (default)
|
|
42
|
+
--pdf : Output the results as a pdf file (default)
|
|
43
|
+
--csv : Output the results as a csv file
|
|
44
|
+
--all : Output the results as all of the above
|
|
45
|
+
"""
|
|
46
|
+
|
|
47
|
+
import argparse
|
|
48
|
+
from rich.console import Console
|
|
49
|
+
from rich.text import Text
|
|
50
|
+
from rich.table import Table
|
|
51
|
+
from rich.emoji import Emoji
|
|
52
|
+
|
|
53
|
+
import yaml
|
|
54
|
+
|
|
55
|
+
from .file_parser import (
|
|
56
|
+
parse_bam,
|
|
57
|
+
parse_fasta,
|
|
58
|
+
parse_annotation,
|
|
59
|
+
prepare_annotation,
|
|
60
|
+
)
|
|
61
|
+
from .qc import annotation_free_mode, annotation_mode, sequence_mode
|
|
62
|
+
from .plots import generate_plots
|
|
63
|
+
from .modules import a_site_calculation
|
|
64
|
+
from .html_report import generate_report
|
|
65
|
+
from .json_output import generate_json
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def print_logo(console):
|
|
69
|
+
"""
|
|
70
|
+
print the logo to the console
|
|
71
|
+
"""
|
|
72
|
+
logo = Text(
|
|
73
|
+
"""
|
|
74
|
+
██████╗ ██╗ ██████╗ ██████╗ ███████╗ ██████╗ ███╗ ███╗███████╗
|
|
75
|
+
██╔══██╗ ██║ ██╔══██╗██╔═══██╗██╔════╝██╔═══██╗████╗ ████║██╔════╝
|
|
76
|
+
██████╔╝ ██║ ██████╔╝██║ ██║███████╗██║ ██║██╔████╔██║█████╗
|
|
77
|
+
██╔══██╗ ██║ ██╔══██╗██║ ██║╚════██║██║ ██║██║╚██╔╝██║██╔══╝
|
|
78
|
+
██║ ██║ ██║ ██████╔╝╚██████╔╝███████║╚██████╔╝██║ ╚═╝ ██║███████╗
|
|
79
|
+
╚═╝ ╚═╝ ╚═╝ ══════╝ ╚═════╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
|
|
80
|
+
""",
|
|
81
|
+
style="bold blue",
|
|
82
|
+
)
|
|
83
|
+
logo += Text(
|
|
84
|
+
"""
|
|
85
|
+
██████╗ ██████╗ ██████╗ ███████╗██╗██╗ ███████╗██████╗
|
|
86
|
+
██╔══██╗ ██╔══██╗██╔═══██╗██╔════╝██║██║ ██╔════╝██╔══██╗
|
|
87
|
+
██████╔╝ ██████╔╝██║ ██║█████╗ ██║██║ █████╗ ██████╔╝
|
|
88
|
+
██╔═══╝ ██╔══██╗██║ ██║██╔══╝ ██║██║ ██╔══╝ ██╔══██╗
|
|
89
|
+
██║ ██║ ██║╚██████╔╝██║ ██║██████╗███████╗██║ ██║
|
|
90
|
+
╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝╚══════╝╚═╝ ╚═╝
|
|
91
|
+
""",
|
|
92
|
+
style="bold red",
|
|
93
|
+
)
|
|
94
|
+
console.print(logo)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def print_table_run(args, console, mode):
|
|
98
|
+
console = Console()
|
|
99
|
+
|
|
100
|
+
Inputs = Table(show_header=True, header_style="bold magenta")
|
|
101
|
+
Inputs.add_column("Parameters", style="dim", width=20)
|
|
102
|
+
Inputs.add_column("Values")
|
|
103
|
+
Inputs.add_row("Bam File:", args.bam)
|
|
104
|
+
Inputs.add_row("Gff File:", args.gff)
|
|
105
|
+
Inputs.add_row("Transcriptome File:", args.fasta)
|
|
106
|
+
|
|
107
|
+
Configs = Table(show_header=True, header_style="bold yellow")
|
|
108
|
+
Configs.add_column("Options", style="dim", width=20)
|
|
109
|
+
Configs.add_column("Values")
|
|
110
|
+
Configs.add_row("Mode:", mode)
|
|
111
|
+
Configs.add_row("# of reads:", str(args.subsample))
|
|
112
|
+
Configs.add_row("# of transcripts:", str(args.transcripts))
|
|
113
|
+
Configs.add_row("Config file:", args.config)
|
|
114
|
+
|
|
115
|
+
Output = Table(show_header=True, header_style="bold blue")
|
|
116
|
+
Output.add_column("Output Options", style="dim", width=20)
|
|
117
|
+
Output.add_column("Values")
|
|
118
|
+
Output.add_row("JSON:", str(args.json))
|
|
119
|
+
Output.add_row("HTML:", str(args.html))
|
|
120
|
+
Output.add_row("PDF:", str(args.pdf))
|
|
121
|
+
Output.add_row("CSV:", str(args.csv))
|
|
122
|
+
Output.add_row("All:", str(args.all))
|
|
123
|
+
|
|
124
|
+
# Print tables side by side
|
|
125
|
+
console.print(Inputs, Configs, Output, justify="inline", style="bold")
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def print_table_prepare(args, console, mode):
|
|
129
|
+
console = Console()
|
|
130
|
+
|
|
131
|
+
Inputs = Table(show_header=True, header_style="bold magenta")
|
|
132
|
+
Inputs.add_column("Parameters", style="dim", width=20)
|
|
133
|
+
Inputs.add_column("Values")
|
|
134
|
+
Inputs.add_row("Gff File:", args.gff)
|
|
135
|
+
|
|
136
|
+
Configs = Table(show_header=True, header_style="bold yellow")
|
|
137
|
+
Configs.add_column("Options", style="dim", width=20)
|
|
138
|
+
Configs.add_column("Values")
|
|
139
|
+
Configs.add_row("Mode:", mode)
|
|
140
|
+
Configs.add_row("# of transcripts:", str(args.transcripts))
|
|
141
|
+
Configs.add_row("Config file:", args.config)
|
|
142
|
+
|
|
143
|
+
# Print tables side by side
|
|
144
|
+
console.print(Inputs, Configs, justify="inline", style="bold")
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def argument_parser():
|
|
148
|
+
"""
|
|
149
|
+
Parse the command line arguments and return the parser object
|
|
150
|
+
|
|
151
|
+
Inputs:
|
|
152
|
+
None
|
|
153
|
+
|
|
154
|
+
Outputs:
|
|
155
|
+
parser: ArgumentParser object containing the parsed arguments
|
|
156
|
+
"""
|
|
157
|
+
parser = argparse.ArgumentParser(
|
|
158
|
+
description="""A python command-line utility for the generation
|
|
159
|
+
of comprehensive reports on the quality of ribosome
|
|
160
|
+
profiling (Ribo-Seq) datasets""",
|
|
161
|
+
epilog=f"""
|
|
162
|
+
|
|
163
|
+
Made with {Emoji('heart')} in LAPTI lab at University College Cork.
|
|
164
|
+
For more information, please visit:
|
|
165
|
+
https://RiboMetric.readthedocs.io/en/latest/
|
|
166
|
+
""",
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
subparsers = parser.add_subparsers(dest="command", title="subcommands")
|
|
170
|
+
|
|
171
|
+
# create the parser for the "run" command
|
|
172
|
+
run_parser = subparsers.add_parser(
|
|
173
|
+
"run", help="run RiboMetric in normal mode"
|
|
174
|
+
)
|
|
175
|
+
run_parser.add_argument(
|
|
176
|
+
"-b", "--bam", type=str, required=True, help="Path to bam file"
|
|
177
|
+
)
|
|
178
|
+
run_parser.add_argument(
|
|
179
|
+
"-a",
|
|
180
|
+
"--annotation",
|
|
181
|
+
type=str,
|
|
182
|
+
required=False,
|
|
183
|
+
help="Path to RiboMetric annotation file",
|
|
184
|
+
)
|
|
185
|
+
run_parser.add_argument(
|
|
186
|
+
"-g", "--gff", type=str, required=False, help="Path to gff file"
|
|
187
|
+
)
|
|
188
|
+
run_parser.add_argument(
|
|
189
|
+
"-f",
|
|
190
|
+
"--fasta",
|
|
191
|
+
type=str,
|
|
192
|
+
required=False,
|
|
193
|
+
help="Path to the transcriptome fasta file",
|
|
194
|
+
)
|
|
195
|
+
run_parser.add_argument(
|
|
196
|
+
"-n",
|
|
197
|
+
"--name",
|
|
198
|
+
type=str,
|
|
199
|
+
required=False,
|
|
200
|
+
help="""Name of the sample being analysed
|
|
201
|
+
(default: filename of bam file)""",
|
|
202
|
+
)
|
|
203
|
+
run_parser.add_argument(
|
|
204
|
+
"-o",
|
|
205
|
+
"--output",
|
|
206
|
+
type=str,
|
|
207
|
+
required=False,
|
|
208
|
+
default=".",
|
|
209
|
+
help="""Path to the output directory
|
|
210
|
+
(default: current directory)""",
|
|
211
|
+
)
|
|
212
|
+
run_parser.add_argument(
|
|
213
|
+
"-S",
|
|
214
|
+
"--subsample",
|
|
215
|
+
type=int,
|
|
216
|
+
required=False,
|
|
217
|
+
default=1000000,
|
|
218
|
+
help="""Number of reads to subsample from the bam file
|
|
219
|
+
(default: 10000000)""",
|
|
220
|
+
)
|
|
221
|
+
run_parser.add_argument(
|
|
222
|
+
"-T",
|
|
223
|
+
"--transcripts",
|
|
224
|
+
type=int,
|
|
225
|
+
required=False,
|
|
226
|
+
default=100000,
|
|
227
|
+
help="Number of transcripts to consider (default: 100000)",
|
|
228
|
+
)
|
|
229
|
+
run_parser.add_argument(
|
|
230
|
+
"-c",
|
|
231
|
+
"--config",
|
|
232
|
+
type=str,
|
|
233
|
+
required=False,
|
|
234
|
+
default="config.yml",
|
|
235
|
+
help="Path to the config file (default: config.yml)",
|
|
236
|
+
)
|
|
237
|
+
run_parser.add_argument(
|
|
238
|
+
"--json",
|
|
239
|
+
action="store_true",
|
|
240
|
+
default=False,
|
|
241
|
+
help="Output the results as a json file",
|
|
242
|
+
)
|
|
243
|
+
run_parser.add_argument(
|
|
244
|
+
"--html",
|
|
245
|
+
action="store_true",
|
|
246
|
+
default=True,
|
|
247
|
+
help="Output the results as an html file (default)",
|
|
248
|
+
)
|
|
249
|
+
run_parser.add_argument(
|
|
250
|
+
"--pdf",
|
|
251
|
+
action="store_true",
|
|
252
|
+
default=False,
|
|
253
|
+
help="Output the results as a pdf file (default)",
|
|
254
|
+
)
|
|
255
|
+
run_parser.add_argument(
|
|
256
|
+
"--csv",
|
|
257
|
+
action="store_true",
|
|
258
|
+
default=False,
|
|
259
|
+
help="Output the results as a csv file",
|
|
260
|
+
)
|
|
261
|
+
run_parser.add_argument(
|
|
262
|
+
"--all",
|
|
263
|
+
action="store_true",
|
|
264
|
+
default=False,
|
|
265
|
+
help="Output the results as all of the above",
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
# create the parser for the "prepare" command
|
|
269
|
+
prepare_parser = subparsers.add_parser(
|
|
270
|
+
"prepare", help="run RiboMetric in preparation mode"
|
|
271
|
+
)
|
|
272
|
+
prepare_parser.add_argument(
|
|
273
|
+
"-g", "--gff", type=str, required=True, help="Path to gff file"
|
|
274
|
+
)
|
|
275
|
+
prepare_parser.add_argument(
|
|
276
|
+
"-T",
|
|
277
|
+
"--transcripts",
|
|
278
|
+
type=int,
|
|
279
|
+
required=False,
|
|
280
|
+
default=10000000000,
|
|
281
|
+
help="Number of transcripts to consider (default: 100000)",
|
|
282
|
+
)
|
|
283
|
+
prepare_parser.add_argument(
|
|
284
|
+
"-o",
|
|
285
|
+
"--output",
|
|
286
|
+
type=str,
|
|
287
|
+
required=False,
|
|
288
|
+
default=".",
|
|
289
|
+
help="""Path to the output directory
|
|
290
|
+
(default: current directory)""",
|
|
291
|
+
)
|
|
292
|
+
prepare_parser.add_argument(
|
|
293
|
+
"-c",
|
|
294
|
+
"--config",
|
|
295
|
+
type=str,
|
|
296
|
+
required=False,
|
|
297
|
+
default="config.yml",
|
|
298
|
+
help="Path to the config file (default: config.yml)",
|
|
299
|
+
)
|
|
300
|
+
return parser
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
def main(args):
|
|
304
|
+
"""
|
|
305
|
+
Main function for the RiboMetric command line interface
|
|
306
|
+
|
|
307
|
+
Inputs:
|
|
308
|
+
args: Namespace object containing the parsed arguments
|
|
309
|
+
|
|
310
|
+
Outputs:
|
|
311
|
+
None
|
|
312
|
+
"""
|
|
313
|
+
console = Console()
|
|
314
|
+
print_logo(console)
|
|
315
|
+
|
|
316
|
+
with open(args.config, "r") as ymlfile:
|
|
317
|
+
config = yaml.load(ymlfile, Loader=yaml.Loader)
|
|
318
|
+
|
|
319
|
+
if args.command == "prepare":
|
|
320
|
+
print_table_prepare(args, console, "Prepare Mode")
|
|
321
|
+
prepare_annotation(args.gff, args.output, args.transcripts, config)
|
|
322
|
+
|
|
323
|
+
else:
|
|
324
|
+
if args.all:
|
|
325
|
+
args.json = True
|
|
326
|
+
args.html = True
|
|
327
|
+
args.pdf = True
|
|
328
|
+
args.csv = True
|
|
329
|
+
print_table_run(args, console, "Run Mode")
|
|
330
|
+
|
|
331
|
+
if args.html:
|
|
332
|
+
if args.pdf:
|
|
333
|
+
report_export = "both"
|
|
334
|
+
else:
|
|
335
|
+
report_export = "html"
|
|
336
|
+
elif args.pdf:
|
|
337
|
+
report_export = "pdf"
|
|
338
|
+
|
|
339
|
+
read_df_pre = parse_bam(args.bam, args.subsample)
|
|
340
|
+
print("Reads parsed")
|
|
341
|
+
|
|
342
|
+
# Expand the dataframe to have one row per read
|
|
343
|
+
print("Expanding dataframe")
|
|
344
|
+
read_df = read_df_pre.loc[
|
|
345
|
+
read_df_pre.index.repeat(read_df_pre["count"])
|
|
346
|
+
].reset_index(drop=True)
|
|
347
|
+
print("Dataframe expanded")
|
|
348
|
+
print("Calculating A site information")
|
|
349
|
+
read_df = a_site_calculation(read_df)
|
|
350
|
+
|
|
351
|
+
if args.gff is None and args.annotation is None:
|
|
352
|
+
results_dict = annotation_free_mode(read_df, config)
|
|
353
|
+
|
|
354
|
+
else:
|
|
355
|
+
if args.annotation is not None and args.gff is not None:
|
|
356
|
+
print("Both annotation and gff provided, using annotation")
|
|
357
|
+
annotation_df = parse_annotation(args.annotation)
|
|
358
|
+
elif args.annotation is None and args.gff is not None:
|
|
359
|
+
print("Gff provided, preparing annotation")
|
|
360
|
+
annotation_df = prepare_annotation(
|
|
361
|
+
args.gff, args.output, args.transcripts, config
|
|
362
|
+
)
|
|
363
|
+
print("Annotation prepared")
|
|
364
|
+
elif args.annotation is not None and args.gff is None:
|
|
365
|
+
print("Annotation provided, parsing")
|
|
366
|
+
annotation_df = parse_annotation(args.annotation)
|
|
367
|
+
print("Annotation parsed")
|
|
368
|
+
|
|
369
|
+
print("Running annotation mode")
|
|
370
|
+
results_dict = annotation_mode(read_df, annotation_df, config)
|
|
371
|
+
|
|
372
|
+
if args.fasta is not None:
|
|
373
|
+
fasta_dict = parse_fasta(args.fasta)
|
|
374
|
+
|
|
375
|
+
results_dict = sequence_mode(results_dict, read_df, fasta_dict, config)
|
|
376
|
+
if args.html or args.pdf:
|
|
377
|
+
plots_list = generate_plots(results_dict, config)
|
|
378
|
+
generate_report(plots_list, config, report_export)
|
|
379
|
+
if args.json:
|
|
380
|
+
generate_json(results_dict, config)
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
if __name__ == "__main__":
|
|
384
|
+
parser = argument_parser()
|
|
385
|
+
args = parser.parse_args()
|
|
386
|
+
|
|
387
|
+
main(args)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"""Console script for RiboMetric."""
|
|
2
|
+
import sys
|
|
3
|
+
|
|
4
|
+
from .RiboMetric import argument_parser as p, main as m
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def main():
|
|
8
|
+
"""Console script for RiboMetric."""
|
|
9
|
+
parser = p()
|
|
10
|
+
args = parser.parse_args()
|
|
11
|
+
|
|
12
|
+
m(args)
|
|
13
|
+
return 0
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
if __name__ == "__main__":
|
|
17
|
+
sys.exit(main()) # pragma: no cover
|