Commit 232151a2 authored by rrvandenberg's avatar rrvandenberg

Add minimal logging to vtools

parent ec9bba93
Pipeline #2770 failed with stage
in 24 seconds
......@@ -7,6 +7,7 @@ vtools.cli
:license: MIT
"""
import json
import logging
import click
from cyvcf2 import VCF, Writer
......@@ -15,6 +16,13 @@ from .filter import FilterParams, FilterClass, Filterer
from .stats import Stats
from .gcoverage import RefRecord, region_coverages
# Create logger and console handler
logger = logging.getLogger('vtools')
formatter = logging.Formatter('%(name)s - %(message)s')
ch = logging.StreamHandler()
ch.setFormatter(formatter)
logger.addHandler(ch)
@click.command()
@click.option("-c", "--call-vcf", type=click.Path(exists=True),
......@@ -36,8 +44,18 @@ from .gcoverage import RefRecord, region_coverages
@click.option("-dc", "--discordant", type=click.Path(writable=True),
help="Path to output discordant VCF file",
required=False)
@click.option("--log", type=click.Choice(['debug', 'info', 'warning', 'error',
'critical']), default='info')
def evaluate_cli(call_vcf, positive_vcf, call_samples, positive_samples, stats,
discordant):
discordant, log):
# Set the level for the logger and the handler
logger.setLevel(log.upper())
ch.setLevel(log.upper())
logger.debug('Ontbuggen')
logger.info('informatie')
logger.warning('waarschuwing')
logger.error('fout')
logger.critical('kritiek')
c_vcf = VCF(call_vcf, gts012=True)
p_vcf = VCF(positive_vcf, gts012=True)
st, disc = site_concordancy(c_vcf, p_vcf, call_samples,
......
......@@ -7,6 +7,7 @@ vtools.evaluate
:license: MIT
"""
from typing import List, Dict
import logging
from cyvcf2 import VCF
......@@ -42,6 +43,14 @@ def site_concordancy(call_vcf: VCF,
"het_concordant": 0, "sites_considered": 0,
"total_sites": 0}
"""
logger = logging.getLogger('vtools.evaluate')
logger.debug('Ontbuggen')
logger.info('informatie')
logger.warning('waarschuwing')
logger.error('fout')
logger.critical('kritiek')
if len(positive_samples) != len(call_samples):
raise ValueError("Lists of samples must have same size")
......@@ -70,6 +79,7 @@ def site_concordancy(call_vcf: VCF,
pos_record.end
)
it = call_vcf(query_str)
same = []
for it_record in it:
......@@ -79,6 +89,9 @@ def site_concordancy(call_vcf: VCF,
and it_record.ALT == pos_record.ALT):
same.append(it_record)
logger.debug('{} is excluded'.format(query_str))
else:
logger.debug('{} is included'.format(query_str))
if len(same) != 1:
continue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment