From 4ef71d0ecde4409f8045ad282d89d2a7f5cc3897 Mon Sep 17 00:00:00 2001
From: Sander Bollen <a.h.b.bollen@lumc.nl>
Date: Tue, 8 May 2018 10:39:04 +0200
Subject: [PATCH] add cli for evaluation

---
 setup.py      |  3 ++-
 vtools/cli.py | 34 +++++++++++++++++++++++++++++-----
 2 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/setup.py b/setup.py
index d556554..4a4ec13 100644
--- a/setup.py
+++ b/setup.py
@@ -39,7 +39,8 @@ setup(
         "console_scripts": [
             "vtools-filter = vtools.cli:filter_cli",
             "vtools-stats = vtools.cli:stats_cli",
-            "vtools-gcoverage = vtools.cli:gcoverage_cli"
+            "vtools-gcoverage = vtools.cli:gcoverage_cli",
+            "vtools-evaluate = vtools.cli:evaluate_cli"
         ]
     },
     classifiers=[
diff --git a/vtools/cli.py b/vtools/cli.py
index ac28c59..1f3dd49 100644
--- a/vtools/cli.py
+++ b/vtools/cli.py
@@ -6,12 +6,36 @@ vtools.cli
 :copyright: (c) Leiden University Medical Center
 :license: MIT
 """
-
+import json
 import click
+from cyvcf2 import VCF, Writer
+
+from .evaluate import site_concordancy
+from .filter import FilterParams, FilterClass, Filterer
+from .stats import Stats
+from .gcoverage import RefRecord, region_coverages
 
-from .filter import *
-from .stats import *
-from .gcoverage import *
+
+@click.command()
+@click.option("-c", "--call-vcf", type=click.Path(exists=True),
+              help="Path to VCF with calls to be evaluated",
+              required=True)
+@click.option("-p", "--positive-vcf", type=click.Path(exists=True),
+              help="Path to VCF with known calls",
+              required=True)
+@click.option("-cs", "--call-samples", type=click.STRING, multiple=True,
+              help="Sample(s) in call-vcf to consider. "
+                   "May be called multiple times",
+              required=True)
+@click.option("-ps", "--positive-samples", type=click.STRING, multiple=True,
+              help="Sample(s) in positive-vcf to consider. "
+                   "May be called multiple times",
+              required=True)
+def evaluate_cli(call_vcf, positive_vcf, call_samples, positive_samples):
+    c_vcf = VCF(call_vcf, gts012=True)
+    p_vcf = VCF(positive_vcf, gts012=True)
+    evaluated = site_concordancy(c_vcf, p_vcf, call_samples, positive_samples)
+    print(json.dumps(evaluated))
 
 
 @click.command()
@@ -80,7 +104,7 @@ def stats_cli(input):
               default=True,
               help="Collect metrics per exon or per transcript")
 def gcoverage_cli(input_gvcf, refflat_file, per_exon):
-    reader = cyvcf2.VCF(input_gvcf)
+    reader = VCF(input_gvcf)
     header = None
     with open(refflat_file) as handle:
         for line in handle:
-- 
GitLab