def __init__(self, name = None, length = None, children = None): """See class documentation for constraints.""" name = name or None length = length or None children = tuple(children or ()) nw_hash = hash((name, length, children)) Immutable.__init__(self, name = name, length = length, children = children, _hash = nw_hash) if not (self.children or self.name or self.length): raise NewickError("Leaf nodes MUST have either a name or a length") # Ensure that these values are hashable hash(self.name) hash(self.length) weight = 0 for child in self.children: if not isinstance(child, Newick): raise TypeError("Child nodes must be Newick nodes") weight += 1 object.__setattr__(self, "_weight", weight)
def __init__(self, name=None, length=None, children=None): """See class documentation for constraints.""" name = name or None length = length or None children = tuple(children or ()) nw_hash = hash((name, length, children)) Immutable.__init__(self, name=name, length=length, children=children, _hash=nw_hash) if not (self.children or self.name or self.length): raise NewickError("Leaf nodes MUST have either a name or a length") # Ensure that these values are hashable hash(self.name) hash(self.length) weight = 0 for child in self.children: if not isinstance(child, Newick): raise TypeError("Child nodes must be Newick nodes") weight += 1 object.__setattr__(self, "_weight", weight)
def __init__(self, description, func, *values): if not callable(func): raise TypeError('func must be callable, not %r' % (func,)) values = tuple(values) Immutable.__init__(self, _func=func, _values=values, _description=description, _objs=(description, func, values))
def __init__(self, name, meta, sequence): if not (name and isinstance(name, types.StringTypes)): raise FASTAError("FASTA name must be a non-empty string") elif not (isinstance(meta, types.StringTypes) or (meta is None)): raise FASTAError("FASTA meta-information must be a string, or None") elif not isinstance(sequence, types.StringTypes): raise FASTAError("FASTA sequence must be a string") Immutable.__init__(self, name = name, meta = meta, sequence = sequence)