# Path: test/utils/vcf_test.py
# class MockFileWriter(object):
#     def __init__(self):
#         self._content = []
#         self.opened = False
#         self.closed = False
# 
#     def open(self):
#         self.opened = True
# 
#     def write(self, content):
#         if content == None:
#             return
#         self._content.extend(content.splitlines())
# 
#     def lines(self):
#         return self._content
# 
#     def close(self):
#         self.closed = True
# 
# class MockVcfReader(object):
#     def __init__(self,
#                  input_filepath="vcfName",
#                  metaheaders=None,
#                  column_header='#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tNORMAL\tTUMOR',
#                  content=None,
#                  records=None,
#                  sample_names=None):
# 
#         if content is None:
#             self.content = ["foo"]
#         else:
#             self.content = content
# 
#         if metaheaders is None:
#             self.metaheaders = ["##metaheaders"]
#         else:
#             self.metaheaders = metaheaders
# 
#         if records:
#             self.records = records
#         elif content:
#             self.records = [MockVcfRecord.parse_record(line) for line in self.content]
#         else:
#             self.records = []
# 
#         if sample_names is None:
#             self.sample_names = []
#         else:
#             self.sample_names = sample_names
#         self.file_name = input_filepath
#         self.input_filepath = input_filepath
#         self.column_header = column_header
#         self.split_column_header = self.column_header.strip("#").split("\t")
#         self.opened = False
#         self.closed = False
#         self._caller_name = "mockCaller"
#         self.qualified_sample_names = self._create_qualified_sample_names()
#         self.format_tags={}
# 
#     def open(self):
#         self.opened = True
#     #pylint:disable=unused-argument
#     def vcf_records(self, dummy=None, qualified=False):
#         for record in self.records:
#             yield record
# 
#     def tagged_vcf_records(self):
#         for record in self.records:
#             yield record
# 
#     def _get_tag_metaheaders(self, regex_exp):
#         tag_dict = {}
#         for metaheader in self.metaheaders:
#             tag = re.match(regex_exp, metaheader)
#             if tag:
#                 tag_key = tag.group(1)
#                 tag_dict[tag_key] = metaheader.strip()
# 
#         return tag_dict
# 
#     @property
#     def format_metaheaders(self):
#         return dict(self._get_tag_metaheaders("^##FORMAT=.*?[<,]ID=([^,>]*)"))
# 
#     @property
#     def info_metaheaders(self):
#         return dict(self._get_tag_metaheaders("^##INFO=.*?[<,]ID=([^,>]*)"))
# 
#     @property
#     def filter_metaheaders(self):
#         return dict(self._get_tag_metaheaders("^##FILTER=.*?[<,]ID=([^,>]*)"))
# 
#     @property
#     def contig_metaheaders(self):
#         return dict(self._get_tag_metaheaders("^##contig=.*?[<,]ID=([^,>]*)"))
# 
#     @property
#     def non_format_metaheaders(self):
#         return self.metaheaders
# 
#     def _create_qualified_sample_names(self):
#         patient_prefix = self.file_name.split(".")[0]
#         qualified_names = []
#         if self.sample_names:
#             for sample_name in self.sample_names:
#                 qualified_names.append("|".join([patient_prefix, sample_name]))
#         else:
#             qualified_names.append("|".join(["foo", "bar"]))
#         return qualified_names
# 
#     def modify_metaheader(self, original_metaheader, transformed_tag):
#         pass
# 
#     def store_format_tags(self, original_tag, new_tag):
#         self.format_tags[original_tag] = new_tag
# 
#     @property
#     def caller_name(self):
#         return self._caller_name
# 
#     def close(self):
#         self.closed = True


from argparse import Namespace
from testfixtures import TempDirectory
from test.utils.vcf_test import MockFileWriter, MockVcfReader
import os
import jacquard.summarize as summarize
import jacquard.utils.vcf as vcf
import test.utils.test_case as test_case
        if metaheaders_list:
            self.metaheaders_list = metaheaders_list
        else:
            self.metaheaders_list = []
        self.add_tags_called = False

    def add_tags(self, vcf_record):
        self.add_tags_called = True

    def get_metaheaders(self):
        return self.metaheaders_list

class SummarizeTestCase(test_case.JacquardBaseTestCase):
    def test_write_metaheaders(self):
        file_writer = MockFileWriter()
        vcf_reader = MockVcfReader(column_header="#header")
        caller = MockSummarizeCaller(["##summarize_metaheader"])
        summarize._write_metaheaders(caller,
                                     vcf_reader,
                                     file_writer,
                                     ["##execution_context"])
        expected = ["##execution_context",
                    "##metaheaders",
                    "##summarize_metaheader",
                    "#header"]
        self.assertEquals(expected, file_writer.lines())

    def test_add_summarize_tags(self):
        file_writer = MockFileWriter()
        vcf_record = vcf.VcfRecord("chr1", "42", "A", "C")

