Return cyvcf2 VCF object

    Args:
        file_path(str)

    Returns:
        vcf_obj(cyvcf2.VCF)
975219
def get_file_handle(file_path):
    
    LOG.debug("Check if file end is correct")

    if not os.path.exists(file_path):
        raise IOError("No such file:{0}".format(file_path))

    if not os.path.splitext(file_path)[-1] in VALID_ENDINGS:
        raise IOError("Not a valid vcf file name: {}".format(file_path))

    vcf_obj = VCF(file_path)

    return vcf_obj
400773
def parse(file_path):
    
    newDecoder = MMTFDecoder()
    with open(file_path, "rb") as fh:
        newDecoder.decode_data(_unpack(fh))
    return newDecoder
1211211
def GetFileEntryByPathSpec(self, path_spec):
    
    if not self.FileEntryExistsByPathSpec(path_spec):
      return None

    location = getattr(path_spec, 'location', None)

    if len(location) == 1:
      return tar_file_entry.TARFileEntry(
          self._resolver_context, self, path_spec, is_root=True,
          is_virtual=True)

    kwargs = {}
    try:
      kwargs['tar_info'] = self._tar_file.getmember(location[1:])
    except KeyError:
      kwargs['is_virtual'] = True

    return tar_file_entry.TARFileEntry(
        self._resolver_context, self, path_spec, **kwargs)
808308
def _getpath(self, path):
        ""
        if is_blacklisted(path):
            raise JottaFuseError('Blacklisted file, refusing to retrieve it')

        return self.client.getObject(path)
1211652
def _get_file_iterator(self, file_obj):
        
        file_obj.seek(0)

        return iter(lambda: file_obj.read(self.read_bs), '')
541954
def _OpenFileObject(self, path_spec):
    
    if not path_spec.HasParent():
      raise errors.PathSpecError(
          'Unsupported path specification without parent.')

    file_object = resolver.Resolver.OpenFileObject(
        path_spec.parent, resolver_context=self._resolver_context)
    qcow_file = pyqcow.file()
    qcow_file.open_file_object(file_object)
    return qcow_file
1119335
def read_file(file_path_name):
    
    with io.open(os.path.join(os.path.dirname(__file__), file_path_name), mode='rt', encoding='utf-8') as fd:
        return fd.read()
809520
def _get_cygwin_path(self, windows_path):
        
        conv_cmd = [os.path.join(self._cygwin_bin_location, "cygpath.exe"),
                    "-u", windows_path]
        process = Popen(conv_cmd,
                        stdout=PIPE, stderr=PIPE, shell=False)
        out, err = process.communicate()
        if err:
            print(err)
            raise Exception(err)

        return out.strip()
1030639
def from_file_path(cls, path_prefix):
        
        with cls._path_prefix_to_files(path_prefix, 'r') as (array_file, vocab_file):
            return cls.from_files(array_file, vocab_file)
241340
def _get_filename_path(self, path):
        
        feature_filename = os.path.join(path, self.feature_type.value)

        if self.feature_name is not None:
            feature_filename = os.path.join(feature_filename, self.feature_name)

        return feature_filename
15529
def split_vcf(in_file, ref_file, config, out_dir=None):
    
    if out_dir is None:
        out_dir = os.path.join(os.path.dirname(in_file), "split")
    out_files = []
    with open(ref.fasta_idx(ref_file, config)) as in_handle:
        for line in in_handle:
            chrom, size = line.split()[:2]
            out_file = os.path.join(out_dir,
                                    os.path.basename(replace_suffix(append_stem(in_file, "-%s" % chrom), ".vcf")))
            subset_vcf(in_file, (chrom, 0, size), out_file, config)
            out_files.append(out_file)
    return out_files
