Exemplo n.º 1
0
    def test_model(self):
        """PDBDope test final model"""
        from biskit import PDBModel

        if self.local:
            print('\nData added to info record of model (key -- value):')
            for k in list(self.d.m.info.keys()):
                print('%s -- %s' % (k, self.d.m.info[k]))

            print('\nAdded atom profiles:')
            print(self.M.atoms)

            print('\nAdded residue  profiles:')
            print(self.M.residues)

            ## check that nothing has changed
            print('\nChecking that models are unchanged by doping ...')

        m_ref = PDBModel(self.f)
        m_ref = m_ref.compress(m_ref.maskProtein())
        for k in list(m_ref.atoms.keys()):
            #ref = [ m_ref.atoms[i][k] for i in m_ref.atomRange() ]
            #mod = [ self.M.atoms[i][k] for i in self.M.atomRange() ]
            self.assertTrue(N.all(m_ref[k] == self.M[k]))

        ## display in Pymol
        if self.local:
            print("Starting PyMol...")
            from biskit.exe.pymoler import Pymoler

            pm = Pymoler()
            pm.addPdb(self.M, 'm')
            pm.colorAtoms('m', N0.clip(self.M.profile('relAS'), 0.0, 100.0))
            pm.show()
Exemplo n.º 2
0
    def test_model(self):
        """PDBDope test final model"""
        from biskit import PDBModel

        if self.local:
            print('\nData added to info record of model (key -- value):')
            for k in list(self.d.m.info.keys()):
                print('%s -- %s'%(k, self.d.m.info[k]))

            print('\nAdded atom profiles:')
            print(self.M.atoms)

            print('\nAdded residue  profiles:')
            print(self.M.residues)

            ## check that nothing has changed
            print('\nChecking that models are unchanged by doping ...')

        m_ref = PDBModel( self.f )
        m_ref = m_ref.compress( m_ref.maskProtein() )
        for k in list(m_ref.atoms.keys()):
            #ref = [ m_ref.atoms[i][k] for i in m_ref.atomRange() ]
            #mod = [ self.M.atoms[i][k] for i in self.M.atomRange() ]
            self.assertTrue( N.all( m_ref[k] == self.M[k]) )

        ## display in Pymol
        if self.local:
            print("Starting PyMol...")
            from biskit.exe.pymoler import Pymoler

            pm = Pymoler()
            pm.addPdb( self.M, 'm' )
            pm.colorAtoms( 'm', N0.clip(self.M.profile('relAS'), 0.0, 100.0) )
            pm.show()
Exemplo n.º 3
0
    def fractionNativeSurface(self, cont, contRef ):
        """
        fraction of atoms/residues that are involved in B{any} contacts
        in both complexes.

        @param cont: contact matrix
        @type  cont: matrix
        @param contRef: reference contact matrix
        @type  contRef: matrix
        
        @return: (fractRec, fractLig), fraction of atoms/residues that
                  are involved in any contacts in both complexes
        @rtype: (float, float)
           
        """
        lig, ligRef = N0.clip( N0.sum(cont),0,1),  N0.clip( N0.sum(contRef), 0,1)
        rec    = N0.clip( N0.sum(cont, 1),0,1)
        recRef = N0.clip( N0.sum(contRef, 1), 0,1)

        fLig = N0.sum( N0.logical_and( lig, ligRef )) *1./ N0.sum( ligRef )
        fRec = N0.sum( N0.logical_and( rec, recRef )) *1./ N0.sum( recRef )

        return (fRec, fLig)
Exemplo n.º 4
0
    def __test_conservation(self):
        """PDBDope.addConservation (Hmmer) test"""
        if self.local: print("Adding conservation data...", end=' ')
        self.d.addConservation()
        if self.local: print('Done.')

        ## display in Pymol
        if self.local:
            print("Starting PyMol...")
            from biskit.exe.pymoler import Pymoler

            pm = Pymoler()
            pm.addPdb( self.M, 'm' )
            pm.colorAtoms( 'm', N0.clip(self.M.profile('cons_ent'), 0.0, 100.0) )
            pm.show()
Exemplo n.º 5
0
    def fractionNativeSurface(self, cont, contRef):
        """
        fraction of atoms/residues that are involved in B{any} contacts
        in both complexes.

        @param cont: contact matrix
        @type  cont: matrix
        @param contRef: reference contact matrix
        @type  contRef: matrix
        
        @return: (fractRec, fractLig), fraction of atoms/residues that
                  are involved in any contacts in both complexes
        @rtype: (float, float)
           
        """
        lig, ligRef = N0.clip(N0.sum(cont), 0,
                              1), N0.clip(N0.sum(contRef), 0, 1)
        rec = N0.clip(N0.sum(cont, 1), 0, 1)
        recRef = N0.clip(N0.sum(contRef, 1), 0, 1)

        fLig = N0.sum(N0.logical_and(lig, ligRef)) * 1. / N0.sum(ligRef)
        fRec = N0.sum(N0.logical_and(rec, recRef)) * 1. / N0.sum(recRef)

        return (fRec, fLig)
