Skip to content

Commit

Permalink
feat: new run and download command
Browse files Browse the repository at this point in the history
The application now supports two main functions:
- `run` for generating the report
- `download` for downloading all supported databases
  • Loading branch information
matq007 committed Mar 26, 2019
1 parent 13697df commit 4e00d81
Show file tree
Hide file tree
Showing 9 changed files with 260 additions and 30 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include LICENSE
include README.md
include docs/_src/_static/fusion-report.png
include requirements.txt
recursive-include fusion_report *
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@ This python script generates an interactive summary report from fusion detection

## Installation

### From source

```bash
sudo apt-get install sqlite3 wget
python3 setup.py install
```

## Usage

```bash
fusion_report "<SAMPLE NAME>" /path/to/output /path/to/db/
# Download required databases
# Currently supported databases: FusionGDB, Mitelman and COSMIC
# COSMIC requires login credentials to download Fusion gene Database
fusion_report download --cosmic_usr '<username>' --cosmic_passwd '<password>' /path/to/db/

# Run the fusion-report
fusion_report run "<SAMPLE NAME>" /path/to/output /path/to/db/
--ericscript tests/test_data/ericscript.tsv
--starfusion tests/test_data/starfusion.tsv
--fusioncatcher tests/test_data/fusioncatcher.txt
Expand All @@ -37,6 +46,8 @@ Or get help and list all possible parameters.

```bash
fusion_report --help
fusion_report run --help
fusion_report download --help
```

For more info on how to run the script, please see the [documentation](https://matq007.github.io/fusion-report/).
Expand Down
87 changes: 68 additions & 19 deletions bin/fusion_report
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ from fusion_report.lib.report import Report
from fusion_report.lib.section import Section
from fusion_report.lib.graph import Graph
from fusion_report.lib.tool_parser import ToolParser
from fusion_report.lib.download import Download
from fusion_report.core import tool_detection_chart, known_vs_unknown_chart, \
distribution_chart, create_fusions_table, create_ppi_graph, print_progress_bar, \
get_db_fusions, score_fusion, create_multiqc_section, create_fusion_list
Expand All @@ -30,6 +31,11 @@ def parse(params):

return tools

def download(params):
""" Function for downloading all databases. """
manager = Download(params)
manager.get_all_databases()

def generate_index(params, parser):
"""
Helper function for generating index.html page.
Expand Down Expand Up @@ -274,92 +280,135 @@ def main():
Supported tools are: {0} and {1}.
'''.format(', '.join(SUPPORTED_TOOLS[:-1]), SUPPORTED_TOOLS[-1])
)
mandatory = parser.add_argument_group('Mandatory arguments', 'Required arguments to run app.')
mandatory.add_argument(
# fusion_parser run
subparsers = parser.add_subparsers(dest='command')
run_parser = subparsers.add_parser('run', help='Run application')
run_mandatory = run_parser.add_argument_group(
'Mandatory arguments', 'Required arguments to run app.'
)
run_mandatory.add_argument(
'sample',
help='Sample name',
type=str
)
mandatory.add_argument(
run_mandatory.add_argument(
'output',
help='Output directory',
type=str
)
mandatory.add_argument(
run_mandatory.add_argument(
'db_path',
help='Path to folder where all databases are stored.',
type=str
)
tools = parser.add_argument_group('Tools', 'List of all supported tools with their weights.')
tools.add_argument(
run_tools = run_parser.add_argument_group(
'Tools', 'List of all supported tools with their weights.'
)
run_tools.add_argument(
'--ericscript',
help='EricScript output file',
type=str
)
tools.add_argument(
run_tools.add_argument(
'--ericscript_weight',
help='EricScript weight',
type=float,
default=DEFAULT_TOOL_WEIGHT
)
tools.add_argument(
run_tools.add_argument(
'--fusioncatcher',
help='FusionCatcher output file',
type=str
)
tools.add_argument(
run_tools.add_argument(
'--fusioncatcher_weight',
help='FusionCatcher weight',
type=float,
default=DEFAULT_TOOL_WEIGHT
)
tools.add_argument(
run_tools.add_argument(
'--starfusion',
help='STAR-Fusion output file',
type=str
)
tools.add_argument(
run_tools.add_argument(
'--starfusion_weight',
help='STAR-Fusion weight',
type=float,
default=DEFAULT_TOOL_WEIGHT
)
tools.add_argument(
run_tools.add_argument(
'--pizzly',
help='Pizzly output file',
type=str
)
tools.add_argument(
run_tools.add_argument(
'--pizzly_weight',
help='Pizzly weight',
type=float,
default=DEFAULT_TOOL_WEIGHT
)
tools.add_argument(
run_tools.add_argument(
'--squid',
help='Squid output file',
type=str
)
tools.add_argument(
run_tools.add_argument(
'--squid_weight',
help='Squid weight',
type=float,
default=DEFAULT_TOOL_WEIGHT
)
optional = parser.add_argument_group('Optional', 'List of additional configuration parameters.')
optional.add_argument(
run_optional = run_parser.add_argument_group(
'Optional', 'List of additional configuration parameters.'
)
run_optional.add_argument(
'-c', '--config',
help='Input config file',
type=str,
required=False
)
optional.add_argument(
run_optional.add_argument(
'-t', '--tool_cutoff',
help='Number of tools required to detect a fusion',
type=int,
default=TOOL_DETECTION_CUTOFF
)
generate_report(parser.parse_args())
# fusion_parser download
download_parser = subparsers.add_parser('download', help='Download required databases')
download_parser.add_argument(
'output',
help='Output directory',
type=str
)
mandatory_download = download_parser.add_argument_group(
'COSMIC', '''Option credential parameters. You can either provide username and password
which will be used to generate base64 token or the token itself.'''
)
mandatory_download.add_argument(
'--cosmic_usr',
help='COSMIC username',
type=str
)
mandatory_download.add_argument(
'--cosmic_passwd',
help='COSMIC password',
type=str
)
mandatory_download.add_argument(
'--cosmic_token',
help='COSMIC token',
type=str
)

# Handle individual commands
params = parser.parse_args()
if params.command == 'run':
generate_report(params)
elif params.command == 'download':
download(params)
else:
exit(f'Command {params.command} not recognized!')

if __name__ == "__main__":
main()
12 changes: 12 additions & 0 deletions docs/_src/download_db.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ Currently the tool supports three different databases:
- Mitelman
- COSMIC

You can download the databases running:

.. code-block:: bash
fusion_report download
--cosmic_usr '<username>'
--cosmic_passwd '<password>'
/path/to/db
Manual download
***************

FusionGDB
---------

Expand Down
1 change: 1 addition & 0 deletions docs/_src/lib.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Lib
.. toctree::

lib/db
lib/download
lib/fusion_detail
lib/graph
lib/master_page
Expand Down
5 changes: 5 additions & 0 deletions docs/_src/lib/download.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Download
===================

.. autoclass:: fusion_report.lib.download.Download
:members:
8 changes: 5 additions & 3 deletions docs/_src/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Run all fusion detection tools

.. code-block:: bash
fusion_report "<SAMPLE NAME>" /path/to/output /path/to/db/
fusion_report run "<SAMPLE NAME>" /path/to/output /path/to/db/
--ericscript tests/test_data/ericscript.tsv
--starfusion tests/test_data/starfusion.tsv
--fusioncatcher tests/test_data/fusioncatcher.txt
Expand All @@ -23,7 +23,7 @@ equal `100 / (number of tools)`.

.. code-block:: bash
fusion_report "<SAMPLE NAME>" /path/to/output /path/to/db/
fusion_report run "<SAMPLE NAME>" /path/to/output /path/to/db/
--ericscript tests/test_data/ericscript.tsv
--ericscript_weight 30.5
--fusioncatcher tests/test_data/fusioncatcher.txt
Expand All @@ -34,4 +34,6 @@ All parameters and options

.. code-block:: bash
fusion_report --help
fusion_report --help
fusion_report run --help
fusion_report download --help
Loading

0 comments on commit 4e00d81

Please sign in to comment.