# Path: test/utils/vcf_test.py
# class MockFileWriter(object):
#     def __init__(self):
#         self._content = []
#         self.opened = False
#         self.closed = False
# 
#     def open(self):
#         self.opened = True
# 
#     def write(self, content):
#         if content == None:
#             return
#         self._content.extend(content.splitlines())
# 
#     def lines(self):
#         return self._content
# 
#     def close(self):
#         self.closed = True
# 
# class MockVcfReader(object):
#     def __init__(self,
#                  input_filepath="vcfName",
#                  metaheaders=None,
#                  column_header='#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\tFORMAT\tNORMAL\tTUMOR',
#                  content=None,
#                  records=None,
#                  sample_names=None):
# 
#         if content is None:
#             self.content = ["foo"]
#         else:
#             self.content = content
# 
#         if metaheaders is None:
#             self.metaheaders = ["##metaheaders"]
#         else:
#             self.metaheaders = metaheaders
# 
#         if records:
#             self.records = records
#         elif content:
#             self.records = [MockVcfRecord.parse_record(line) for line in self.content]
#         else:
#             self.records = []
# 
#         if sample_names is None:
#             self.sample_names = []
#         else:
#             self.sample_names = sample_names
#         self.file_name = input_filepath
#         self.input_filepath = input_filepath
#         self.column_header = column_header
#         self.split_column_header = self.column_header.strip("#").split("\t")
#         self.opened = False
#         self.closed = False
#         self._caller_name = "mockCaller"
#         self.qualified_sample_names = self._create_qualified_sample_names()
#         self.format_tags={}
# 
#     def open(self):
#         self.opened = True
#     #pylint:disable=unused-argument
#     def vcf_records(self, dummy=None, qualified=False):
#         for record in self.records:
#             yield record
# 
#     def tagged_vcf_records(self):
#         for record in self.records:
#             yield record
# 
#     def _get_tag_metaheaders(self, regex_exp):
#         tag_dict = {}
#         for metaheader in self.metaheaders:
#             tag = re.match(regex_exp, metaheader)
#             if tag:
#                 tag_key = tag.group(1)
#                 tag_dict[tag_key] = metaheader.strip()
# 
#         return tag_dict
# 
#     @property
#     def format_metaheaders(self):
#         return dict(self._get_tag_metaheaders("^##FORMAT=.*?[<,]ID=([^,>]*)"))
# 
#     @property
#     def info_metaheaders(self):
#         return dict(self._get_tag_metaheaders("^##INFO=.*?[<,]ID=([^,>]*)"))
# 
#     @property
#     def filter_metaheaders(self):
#         return dict(self._get_tag_metaheaders("^##FILTER=.*?[<,]ID=([^,>]*)"))
# 
#     @property
#     def contig_metaheaders(self):
#         return dict(self._get_tag_metaheaders("^##contig=.*?[<,]ID=([^,>]*)"))
# 
#     @property
#     def non_format_metaheaders(self):
#         return self.metaheaders
# 
#     def _create_qualified_sample_names(self):
#         patient_prefix = self.file_name.split(".")[0]
#         qualified_names = []
#         if self.sample_names:
#             for sample_name in self.sample_names:
#                 qualified_names.append("|".join([patient_prefix, sample_name]))
#         else:
#             qualified_names.append("|".join(["foo", "bar"]))
#         return qualified_names
# 
#     def modify_metaheader(self, original_metaheader, transformed_tag):
#         pass
# 
#     def store_format_tags(self, original_tag, new_tag):
#         self.format_tags[original_tag] = new_tag
# 
#     @property
#     def caller_name(self):
#         return self._caller_name
# 
#     def close(self):
#         self.closed = True


# Path: test/summarize_test.py
from argparse import Namespace
from testfixtures import TempDirectory
from test.utils.vcf_test import MockFileWriter, MockVcfReader
import os
import jacquard.summarize as summarize
import jacquard.utils.vcf as vcf
import test.utils.test_case as test_case

        if metaheaders_list:
            self.metaheaders_list = metaheaders_list
        else:
            self.metaheaders_list = []
        self.add_tags_called = False

    def add_tags(self, vcf_record):
        self.add_tags_called = True

    def get_metaheaders(self):
        return self.metaheaders_list

class SummarizeTestCase(test_case.JacquardBaseTestCase):
    def test_write_metaheaders(self):
        file_writer = MockFileWriter()
        vcf_reader = MockVcfReader(column_header="#header")
        caller = MockSummarizeCaller(["##summarize_metaheader"])
        summarize._write_metaheaders(caller,
                                     vcf_reader,
                                     file_writer,
                                     ["##execution_context"])
        expected = ["##execution_context",
                    "##metaheaders",
                    "##summarize_metaheader",
                    "#header"]
        self.assertEquals(expected, file_writer.lines())

    def test_add_summarize_tags(self):
        file_writer = MockFileWriter()
        vcf_record = vcf.VcfRecord("chr1", "42", "A", "C")

        vcf_reader = MockVcfReader(records=[vcf_record])