def __init__(self, root_path=None, case_lines=None, case_type=None, pattern='*.vcf', vtype='snv', case_obj=None): """Initialize a vcf adapter. When instansiating all cases are found. Args: root_path(str) : Path to a vcf file or a dir with vcf files case_lines(Iterable) : Lines with ped like information case_type(str) : Format of pedigreeinformation patter(str) : What pattern to search for in directory vtype(str) : 'snv' or 'sv' case_obj(puzzle.models.case) : If initialized with a case """ super(VcfPlugin, self).__init__() self.individuals = [] self.case_objs = [] logger.info("Updating root path to {0}".format(root_path)) self.root_path = root_path self.check_setup(case_lines) self.variant_type = vtype logger.info("Setting variant type to {0}".format(vtype)) self.pattern = pattern logger.debug("Updating pattern to {0}".format(pattern)) if root_path: if os.path.isdir(root_path): logger.info("Looking for vcf files in {0}".format(root_path)) for vcf_file in self._find_vcfs(pattern=pattern): logger.info("Found vcf {0}".format(vcf_file)) case_obj = get_case(variant_source=vcf_file) self.case_objs.append(case_obj) else: self.case_objs.append(get_case( variant_source=self.root_path, case_lines=case_lines, case_type=case_type ) ) for case_obj in self.case_objs: for ind in case_obj.individuals: self.individuals.append(ind) self.filters = DotDict( can_filter_frequency=True, can_filter_cadd=True, can_filter_consequence=True, can_filter_gene=True, can_filter_inheritance=True, can_filter_sv=True, can_filter_impact_severity=True )
def case_obj(ped_lines): """Return a test case object with individuals.""" _case = get_case('test.vcf', case_lines=ped_lines) yield _case