Multiset
PyCellChemistry documentation index
/Users/lidia/main/research/acbook/web/website/ac-home/pycellchem/pycellchem-2.0/src/artchem/Multiset.py

#---------------------------------------------------------------------------
#
# Multiset.py: a multiset class
#
# a multiset is a bag of objects (molecules in our context), like a
# set where every object may occur more than once
#
# Example: { A:2, B:3 } represents a bag containing 2 molecules of
# species (type) A and 3 molecules of type B
#
# by Lidia Yamamoto, Univ. Basel, Switzerland, January 2010
# June 2013: adapted to the PyCellChemistry package
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# Copyright (C) 2015 Lidia A. R. Yamamoto
# Contact: http://www.artificial-chemistries.org/
#
# This file is part of PyCellChemistry.
#
# PyCellChemistry is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 3, as published by the Free Software Foundation.
#
# PyCellChemistry is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyCellChemistry, see file COPYING. If not, see
# http://www.gnu.org/licenses/
#


Modules
numpy
sys


Classes
Multiset


class Multiset
Methods defined here:
__init__(self)
initialize empty multiset
absorb(self, victim)
absorb victim multiset into my own (victim will return empty)
clear(self)
delete all molecules from the multiset
divide(self)
divide multiset in two parts; returns daughter multiset created
empty(self)
true if this multiset is empty
expel(self, mol, mult=1)
expel a given amount of a molecule from the multiset;
returns the number of molecules actually expelled
expelrnd(self)
expel a random molecule from the multiset
inject(self, mol, mult=1)
inject a given amount of a molecule in the multiset
keys(self)
list containing the set of different objects in the multiset
mult(self, mol='')
multiplicity: number of molecules of type 'mol' present
in the multiset
nmolecules(self)
total number of molecules in the multiset
nspecies(self)
number of distinct molecular species in the multiset
rndmol(self)
peek at a random molecule from the multiset, without
removing it
topkeys(self)
list of molecules in the multiset, ordered by decreasing
multiplicity
trace(self)
print the multiset object (typically for debug purposes)
trace_frequencies(self)
print a histogram of molecule multiplicities


Functions
rndpolymer(alphabet, length)
generate a random string of given length with characters from the
given alphabet


Generated automatically by pydoc, July 10, 2015