From 70d3ac7f18254f5289126f7f6537e425a05665d6 Mon Sep 17 00:00:00 2001
From: Redmar van den Berg <RedmarvandenBerg@lumc.nl>
Date: Thu, 8 Aug 2019 08:59:59 +0200
Subject: [PATCH] Write stats to stdout by default

This is also the default behaviour in master. This change restores
the default behaviour, while still preserving the option to write
the stats json directly to a file by specifying --stats.
---
 README.md     | 6 +++---
 vtools/cli.py | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 947346e..a998cd6 100644
--- a/README.md
+++ b/README.md
@@ -154,10 +154,10 @@ Options:
                                 called multiple times  [required]
   -ps, --positive-samples TEXT  Sample(s) in positive-vcf to consider. May be
                                 called multiple times  [required]
-  -s, --stats PATH              Path to output stats json file  [required]
+  -s, --stats PATH              Path to output stats json file
   -dc, --discordant PATH        Path to output discordant VCF file
-  --help                        Show this message and exit
-  ```
+  --help                        Show this message and exit.
+```
 
 ## License
 
diff --git a/vtools/cli.py b/vtools/cli.py
index 30cd698..77d54a7 100644
--- a/vtools/cli.py
+++ b/vtools/cli.py
@@ -32,7 +32,7 @@ from .gcoverage import RefRecord, region_coverages
                    "May be called multiple times",
               required=True)
 @click.option("-s", "--stats", type=click.Path(writable=True),
-              help="Path to output stats json file", required=True)
+              help="Path to output stats json file", default='-')
 @click.option("-dc", "--discordant", type=click.Path(writable=True),
               help="Path to output discordant VCF file",
               required=False)
@@ -43,12 +43,12 @@ def evaluate_cli(call_vcf, positive_vcf, call_samples, positive_samples, stats,
     st, disc = site_concordancy(c_vcf, p_vcf, call_samples,
                                 positive_samples)
     # Write the stats json file
-    with open(stats, 'w') as fout:
+    with click.open_file(stats, 'w') as fout:
         print(json.dumps(st), file=fout)
 
     # If specified, write the discordant variants
     if discordant:
-        with open(discordant, 'w') as fout:
+        with click.open_file(discordant, 'w') as fout:
             for record in disc:
                 print(record, file=fout, end='')
 
-- 
GitLab