A generator that returns sequence pieces, seperated by indexes specified in idxs.
547068
def split_by_idxs(seq, idxs):
    ''' '''
    last = 0
    for idx in idxs:
        if not (-len(seq) <= idx < len(seq)):
          raise KeyError(f'Idx {idx} is out-of-bounds')
        yield seq[last:idx]
        last = idx
    yield seq[last:]
1308240
def extract_sequences(self, ids, new_path=None):
        """"""
        # Temporary path #
        if new_path is None: new_fasta = self.__class__(new_temp_path())
        elif isinstance(new_path, FASTA): new_fasta = new_path
        else:                new_fasta = self.__class__(new_path)
        # Do it #
        new_fasta.create()
        for seq in self:
            if seq.id in ids: new_fasta.add_seq(seq)
        new_fasta.close()
        return new_fasta
717261
def _chunks(l, n):
    
    for i in xrange(0, len(l), n):
        yield l[i:i+n]
81260
def index_row(a:Union[Collection,pd.DataFrame,pd.Series], idxs:Collection[int])->Any:
    ""
    if a is None: return a
    if isinstance(a,(pd.DataFrame,pd.Series)):
        res = a.iloc[idxs]
        if isinstance(res,(pd.DataFrame,pd.Series)): return res.copy()
        return res
    return a[idxs]
1005073
def _join_sequence(seq, last_separator=''):
    """"""
    count = len(seq)
    return ', '.join(_format_element(element, count, i, last_separator)
                     for i, element in enumerate(seq))
118350
def fetch(index, tokens):
    
    if len(tokens) == 0:
        return set()
    return set.intersection(*[set(index.get(token, [])) for token in tokens])
594723
def convertSequenceMachineSequence(generatedSequences):
  
  sequenceList = []
  currentSequence = []
  for s in generatedSequences:
    if s is None:
      sequenceList.append(currentSequence)
      currentSequence = []
    else:
      currentSequence.append(s)

  return sequenceList
1257081
def multi_mask_sequences(records, slices):
    
    for record in records:
        record_indices = list(range(len(record)))
        keep_indices = reduce(lambda i, s: i - frozenset(record_indices[s]),
                              slices, frozenset(record_indices))
        seq = ''.join(b if i in keep_indices else '-'
                      for i, b in enumerate(str(record.seq)))
        record.seq = Seq(seq)
        yield record
285366
public function getIndexes(): \Generator
    {
        $definitions = $this->reflection->getProperty('indexes') ?? [];

        foreach ($definitions as $definition) {
            yield $this->castIndex($definition);
        }
    }
1176360
def genslices_ndim(ndim, shape):
    """"""
    iterables = [genslices(shape[n]) for n in range(ndim)]
    yield from product(*iterables)
1065333
def sequence(values):
    
    import ibis.expr.operations as ops

    return ops.ValueList(values).to_expr()
1359057
def __get_idxs(self, words):
        """"""
        if self.bow:
            return list(itertools.chain.from_iterable(
                [self.positions[z] for z in words]))
        else:
            return self.positions[words]
613254
def extract_indexes(coords):
    """"""
    for name, variable in coords.items():
        variable = as_variable(variable, name=name)
        if variable.dims == (name,):
            yield name, variable.to_index()
482131
def build(values):
		'''
		
		'''
		idxstore = IndexStore()
		idxstore._i2val = list(values)
		idxstore._val2i = {term:i for i,term in enumerate(values)}
		idxstore._next_i = len(values)
		return idxstore
662005
def _sequence_map(cls, seq, path):
        
        if not any(path):
            # There is no further kwargsql expression
            return seq
        result = []
        for item in seq:
            try:
                result.append(cls.__resolve_path(item, path))
            except (KeyError, IndexError):
                pass
        return result
366506
def pieces(array, chunk_size):
        """"""
        for i in range(0, len(array), chunk_size): yield array[i:i+chunk_size]
567975
def chunks(l, n):
    """"""
    if n:
        for i in xrange(0, len(l), n):
            yield l[i:i + n]