If we are running a non-genome analysis, pull the regional file for analysis.
556459
def _get_regional_bed_file(data):
    
    variant_regions = bedutils.merge_overlaps(tz.get_in(["config", "algorithm", "variant_regions"], data),
                                              data)
    is_genome = data["config"]["algorithm"].get("coverage_interval", "exome").lower() in ["genome"]
    if variant_regions and utils.file_exists(variant_regions) and not is_genome:
        return variant_regions
1254863
protected void assertExtractSource(File archive) throws FileNotFoundException, IllegalArgumentException {
        if (archive.isDirectory()) {
            throw new IllegalArgumentException("Can not extract " + archive + ". Source is a directory.");
        } else if (!archive.exists()) {
            throw new FileNotFoundException(archive.getPath());
        } else if (!archive.canRead()) {
            throw new IllegalArgumentException("Can not extract " + archive + ". Can not read from source.");
        }
    }
241492
def _combine_regional_coverage(in_bams, samplenames, chrom, start, end, work_dir, data):
    
    dfs = [_calc_regional_coverage(bam, chrom, start, end, sample, work_dir, data) for bam, sample
           in zip(in_bams, samplenames)]
    return rbind(dfs)
868232
def analyze(self, handle, filename):
        
        # multipart post files.
        files = {"sample_file": (filename, handle)}

        # ensure the handle is at offset 0.
        handle.seek(0)

        response = self._request("/sample/submit", method='POST', files=files, headers=self.headers)

        try:
            if response.status_code == 200 and not response.json()['data']['errors']:
                # only support single-file submissions; just grab the first one.
                return response.json()['data']['samples'][0]['sample_id']
            else:
                raise sandboxapi.SandboxError("api error in analyze ({u}): {r}".format(u=response.url, r=response.content))
        except (ValueError, KeyError, IndexError) as e:
            raise sandboxapi.SandboxError("error in analyze: {e}".format(e=e))
799136
def sample_chromosomes(job, genome_fai_file):
    
    work_dir = os.getcwd()
    genome_fai = untargz(job.fileStore.readGlobalFile(genome_fai_file), work_dir)
    return chromosomes_from_fai(genome_fai)
991445
def _analyze_file(self, f):
        """"""

        f.seek(0)
        # Check for BOMs
        if self.CHECK_BOM:
            encoding = self.has_bom(f)
            f.seek(0)
        else:
            util.warn_deprecated(
                "'CHECK_BOM' attribute is deprecated. "
                "Please override 'has_bom` function to control or avoid BOM detection."
            )
        # Check file extensions
        if encoding is None:
            encoding = self._utf_strip_bom(self.header_check(f.read(1024)))
            f.seek(0)
        if encoding is None:
            encoding = self._utf_strip_bom(self.content_check(f))
            f.seek(0)

        return encoding
1039760
def _extract_local_archive(working_dir, cleanup_functions, env_name, local_archive):
    
    with zipfile.ZipFile(local_archive) as z:
        z.extractall(working_dir)
        archive_filenames = z.namelist()

    root_elements = {m.split(posixpath.sep, 1)[0] for m in archive_filenames}
    abs_archive_filenames = [os.path.abspath(os.path.join(working_dir, f)) for f in root_elements]

    def cleanup():
        for fn in abs_archive_filenames:
            if os.path.isdir(fn):
                shutil.rmtree(fn)
            else:
                os.unlink(fn)

    cleanup_functions.append(cleanup)
    env_dir = os.path.join(working_dir, env_name)
    # Because of a python deficiency (Issue15795), the execute bits aren't
    # preserved when the zip file is unzipped. Need to add them back here.
    _fix_permissions(env_dir)
    return env_dir
1150966
def pull(self):
        
        if not os.path.exists(self.repo_dir):
            yield from self.initialize_repo()
        else:
            yield from self.update()
879754
def extract(self, remotepath, subpath, saveaspath = None):
		''' '''
		rpath = get_pcs_path(remotepath)
		topath = get_pcs_path(saveaspath)
		if not saveaspath:
			topath = os.path.dirname(rpath) + '/' + subpath
		return self.__panapi_unzipcopy_file(rpath, subpath, topath)
