def __init__(self, data=None, RowOrder=None, ColOrder=None, Default=None, Pad=None, RowConstructor=None, info=None): """ Init dict with pre-exisitng data: dict of dicts Usage: data = distance matrix in form acceptable by Dict2D class RowOrder = list of 'interesting keys', default is the set of all amino acids ColOrder = list of 'interesting keys', default is the set of all amino acids Default = value to set padded elements to Pad = boolean describing whether to fill object to hold all possible elements based on RowOrder and ColOrder RowConstructor = constructor to use when building inner objects, default dict info = the AAIndexRecord object Power = Power the original matrix has been raised to yield current matrix """ if RowOrder is not None: self.RowOrder = RowOrder if ColOrder is not None: self.ColOrder = ColOrder if Pad is not None: self.Pad = Pad # Initialize super class attributes Dict2D.__init__(self, data=data, RowOrder=self.RowOrder,\ ColOrder=self.ColOrder, Default=Default, Pad=self.Pad,\ RowConstructor=RowConstructor) Delegator.__init__(self, info) # The power to which the original data has been raised to give # the current data, starts at 1., modified by elementPow() # accessed as self.Power self.__dict__['Power'] = 1.
def __init__(self, items="", length=None): """Initializes the Bitvector class, storing data in long _vector. Items can be any sequence with members that evaluate to True or False. Private data: _vector: long representing the bitvector _string: string representation of the vector _is_current: boolean indicating whether the string is known to match the long data """ Delegator.__init__(self, None) self.replace(items, length)
def __init__(self, data='', Info=None, **kwargs): """Initializes sequence object, bypassing validation. WARNING: Using this constructor can result in invalid data, though it is much faster without doing the validation. If validation is required, use the MutableSeq factory function, or one of its relatives (Rna, Dna, etc.) """ #ConstrainedContainer, not ConstrainedList, init to bypass validation #Note that ConstrainedContainer init ignores data! ConstrainedContainer.__init__(self, **kwargs) list.__init__(self, data) new_info = self._find_info(data, Info) Delegator.__init__(self, new_info)
def __init__(self, data=None, Info=None, **kwargs): """Intializes BaseUsage with data, either sequence or dict of freqs. Ignores additional kwargs (e.g. to support copy). Makes the _handler for delegator accessible with the name Info. """ if Info is None: if hasattr(data, 'Info'): Info = data.Info else: Info = InfoClass() Delegator.__init__(self, Info) Freqs.__init__(self, data or [], **kwargs)
def __init__(self, *args, **kwargs): """Returns new Info object. Creates DbRefs if necessary.""" temp = dict(*args, **kwargs) if 'Refs' in temp: refs = temp['Refs'] if not isinstance(refs, DbRefs): refs = DbRefs(refs) else: refs = DbRefs() #move keys into refs if they belong there: allows init from flat dict for key, val in temp.items(): if key in KnownDatabases: refs[key] = val del temp[key] Delegator.__init__(self, refs) self['Refs'] = refs MappedRecord.__init__(self, temp)
def __init__(self, Data=None, Children=None, Parent=None): """Returns new TreeNode, intialized with Data and maybe Children/Parent. Note: Parent is handled automatically when a node is appended to the children of another node. Desirable input for (phylogenetic) trees: - Newick string - Nexus block for tree, plus taxon map. - another tree object """ #allocate slots for private vars: make sure they don't get captured #by self.Data! self.__dict__['_data'] = None self.__dict__['_parent'] = None self.__dict__['_handler'] = None Delegator.__init__(self, Data) node_checker = ClassChecker(self.__class__) ConstrainedList.__init__(self, [], node_checker) self.Data = Data self.Parent = Parent if Children: self.extend(Children)
def __init__(self, data='', Info=None, **kwargs): """Initializes sequence object, with associated Info object.""" ConstrainedString.__init__(self, data, **kwargs) new_info = self._find_info(data, Info) Delegator.__init__(self, new_info)
def __init__(self, First=None, Second=None, Third=None, Info=None): """Returns new PositionalBaseUsage with values for the 3 positions.""" Delegator.__init__(self, Info) self.__dict__['First'] = First or BaseUsage() self.__dict__['Second'] = Second or BaseUsage() self.__dict__['Third'] = Third or BaseUsage()
def __init__(self, data, *args): Delegator.__init__(self, *args) self.__dict__['Info'] = self._handler str.__init__(self, data)