1245523
def to_vcf(in_file, caller, header_fn, vcf_fn, data, sep="\t"):
    
    out_file = "%s.vcf" % utils.splitext_plus(in_file)[0]
    if not utils.file_exists(out_file + ".gz") and not utils.file_exists(out_file):
        with file_transaction(data, out_file) as tx_out_file:
            with open(in_file) as in_handle:
                with open(tx_out_file, "w") as out_handle:
                    out_handle.write(_vcf_header.format(caller=caller))
                    out_handle.write("\t".join(["#CHROM", "POS", "ID", "REF", "ALT", "QUAL",
                                                "FILTER", "INFO", "FORMAT", dd.get_sample_name(data)]) + "\n")
                    header, in_handle = header_fn(in_handle)
                    for line in in_handle:
                        out = vcf_fn(dict(zip(header, line.strip().split(sep))))
                        if out:
                            out_handle.write("\t".join(out) + "\n")
    out_file = vcfutils.bgzip_and_index(out_file, data["config"])
    effects_vcf, _ = effects.add_to_vcf(out_file, data, "snpeff")
    return effects_vcf or out_file
1077399
def merge_vcf_files(infiles, ref_seqs, outfile, threads=1):
    ''''''
    vars_dict = vcf_file_read.vcf_files_to_dict_of_vars(infiles, ref_seqs, threads=threads)
    _dict_of_vars_to_vcf_file(vars_dict, outfile)
307012
def parse_file_path(filepath):
    # type: (pathlib.Path) -> Tuple[str, str, str]
    
    if not isinstance(filepath, pathlib.Path):
        filepath = pathlib.Path(filepath)
    dirname = '/'.join(filepath.parts[:len(filepath.parts) - 1])
    if len(dirname) == 0:
        dirname = None
    if len(filepath.parts) > 0:
        fname = filepath.parts[-1]
    else:
        fname = None
    fname, snapshot = blobxfer.util.parse_fileshare_or_file_snapshot_parameter(
        fname)
    return (dirname, fname, snapshot)
1151445
def read_file(self, file_path):
        
        try:
            with open(self.p(file_path)) as fd:
                return fd.read()
        except IOError as ex:
            logger.error("error while accessing file %s: %r", file_path, ex)
            raise ConuException("There was an error while accessing file %s: %r", file_path, ex)
1024758
def _OpenFileObject(self, path_spec):
    
    if not path_spec.HasParent():
      raise errors.PathSpecError(
          'Unsupported path specification without parent.')

    resolver.Resolver.key_chain.ExtractCredentialsFromPathSpec(path_spec)

    file_object = resolver.Resolver.OpenFileObject(
        path_spec.parent, resolver_context=self._resolver_context)
    fvde_volume = pyfvde.volume()
    fvde.FVDEVolumeOpen(
        fvde_volume, path_spec, file_object, resolver.Resolver.key_chain)
    return fvde_volume
243155
def ParseFileObject(self, parser_mediator, file_object):
    
    olecf_file = pyolecf.file()
    olecf_file.set_ascii_codepage(parser_mediator.codepage)

    try:
      olecf_file.open_file_object(file_object)
    except IOError as exception:
      parser_mediator.ProduceExtractionWarning(
          'unable to open file with error: {0!s}'.format(exception))
      return

    root_item = olecf_file.root_item
    if not root_item:
      return

    # Get a list of all items in the root item from the OLECF file.
    item_names = [item.name for item in root_item.sub_items]

    # Compare the list of available plugin objects.
    # We will try to use every plugin against the file (except
    # the default plugin) and run it. Only if none of the plugins
    # works will we use the default plugin.

    item_names = frozenset(item_names)

    try:
      for plugin in self._plugins:
        if parser_mediator.abort:
          break

        if not plugin.REQUIRED_ITEMS.issubset(item_names):
          continue

        try:
          plugin.UpdateChainAndProcess(parser_mediator, root_item=root_item)

        except Exception as exception:  # pylint: disable=broad-except
          parser_mediator.ProduceExtractionWarning((
              'plugin: {0:s} unable to parse OLECF file with error: '
              '{1!s}').format(plugin.NAME, exception))

      if self._default_plugin and not parser_mediator.abort:
        try:
          self._default_plugin.UpdateChainAndProcess(
              parser_mediator, root_item=root_item)

        except Exception as exception:  # pylint: disable=broad-except
          parser_mediator.ProduceExtractionWarning((
              'plugin: {0:s} unable to parse OLECF file with error: '
              '{1!s}').format(self._default_plugin.NAME, exception))

    finally:
      olecf_file.close()