Indexes a BGEN file.

    Args:
        fn (str): The name of the BGEN file.
355896
def index_bgen(fn, legacy=False):
    
    logger.info("Indexing {} (BGEN) using 'bgenix'{}".format(
        fn, " (legacy mode)" if legacy else "",
    ))
    command = ["bgenix", "-g", fn, "-index"]
    if legacy:
        command.append("-with-rowid")
    try:
        logger.info("Executing '{}'".format(" ".join(command)))
        subprocess.Popen(command).communicate()
    except FileNotFoundError:
        logger.error("Cannot find 'bgenix', impossible to index {}".format(fn))
        sys.exit(1)
    logger.info("Index generated")
64821
def gen_top_index(collection, title, template, filename)
      template = TemplatePage.new(RDoc::Page::FR_INDEX_BODY, template)
      res = []
      collection.sort.each do |f|
        if f.document_self
          res << { "classlist" => CGI.escapeHTML("#{MODULE_DIR}/fr_#{f.index_name}.html"), "module" => CGI.escapeHTML("#{CLASS_DIR}/#{f.index_name}.html"),"name" => CGI.escapeHTML(f.index_name) }
        end
      end

      values = {
        "entries"    => res,
        'list_title' => CGI.escapeHTML(title),
        'index_url'  => main_url,
        'charset'    => @options.charset,
        'style_url'  => style_url('', @options.css),
      }

      Puppet::FileSystem.open(filename, nil, "w:UTF-8") do |f|
        template.write_html_on(f, values)
      end
    end
689058
def add(self, index, value):
        
        self.buf.append(value)
        if (index - self.flush_at) < self.interval:
            return
        value = np.mean(self.buf)
        if self.verbose:
            logger.info("iter={} {{{}}}={}".format(index, self.name, value))
        if self.fd is not None:
            print("{} {:g}".format(index, value), file=self.fd)
        self.flush_at = index
        self.buf = []
821471
def make_idd_index(extract_func, fname, debug):
    """"""
    astr = _readfname(fname)

    # fname is exhausted by the above read
    # reconstitute fname as a StringIO
    fname = StringIO(astr)

    # glist = iddgroups.iddtxt2grouplist(astr.decode('ISO-8859-2'))
    
    
    blocklst, commlst, commdct = extract_func(fname)
    
    name2refs = iddindex.makename2refdct(commdct)
    ref2namesdct = iddindex.makeref2namesdct(name2refs)
    idd_index = dict(name2refs=name2refs, ref2names=ref2namesdct)
    commdct = iddindex.ref2names2commdct(ref2namesdct, commdct)
    
    return blocklst, commlst, commdct, idd_index
648203
def bind(self, fn):
        '''
        '''
        @Parser
        def bind_parser(text, index):
            res = self(text, index)
            return res if not res.status else fn(res.value)(text, res.index)
        return bind_parser
320756
def _index_fs(self):
        

        indexed_objects = self._return_deque()

        directory = self.job_args.get('directory')
        if directory:
            indexed_objects = self._return_deque(
                deque=indexed_objects,
                item=self._drectory_local_files(
                    directory=directory
                )
            )

        object_names = self.job_args.get('object')
        if object_names:
            indexed_objects = self._return_deque(
                deque=indexed_objects,
                item=self._named_local_files(
                    object_names=object_names
                )
            )

        return indexed_objects
926201
def gff(args):
    
    p = OptionParser(gff.__doc__)
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    gbkfile, = args
    MultiGenBank(gbkfile)
864779
def remap_index_fn(ref_file):
    
    snap_dir = os.path.join(os.path.dirname(ref_file), os.pardir, "snap")
    assert os.path.exists(snap_dir) and os.path.isdir(snap_dir), snap_dir
    return snap_dir
123701
def eval_input_fn(params):
  """"""
  file_pattern = os.path.join(getattr(params, "data_dir", ""), "*encoded-dev*")
  return _read_and_batch_from_files(
      file_pattern, params.batch_size, params.max_length, params.num_cpu_cores,
      shuffle=False, repeat=1)
768671
def read(fn, **kwargs):
    
    ext = fn[fn.rfind('.'):].split('@')
    if len(ext) == 1:
        if ext[0] == '.out' or ext[0] == '.dat':
            dirname = os.path.dirname(fn)
            if len(dirname) == 0:
                dirname = '.'
            cycfn = dirname+'/cyc.dat'
            if os.path.exists(cycfn):
                return read_atoms(fn, cycfn=cycfn)
            return read_atoms(fn)
        elif ext[0] == '.nc':
            traj = NetCDFTrajectory(fn, **kwargs)
            return traj[-1]
        else:
            return ase.io.read(fn, **kwargs)
    elif len(ext) == 2:
        if ext[0] == '.nc':
            frame = int(ext[1])
            fn = fn[:fn.rfind('@')]
            traj = NetCDFTrajectory(fn)
            return traj[frame]
        else:
            return ase.io.read(fn, **kwargs)
    else:
        return ase.io.read(fn, **kwargs)
657801
def parseFilename(filename):
    

    # Parse out any extension specified in filename
    _indx = filename.find('[')
    if _indx > 0:
        # Read extension name provided
        _fname = filename[:_indx]
        _extn = filename[_indx + 1:-1]
    else:
        _fname = filename
        _extn = None

    return _fname, _extn
457420
def _index_files(path):
        """"""
        with zipfile.ZipFile(path) as zf:
            names = sorted(zf.namelist())
            names = [nn for nn in names if nn.endswith(".tif")]
            names = [nn for nn in names if nn.startswith("SID PHA")]
            phasefiles = []
            for name in names:
                with zf.open(name) as pt:
                    fd = io.BytesIO(pt.read())
                    if SingleTifPhasics.verify(fd):
                        phasefiles.append(name)
            return phasefiles
471393
def copy(self, new_fn):
        """"""
        new_file = self.__class__(fn=str(new_fn))
        new_file.write(data=self.read())
        new_file.utime(self.atime, self.mtime)
        return new_file
574041
def index(ref_file, out_dir, data):
    
    (ref_dir, local_file) = os.path.split(ref_file)
    gtf_file = dd.get_gtf_file(data)
    if not utils.file_exists(gtf_file):
        raise ValueError("%s not found, could not create a star index." % (gtf_file))
    if not utils.file_exists(out_dir):
        with tx_tmpdir(data, os.path.dirname(out_dir)) as tx_out_dir:
            num_cores = dd.get_cores(data)
            cmd = ("STAR --genomeDir {tx_out_dir} --genomeFastaFiles {ref_file} "
                   "--runThreadN {num_cores} "
                   "--runMode genomeGenerate --sjdbOverhang 99 --sjdbGTFfile {gtf_file}")
            do.run(cmd.format(**locals()), "Index STAR")
            if os.path.exists(out_dir):
                shutil.rmtree(out_dir)
            shutil.move(tx_out_dir, out_dir)
    return out_dir
840758
def in_file(self, fn: str) -> Iterator[Statement]:
        
        yield from self.__file_to_statements.get(fn, [])
1156172
def write_index(fn, index):
    
    with open(fn, "wb") as o_file:
        o_file.write(_CHECK_STRING)
        o_file.write(zlib.compress(bytes(
            index.to_csv(None, index=False, encoding="utf-8"),
            encoding="utf-8",
        )))
972220
def remap_index_fn(ref_file):
    
    index_dir = os.path.join(os.path.dirname(ref_file), os.pardir, "minimap2")
    if os.path.exists(index_dir) and os.path.isdir(index_dir):
        return index_dir
    else:
        return os.path.dirname(ref_file)