Yield CompoundEntries for defined compounds
553746
def parse_compounds(self):
        """"""

        if 'compounds' in self._model:
            for compound in parse_compound_list(
                    self._context, self._model['compounds']):
                yield compound
628315
def xselections(items, n):
    
    if n==0:
        yield []
    else:
        for i in xrange(len(items)):
            for ss in xselections(items, n-1):
                yield [items[i]]+ss
763475
def flatten(items,enter=lambda x:isinstance(x, list)):
    # http://stackoverflow.com/a/40857703
    # https://github.com/ctmakro/canton/blob/master/canton/misc.py
    """"""
    for x in items:
        if enter(x):
            yield from flatten(x)
        else:
            yield x
906016
def possiblesplits(n, minsplits=2, maxsplits=0):
    """"""
    if not maxsplits: maxsplits = n
    for nrsplits in range(minsplits,maxsplits + 1):
        for split in sum_to_n(n,nrsplits):
            split_with_indices = []
            begin = 0
            for length in split:
                split_with_indices.append( (begin, length) )
                begin += length
            yield split_with_indices
1299508
def yield_pair_energies(self, index1, index2):
        """"""
        A = self.As[index1, index2]
        B = self.Bs[index1, index2]
        distance = self.distances[index1, index2]
        yield A*np.exp(-B*distance), 1
900690
def each
      if block_given?
        length.times do |n|
          yield build_coordinate(n)
        end
        self
      else
        length.times.collect { |n|
          build_coordinate(n)
        }.to_enum
      end
    end
482641
def iteritems(self):
        
        keys_yielded = set()
        for k, v in self._pairs:
            if k not in keys_yielded:
                keys_yielded.add(k)
                yield k, v
523376
def genslices(n):
    """"""
    def range_with_none():
        yield None
        yield from range(-n, n+1)

    for t in product(range_with_none(), range_with_none(), range_with_none()):
        s = slice(*t)
        if s.step != 0:
            yield s
173448
def slice_into_pieces(seq, n):
    """"""
    length = len(seq)
    if length % n == 0:
        size = length // n
    else:
        size = length // n + 1
    for it in slice_by_size(seq, size):
        yield it
366506
def pieces(array, chunk_size):
        """"""
        for i in range(0, len(array), chunk_size): yield array[i:i+chunk_size]
900732
def translate_sbml_reaction(entry, new_id, compartment_map, compound_map):
    """"""
    new_entry = DictReactionEntry(entry, id=new_id)

    # Convert compound IDs in reaction equation
    if new_entry.equation is not None:
        compounds = []
        for compound, value in new_entry.equation.compounds:
            # Translate compartment to new ID, if available.
            compartment = compartment_map.get(
                compound.compartment, compound.compartment)
            new_compound = compound.translate(
                lambda name: compound_map.get(name, name)).in_compartment(
                    compartment)
            compounds.append((new_compound, value))

        new_entry.equation = Reaction(
            new_entry.equation.direction, compounds)

    # Get XHTML notes properties
    for key, value in iteritems(parse_xhtml_reaction_notes(entry)):
        if key not in new_entry.properties:
            new_entry.properties[key] = value

    return new_entry
735685
def yield_pair_energies(self, index1, index2):
        """"""
        strength = self.strengths[index1, index2]
        distance = self.distances[index1, index2]
        yield strength*distance**(-6), 1
538569
def p_compound_variable(p):
    ''''''
    if len(p) == 2:
        p[0] = ast.Variable(p[1], lineno=p.lineno(1))
    else:
        p[0] = ast.Variable(p[3], lineno=p.lineno(1))
1277576
def run(self):
        """"""

        # Create solver
        solver = self._get_solver()

        # Load compound information
        def compound_name(id):
            if id not in self._model.compounds:
                return id
            return self._model.compounds[id].properties.get('name', id)

        # TODO: The exchange and transport reactions have tuple names. This
        # means that in Python 3 the reactions can no longer be directly
        # compared (e.g. while sorting) so define this helper function as a
        # workaround.
        def reaction_key(r):
            return r if isinstance(r, tuple) else (r,)

        # Calculate penalty if penalty file exists
        penalties = {}
        if self._args.penalty is not None:
            for line in self._args.penalty:
                line, _, comment = line.partition('#')
                line = line.strip()
                if line == '':
                    continue
                rxnid, penalty = line.split(None, 1)
                penalties[rxnid] = float(penalty)

        model_extended, weights = create_extended_model(
            self._model,
            db_penalty=self._args.db_penalty,
            ex_penalty=self._args.ex_penalty,
            tp_penalty=self._args.tp_penalty,
            penalties=penalties)

        epsilon = self._args.epsilon
        core = set()
        if self._args.subset is None:
            for r in self._mm.reactions:
                if not self._mm.is_exchange(r):
                    core.add(r)
        else:
            for line in self._args.subset:
                line = line.strip()
                if line == '':
                    continue
                core.add(line)
        induced = fastgapfill(model_extended, core, weights=weights,
                              epsilon=epsilon, solver=solver)

        for reaction_id in sorted(self._mm.reactions):
            rx = self._mm.get_reaction(reaction_id)
            rxt = rx.translated_compounds(compound_name)
            print('{}\t{}\t{}\t{}'.format(reaction_id, 'Model', 0, rxt))

        for rxnid in sorted(induced, key=reaction_key):
            if self._mm.has_reaction(rxnid):
                continue
            rx = model_extended.get_reaction(rxnid)
            rxt = rx.translated_compounds(compound_name)
            print('{}\t{}\t{}\t{}'.format(
                rxnid, 'Add', weights.get(rxnid, 1), rxt))
1327758
def each
      (1..ROWS).each do |r|
        (1..COLS).each do |c|
          yield(r, c, self[r, c])
        end
      end
    end
1015754
def generate_chunks(data, chunk_size=DEFAULT_CHUNK_SIZE):
    """"""
    iterator = iter(repeated.getvalues(data))

    while True:
        chunk = list(itertools.islice(iterator, chunk_size))
        if not chunk:
            return

        yield chunk
439271
private void makeCompounds(List<String> compoundList,
			List<String> sourceList) {
		//		System.out.println("[makeCompounds] making compounds from compoundLines");

		for (String line : compoundList) {
			if (compoundList.indexOf(line) + 1 == compoundList.size()) {
				//				System.out.println("[makeCompounds] Final line in compoundLines.");
				isLastCompndLine = true;
			}
			pdb_COMPND_Handler(line);

		}
		//		System.out.println("[makeCompounds] adding sources to compounds from sourceLines");
		// since we're starting again from the first compound, reset it here
		if ( entities.size() == 0){
			current_compound = new EntityInfo();
		} else {
			current_compound = entities.get(0);
		}
		for (String line : sourceList) {
			if (sourceList.indexOf(line) + 1 == sourceList.size()) {
				//				System.out.println("[makeCompounds] Final line in sourceLines.");
				isLastSourceLine = true;
			}
			pdb_SOURCE_Handler(line);
		}

	}