Check if bam file has an index. Returns True/False.
761278
def bam_has_index(bam_file):
    """"""
    has_index = None
    with pysam.AlignmentFile(bam_file, 'rb') as bam_fileobj:
        try:
            bam_fileobj.fetch(bam_fileobj.references[0])
        except ValueError as err:
            if err.message == 'fetch called on bamfile without index':
                bam_fileobj.close()
                has_index = False
        else:
            has_index = True
    return has_index
564673
def index_exists(self, table: str, indexname: str) -> bool:
        """"""
        # MySQL:
        sql = ("SELECT COUNT(*) FROM information_schema.statistics"
               " WHERE table_name=? AND index_name=?")
        row = self.fetchone(sql, table, indexname)
        return True if row[0] >= 1 else False
342303
def has_file(self, name: str):
        '''
        
        '''
        return os.path.isfile(self._path / name)
527248
public function hasIndex($index)
    {
        if ($index instanceof Index) {
            $index = $index->getName();
        }

        return \in_array($index, $this->_indices);
    }
1079381
def check_index(i):
    

    i = asarray(i)
    if (i.ndim > 1) or (size(i) < 1):
        raise Exception("Index must be one-dimensional and non-singleton")

    return i
290681
def is_empty(bam_file):
    
    bam_file = objectstore.cl_input(bam_file)
    cmd = ("set -o pipefail; "
           "samtools view {bam_file} | head -1 | wc -l")
    p = subprocess.Popen(cmd.format(**locals()), shell=True,
                         executable=do.find_bash(),
                         stdout=subprocess.PIPE, stderr=subprocess.PIPE,
                         preexec_fn=lambda: signal.signal(signal.SIGPIPE, signal.SIG_DFL))
    stdout, stderr = p.communicate()
    stdout = stdout.decode()
    stderr = stderr.decode()
    if ((p.returncode == 0 or p.returncode == 141) and
         (stderr == "" or (stderr.startswith("gof3r") and stderr.endswith("broken pipe")))):
        return int(stdout) == 0
    else:
        raise ValueError("Failed to check empty status of BAM file: %s" % str(stderr))
954295
def _check_index(self):
        """"""
        assert 0 <= self._index <= len(self._history) - 1
        # There should always be the base item at least.
        assert len(self._history) >= 1
579111
def checkFileExists(filename, directory=None):
    

    if directory is not None:
        fname = os.path.join(directory,filename)
    else:
        fname = filename
    _exist = os.path.exists(fname)
    return _exist
283451
public boolean get(long index) throws IOException {
        try {
            lock().acquireReadLock();
            int value = mFile.read(index >> 3);
            return value > 0 && ((value << (index & 7)) & 0x80) != 0;
        }
        catch (InterruptedException e) {
            throw new InterruptedIOException();
        }
        finally {
            lock().releaseLock();
        }
    }
831242
def samtools_index(self, bam_file):
        """"""
        cmd = self.tools.samtools + " index {0}".format(bam_file)
        return cmd
1278640
public boolean isUseSecondryIndex()
    {
        // if lucene directory and indexer class both not present then return
        // true.

        return StringUtils.isEmpty(LuceneIndexDir) && StringUtils.isBlank(LuceneIndexDir)
                && StringUtils.isEmpty(indexImplementor) && StringUtils.isBlank(indexImplementor);
    }
704730
public Boolean hasIndex() {

        Boolean hasIndex = false;
        if (this.indexedFastaSequenceFile != null) {
            hasIndex = this.indexedFastaSequenceFile.isIndexed();
        }
        return hasIndex;
    }
1041435
def is_indexing(working_dir):
    
    indexing_path = get_indexing_lockfile(working_dir)
    if os.path.exists( indexing_path ):
        return True
    else:
        return False
569508
def index_bams(job, config):
    
    job.fileStore.logToMaster('Indexed sample BAMS: ' + config.uuid)
    disk = '1G' if config.ci_test else '20G'
    config.normal_bai = job.addChildJobFn(run_samtools_index, config.normal_bam, cores=1, disk=disk).rv()
    config.tumor_bai = job.addChildJobFn(run_samtools_index, config.tumor_bam, cores=1, disk=disk).rv()
    job.addFollowOnJobFn(preprocessing_declaration, config)
298969
def contains_index(self):
        """"""
        if self._contains_index is None:
            max_t = 0
            for tkey in self.types:
                if self.types[tkey].end > max_t and not self.types[tkey].embedded:
                    max_t = self.types[tkey].end

            #Now we have a good first guess. Continue to iterate the next few lines
            #of the the refstring until we find a solid "CONTAINS" keyword. If there
            #are no types in the module, then max_t will be zero and we don't have
            #the danger of running into a contains keyword as part of a type. In that
            #case we can just keep going until we find it.
            i = 0
            start = self.linenum(max_t)[0]
            max_i = 10 if max_t > 0 else len(self._lines)

            while (self._contains_index is None and i < max_i
                   and start + i < len(self._lines)):
                iline = self._lines[start + i].lower()
                if "contains" in iline:
                    if '!' not in iline or (iline.index('!') > iline.index("contains")):
                        self._contains_index = start + i
                i += 1

            if self._contains_index is None:
                #There must not be a CONTAINS keyword in the module
                self._contains_index = len(self._lines)-1

        return self._contains_index
198707
def is_directory_index(resource):
    
    remote_regexp = re.compile(r"^https?://(.+)/?$", re.I)
    result = remote_regexp.match(resource)

    if result is not None:
        juicer.utils.Log.log_debug("%s matches directory index regexp" % resource)
        return True
    else:
        juicer.utils.Log.log_debug("%s doesn't match directory index regexp" % resource)
        return False
172532
def is_indexed(self):
        
        try:
            return getattr(self.table.cols, self.cname).is_indexed
        except AttributeError:
            False