Exemplo n.º 6
0
    def __test_conservation(self):
        """PDBDope.addConservation (Hmmer) test"""
        if self.local: print("Adding conservation data...", end=' ')
        self.d.addConservation()
        if self.local: print('Done.')

        ## display in Pymol
        if self.local:
            print("Starting PyMol...")
            from biskit.exe.pymoler import Pymoler

            pm = Pymoler()
            pm.addPdb(self.M, 'm')
            pm.colorAtoms('m', N0.clip(self.M.profile('cons_ent'), 0.0, 100.0))
            pm.show()
Exemplo n.º 7
0
def relExposure( model, absSurf, key='AS', clip=1 ):
    """
    Calculate how exposed an atom is relative to the same
    atom in a GLY-XXX-GLY tripeptide, an approximation of
    the unfolded state.

    @param absSurf: Absolute MS OR AS values
    @type  absSurf: [float]
    @param key: MS or AS
    @type  key: MS|AS
    @param clip: clip values above 100% (default: 1)
    @type  clip: 1|0
    
    @return: rel - list of relative accessible surfaces
    @rtype: [float]
    """
    if not key=='MS' and not key=='AS':
        raise Exception('Incorrect key for relative exposiure: %s '%key)

    rel = []
    i=0

    ## loop over chains
    for j in range( model.lenChains()):
        c = model.takeChains([j])

        k=0
        cIdx = c.resIndex()
        ## and loop over atoms in chain
        for a in c.atoms.iterDicts():
            ## N-terminal residue
            if k < cIdx[1]:
                rel = __Nter( a, rel, absSurf, key, i )
            ## C-terminal residue
            if k >= cIdx[-1]:
                rel = __Cter( a, rel, absSurf, key, i )
            ## everything but N- and C termini
            if not k < cIdx[1] and not k >= cIdx[-1]:
                rel = __bulk( a, rel, absSurf, key, i )
            i+=1
            k+=1

    if clip:
        return  N0.clip( N0.array(rel), 0.0, 100.0 )
    else:
        return  N0.array(rel)
Exemplo n.º 8
0
def relExposure(model, absSurf, key='AS', clip=1):
    """
    Calculate how exposed an atom is relative to the same
    atom in a GLY-XXX-GLY tripeptide, an approximation of
    the unfolded state.

    @param absSurf: Absolute MS OR AS values
    @type  absSurf: [float]
    @param key: MS or AS
    @type  key: MS|AS
    @param clip: clip values above 100% (default: 1)
    @type  clip: 1|0
    
    @return: rel - list of relative accessible surfaces
    @rtype: [float]
    """
    if not key == 'MS' and not key == 'AS':
        raise Exception('Incorrect key for relative exposiure: %s ' % key)

    rel = []
    i = 0

    ## loop over chains
    for j in range(model.lenChains()):
        c = model.takeChains([j])

        k = 0
        cIdx = c.resIndex()
        ## and loop over atoms in chain
        for a in c.atoms.iterDicts():
            ## N-terminal residue
            if k < cIdx[1]:
                rel = __Nter(a, rel, absSurf, key, i)
            ## C-terminal residue
            if k >= cIdx[-1]:
                rel = __Cter(a, rel, absSurf, key, i)
            ## everything but N- and C termini
            if not k < cIdx[1] and not k >= cIdx[-1]:
                rel = __bulk(a, rel, absSurf, key, i)
            i += 1
            k += 1

    if clip:
        return N0.clip(N0.array(rel), 0.0, 100.0)
    else:
        return N0.array(rel)
Exemplo n.º 9
0
 def calc_membership_matrix(self, d2):
     ## remove 0s (if a cluster center is exactly on one item)
     d2 = N0.clip(d2, N0.power(1e200, 1 - self.w), 1e300)
     q = N0.power(d2, 1. / (1. - self.w))
     return q / N0.sum(q)
Exemplo n.º 10
0
 def calc_membership_matrix(self, d2):
     ## remove 0s (if a cluster center is exactly on one item)
     d2 = N0.clip( d2, N0.power(1e200, 1-self.w), 1e300 )
     q = N0.power(d2, 1. / (1. - self.w))
     return q / N0.sum(q)