Skip to content

Commit

Permalink
updated cmd line options to make postional args, remove underscores, …
Browse files Browse the repository at this point in the history
…changed docs to reflect the change
  • Loading branch information
nilesh-tawari committed Sep 11, 2017
1 parent c871d7c commit 211708d
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 64 deletions.
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include LICENSE
include chronqc/templates/*.txt
include chronqc/templates/*.html
include tox.ini
include chronqc/config/*
include chronqc/config/chronqc.conf
include versioneer.py
include chronqc/_version.py
include chronqc/db/*
Expand Down
74 changes: 36 additions & 38 deletions chronqc/chronqc.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __call__(self, parser, namespace, values, option_string=None):

# @click.command()
def main():
try:
try:
parser = argparse.ArgumentParser(prog='chronqc')
subparsers = parser.add_subparsers() # , annotation')
# Parse database arguments
Expand All @@ -56,55 +56,45 @@ def main():
db_requiredNamed = db_parser.add_argument_group('available arguments')
group = db_requiredNamed.add_mutually_exclusive_group()
# group.set_defaults(mode='create')
db_requiredNamed.add_argument('-db', '--db',
db_requiredNamed.add_argument('--db',
help='Name of ChronQC database to be created \
(default name is chronqc.stats.sqlite) or \
full path of ChronQC database to be updated.')
group.add_argument('-u', '--update', action='store_const', dest='mode',
const='update', help="Update the ChronQC database \
provided by {-db} argument.")
provided by {--db} argument.")
group.add_argument('-c', '--create', action='store_const', dest='mode',
const='create', help="Create the ChronQC database \
provided by {-db} argument.")
db_requiredNamed.add_argument('-db_table', '--db_table', required=False, action=Highlander,
provided by {--db} argument.")
db_requiredNamed.add_argument('--db-table', required=False, action=Highlander,
help='Name of ChronQC SQLlite database table \
to be created/updated. Default name is \
chronqc_stats_data. ')
db_requiredNamed.add_argument('-panel', '--panel', required=True, action=Highlander,
help='Name of the panel (assay or project). \
This allows storing statistical data for \
multiple assays in same ChronQC database \
and comparison of data with historical \
data in the same assay. ')
db_requiredNamed.add_argument('-multiqc_stats', '--multiqc_stats',
required=True, action=Highlander,
help='Input multiqc_general_stats.txt file \
generated by MultiQC')
action = db_requiredNamed.add_mutually_exclusive_group(required=True)
action.add_argument('-run_date_info', '--run_date_info', action=Highlander,
action = db_requiredNamed.add_mutually_exclusive_group(required=False)
action.add_argument('--run-date-info', action=Highlander,
help='Run ID and sequencing date information for \
all samples in csv format. File should have three \
columns (Sample, Run, Date).If run_date_info is \
provided {multiqc_sources, module, run_dir_level} \
columns (Sample, Run, Date).If run-date-info is \
provided {multiqc-sources, module, run-dir-level} \
arguments are not required.')
action.add_argument('-multiqc_sources', '--multiqc_sources', action=Highlander,
action.add_argument('--multiqc-sources', action=Highlander,
help='Input multiqc_sources.txt file generated by \
MultiQC. If run_date_info is not provided. \
MultiQC. If run-date-info is not provided. \
Run ID and Sequencing date information is \
generated using this file along with \
{module, run_dir_level} information.')
db_requiredNamed.add_argument('-module', '--module', required=False,
{module, run-dir-level} information.')
db_requiredNamed.add_argument('--module', required=False,
default='FastQC', action=Highlander,
help='Default module is FastQC. \
Name of module from multiqc_sources.txt \
file. Time stamp from the output files of this \
module will be used to get the Sequencing \
date. If output files are not found then time \
stamp of multiqc_sources file is used instead. \
stamp of multiqc-sources file is used instead. \
Path of output files of this module \
and run_dir_level (default = 3) is used to \
and run-dir-level (default = 3) is used to \
get Run ID.')
db_requiredNamed.add_argument('-run_dir_level', '--run_dir_level',
db_requiredNamed.add_argument('--run-dir-level',
required=False, default=3, action=Highlander,
help='Upper directory level for path in \
multiqc_sources.txt file. This will be \
Expand All @@ -117,30 +107,38 @@ def main():
db_parser.add_argument('-f', '--force', required=False,
action='store_true', help='Overwrite the \
output in chronqc_db directory. ')
db_requiredNamed.add_argument('mstats', # required=True
action=Highlander,
help='Input multiqc_general_stats.txt file \
generated by MultiQC')
db_requiredNamed.add_argument('panel', action=Highlander, #required=True,
help='Name of the panel (assay or project). \
This allows storing statistical data for \
multiple assays in same ChronQC database \
and comparison of data with historical \
data in the same assay. ')
db_parser.set_defaults(func=run_db)
# Parse plot arguments
plot_parser = subparsers.add_parser('plot',
help='Generate ChronQC plots. \
Type "chronqc plot -h" for \
help on generating ChronQC plots.')
plot_requiredNamed = plot_parser.add_argument_group('mandatory arguments')
plot_requiredNamed.add_argument('-db', '--db', required=True, action=Highlander,
help='Input SQLite database name.')

plot_requiredNamed.add_argument('-json', '--json', required=True, action=Highlander,
help='Input JSON filename with plot \
properties.')
plot_requiredNamed.add_argument('-panel', '--panel', required=True, action=Highlander,
help='Name of the panel (assay). This enables \
comparison of historical data \
in the same assay.')
plot_parser.add_argument('-p', '--prefix', required=False, action=Highlander,
help='Prefix for ChronQC output html file.')
plot_parser.add_argument('-o', '--output', required=False, action=Highlander,
help='Directory path to save ChronQC output')
plot_parser.add_argument('-f', '--force', required=False,
action='store_true', help='Overwrite the \
output in chronqc_output directory.')
plot_parser.add_argument('db', action=Highlander, #required=True,
help='Input SQLite database name.')
plot_parser.add_argument('panel', action=Highlander, # required=True,
help='Name of the panel (assay). This enables \
comparison of historical data \
in the same assay.')
plot_parser.add_argument('json', action=Highlander, #required=True,
help='Input JSON filename with plot \
properties.')
plot_parser.set_defaults(func=run_plot)

annotate_parser = subparsers.add_parser('annotation', help='Start connectivity for annotating plots. ' \
Expand All @@ -152,7 +150,7 @@ def main():

args = parser.parse_args()
args.func(args)
except AttributeError:
except AttributeError:
parser.print_help()
sys.exit(0)

Expand Down
7 changes: 4 additions & 3 deletions chronqc/chronqc_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def main(args):
# output dir and file
# Get output directory 1. user defined 2. db dir 3. multiqc_stats dir
# Get output file name prefix and out file name
multiqc_stats = op.abspath(args.multiqc_stats)
multiqc_stats = op.abspath(args.mstats)
if args.db is not None:
output_directory, output_prefix = utils.path_leaf(args.db)
out_file = op.abspath(args.db)
Expand Down Expand Up @@ -170,8 +170,9 @@ def main(args):
utils.print_progress(3, 4, prefix='Running ChronQC', decimals=1, bar_length=50)

# Read config and get default parameters
sdir = op.dirname(op.abspath('__file__'))
config_file = op.join(sdir, 'config', 'chronqc.conf')
#sdir = op.dirname(op.abspath('__file__'))
sdir = op.abspath(op.join(op.dirname(__file__), 'config'))
config_file = op.join(sdir, 'chronqc.conf')
Config.read(config_file)
# [ignore_columns]
ignore_columns = Config.get('ignore_columns', 'columns').split(',')
Expand Down
23 changes: 12 additions & 11 deletions docs/run_chronqc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ This example demonstrates generating ChronQC plots from a custom database::

Run following command to generate interactive plots in html::
chronqc plot -db chronqc_custom_db.sqlite -json config.json -panel Somatic
chronqc plot chronqc_custom_db.sqlite Somatic config.json

The types of created plots and their properties are specified in "config.json" file. For details on creating the config file visit `documentation. <http://chronqc.readthedocs.io/en/latest/plots/plot_options.html>`__
Interactive html report is created under ``chronqc_output`` directory


**2. The output of MultiQC.**

*For creating ChronQC database and plots, see the example below*
*2.1 For creating ChronQC database and plots, see the example below*

This example demonstrates generating a ChronQC database and creating ChronQC graphs using the database::
cd examples/multiqc_example_1
Step 1: Create a ChronQC database::
chronqc database --create -multiqc_stats multiqc_data/multiqc_general_stats.txt -run_date_info run_date_info.csv -panel SOMATIC -o
chronqc database --create --run-date-info run_date_info.csv -o . multiqc_data/multiqc_general_stats.txt SOMATIC

A sqlite database ``chronqc.stats.sqlite`` and ``chronqc.stats.cols.txt`` file are created in ``chronqc_db`` folder under the ``.`` (current) directory.

Expand All @@ -40,42 +41,42 @@ Step 2: Create ChronQC plots::
The types of created plots and their properties are specified in JSON file.
Plots can be generated using the default ``chronqc.default.json`` file,

chronqc plot -db chronqc_db/chronqc.stats.sqlite -json chronqc_db/chronqc.default.json -panel SOMATIC -o .
chronqc plot -o . chronqc_db/chronqc.stats.sqlite SOMATIC chronqc_db/chronqc.default.json

Interactive html report is created in ``chronqc_output`` under the ``.`` (current) directory.

*Customizing the JSON*

It is strongly adviced to create custom JSON file, based on the laboratories assay tracking strategy. A sample of custom JSON is included in the folder. `chronqc.stats.cols.txt` file contains column names present in the database, and can be used to create the config file. For details on creating the config file visit `documentation. <http://chronqc.readthedocs.io/en/latest/plots/plot_options.html>`__

chronqc plot -db chronqc_db/chronqc.stats.sqlite -json sample.json -panel SOMATIC -o .
chronqc plot -o . chronqc_db/chronqc.stats.sqlite SOMATIC sample.json

Interactive html report is created in ``chronqc_output`` under the ``.`` (current) directory.


*For creating, updating ChronQC database and plots, see the example below*
*2.2 For creating, updating ChronQC database and plots, see the example below*

This example demonstrates generating a ChronQC database, updating the generated database with new data and creating ChronQC graphs using the database::

cd examples/multiqc_example_2

Step 1: Create a ChronQC database::

chronqc database --create -multiqc_stats year_2016/multiqc_data/multiqc_general_stats.txt -run_date_info year_2016/run_date_info.csv -panel Germline -o .
chronqc database --create --run-date-info year_2016/run_date_info.csv -o . year_2016/multiqc_data/multiqc_general_stats.txt Germline

A sqlite database ``chronqc.stats.sqlite`` and `chronqc.stats.cols.txt` file are created in ``chronqc_db`` folder under the ``.`` (current) directory.
A default JSON file named ``chronqc.default.json`` is also created in chronqc_db under the ``.`` (current) directory.

Step 2: Update existing ChronQC database::

chronqc database --update -db chronqc_db/chronqc.stats.sqlite -multiqc_stats year_2017/multiqc_data/multiqc_general_stats.txt -run_date_info year_2017/run_date_info.csv -panel Germline
chronqc database --update --db chronqc_db/chronqc.stats.sqlite --run-date-info year_2017/run_date_info.csv year_2017/multiqc_data/multiqc_general_stats.txt Germline

Step 3: Create ChronQC plots::

The types of created plots and their properties are specified in JSON file.
Plots can be generated using the default ``chronqc.default.json`` file,

chronqc plot -db chronqc_db/chronqc.stats.sqlite -json chronqc_db/chronqc.default.json -panel Germline -o .
chronqc plot -o . chronqc_db/chronqc.stats.sqlite Germline chronqc_db/chronqc.default.json

Interactive html report is created in ``chronqc_output`` under the ``.`` (current) directory.

Expand All @@ -84,7 +85,7 @@ Interactive html report is created in ``chronqc_output`` under the ``.`` (curren
It is strongly adviced to create custom JSON file, based on the laboratories assay tracking strategy. A sample of custom JSON is included in the folder. `chronqc.stats.cols.txt` file contains column names present in the database, and can be used to create the config file. For details on creating the config file visit `documentation. <http://chronqc.readthedocs.io/en/latest/plots/plot_options.html>`__


chronqc plot -db chronqc_db/chronqc.stats.sqlite -json sample.json -panel Germline -o .
chronqc plot -o . chronqc_db/chronqc.stats.sqlite Germline sample.json

Interactive html report is created in ``chronqc_output`` under the ``.`` (current) directory.

Expand All @@ -94,7 +95,7 @@ Using ChronQC plots
ChronQC is designed to be interactive. ChronQC plots can be adjusted to a time period and are zoomable. Mousing over a point displays its associated data such as run ID, sample IDs, and corresponding values.
To use the annotation feature of ChronQC plots, start the annotation database connectivity by using `chronqc annotation` command. Default port used for annotation server is 8000, this can be customized by using --port option.
Then open the ChronQC output html in a recent browser (tested on: Google Chrome and Mozilla Firefox).
Users can record notes and corrective actions on the plots by clicking on a point or selecting a date. User notes and corrective actions are stored for long-term recordkeeping in the SQLite ChronQC annotations database. The plots are interlinked so that when an individual point or date is annotated in one graph, the same annotation appears on other graphs. By linking plots with the ChronQC annotations database, users can see the notes and corrective actions recorded previously.
Users can record notes and corrective actions on the plots by clicking on a point or selecting a date. User notes and corrective actions are stored for long-term recordkeeping in the SQLite ChronQC annotations database. The plots are interlinked so that when an individual point or date is annotated in one graph, the same annotation appears on other graphs. By using the ChronQC report with the ChronQC annotations data-base (by starting the annotation server with "chronqc annotation" command), users can see the notes that have been recorded previously.

ChronQC config files
````````````````````
Expand Down
4 changes: 2 additions & 2 deletions examples/custom_db_example/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This example demonstrates generating ChronQC plots from a custom database.

Run following command to generate interactive plots in html

`chronqc plot -db chronqc_custom_db.sqlite -json config.json -panel Somatic`
`chronqc plot chronqc_custom_db.sqlite Somatic config.json`

The types of created plots and their properties are specified in "config.json" file. For details on creating the config file visit [documentation](https://chronqc.readthedocs.io/en/latest/plots/plot_options.html).
Interactive html report is created under `chronqc_output`.
Expand All @@ -16,4 +16,4 @@ Interactive html report is created under `chronqc_output`.
ChronQC is designed to be interactive. ChronQC plots can be adjusted to a time period and are zoomable. Mousing over a point displays its associated data such as run ID, sample IDs, and corresponding values.
To use the annotation feature of ChronQC plots, start the annotation database connectivity by using `chronqc annotation` command. Default port used for annotation server is 8000, this can be customized by using --port option.
Then open the ChronQC output html in a recent browser (tested on: Google Chrome and Mozilla Firefox).
Users can record notes and corrective actions on the plots by clicking on a point or selecting a date. User notes and corrective actions are stored for long-term recordkeeping in the SQLite ChronQC annotations database. The plots are interlinked so that when an individual point or date is annotated in one graph, the same annotation appears on other graphs. By linking plots with the ChronQC annotations database, users can see the notes and corrective actions recorded previously.
Users can record notes and corrective actions on the plots by clicking on a point or selecting a date. User notes and corrective actions are stored for long-term recordkeeping in the SQLite ChronQC annotations database. The plots are interlinked so that when an individual point or date is annotated in one graph, the same annotation appears on other graphs. By using the ChronQC report with the ChronQC annotations data-base (by starting the annotation server with "chronqc annotation" command), users can see the notes that have been recorded previously.

0 comments on commit 211708d

Please sign in to comment.