203182
def _run_scapy(self, scapy_all):
        """"""
        # if not self._flag_a:
        #     self._flag_a = True
        #     warnings.warn(f"'Extractor(engine=scapy)' object is not iterable; "
        #                     "so 'auto=False' will be ignored", AttributeWarning, stacklevel=stacklevel())

        if self._exlyr != 'None' or self._exptl != 'null':
            warnings.warn("'Extractor(engine=scapy)' does not support protocol and layer threshold; "
                          f"'layer={self._exlyr}' and 'protocol={self._exptl}' ignored",
                          AttributeWarning, stacklevel=stacklevel())

        # extract & analyse file
        self._expkg = scapy_all
        self._extmp = iter(scapy_all.sniff(offline=self._ifnm))

        # start iteration
        self.record_frames()
499770
def analyzed_files
      update_script_lines__
      raw_data_relative.select do |file, lines|
        @script_lines__.has_key?(file)
      end.map{|fname,| fname}
    end
511859
def run(bam_file, data, out_dir):
    """"""
    m = {"base": None, "secondary": []}
    m.update(_mirbase_stats(data, out_dir))
    m["secondary"].append(_seqcluster_stats(data, out_dir))
598940
def _load_from_disk(self, dtype_out_time, dtype_out_vert=False,
                        region=False):
        """"""
        ds = xr.open_dataset(self.path_out[dtype_out_time])
        if region:
            arr = ds[region.name]
            # Use region-specific pressure values if available.
            if (self.dtype_in_vert == internal_names.ETA_STR
                    and not dtype_out_vert):
                reg_pfull_str = region.name + '_pressure'
                arr = arr.drop([r for r in arr.coords.iterkeys()
                                if r not in (internal_names.PFULL_STR,
                                             reg_pfull_str)])
                # Rename pfull to pfull_ref always.
                arr = arr.rename({internal_names.PFULL_STR:
                                  internal_names.PFULL_STR + '_ref'})
                # Rename region_pfull to pfull if its there.
                if hasattr(arr, reg_pfull_str):
                    return arr.rename({reg_pfull_str:
                                       internal_names.PFULL_STR})
                return arr
            return arr
        return ds[self.name]
1358654
def extract(self, member, path=None, pwd=None):
        
        if isinstance(member, RarInfo):
            fname = member.filename
        else:
            fname = member
        self._extract([fname], path, pwd)
1238306
def _extract_file(self, tgz, tarinfo, dst_path, buffer_size=10<<20):
    """"""
    src = tgz.extractfile(tarinfo)
    dst = tf_v1.gfile.GFile(dst_path, "wb")
    while 1:
      buf = src.read(buffer_size)
      if not buf:
        break
      dst.write(buf)
      self._log_progress(len(buf))
    dst.close()
    src.close()
308541
def collect_non_report_files(args, discovered_files):
    
    excl_paths = exclude_paths(args)
    abs_root = os.path.abspath(args.root)
    non_report_files = []
    for root, dirs, files in os.walk(args.root, followlinks=args.follow_symlinks):
        dirs[:] = filter_dirs(root, dirs, excl_paths)

        for filename in files:
            if not is_source_file(args, filename):
                continue
            abs_filepath = os.path.join(os.path.abspath(root), filename)
            if is_excluded_path(args, abs_filepath):
                continue
            filepath = os.path.relpath(abs_filepath, abs_root)
            if filepath not in discovered_files:
                src_report = {}
                src_report['name'] = posix_path(filepath)
                coverage = []
                with io.open(abs_filepath, mode='rb') as fobj:
                    for _ in fobj:
                        coverage.append(None)
                    fobj.seek(0)
                    src_report['source_digest'] = hashlib.md5(fobj.read()).hexdigest()
                src_report['coverage'] = coverage
                non_report_files.append(src_report)
    return non_report_files
481960
def _create_subset_file(in_file, het_region_bed, work_dir, data):
    
    cnv_regions = shared.get_base_cnv_regions(data, work_dir)
    region_bed = bedutils.intersect_two(het_region_bed, cnv_regions, work_dir, data)
    out_file = os.path.join(work_dir, "%s-origsubset.bcf" % utils.splitext_plus(os.path.basename(in_file))[0])
    if not utils.file_uptodate(out_file, in_file):
        with file_transaction(data, out_file) as tx_out_file:
            regions = ("-R %s" % region_bed) if utils.file_exists(region_bed) else ""
            cmd = "bcftools view {regions} -o {tx_out_file} -O b {in_file}"
            do.run(cmd.format(**locals()), "Extract regions for BubbleTree frequency determination")
    return out_file