Ejemplo n.º 1
0
    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.
Ejemplo n.º 2
0
    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.
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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)
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
    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)
Ejemplo n.º 9
0
 def __init__(self, data, *args):
     Delegator.__init__(self, *args)
     self.__dict__['Info'] = self._handler
     str.__init__(data)
Ejemplo n.º 10
0
 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()
Ejemplo n.º 11
0
 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()
Ejemplo n.º 12
0
 def __init__(self, data, *args):
     Delegator.__init__(self, *args)
     self.__dict__['Info'] = self._handler
     str.__init__(data)