Beispiel #1
0
    def random_complex(self, inp_mirror=None):
        """
        @return: randomized and minimized complex
        @rtype: Complex
        """
        self.cm = ComplexMinimizer(self.random_complex_remote(),
                                   debug=self.debug)
        self.cm.run(inp_mirror=inp_mirror)

        com = Complex(self.rec, self.lig)

        rt = com.extractLigandMatrix(self.cm.lig)
        com.setLigMatrix(rt)

        return com
Beispiel #2
0
    def random_complex( self, inp_mirror=None ):
        """
        @return: randomized and minimized complex
        @rtype: Complex
        """
        self.cm = ComplexMinimizer( self.random_complex_remote(),
                                    debug=self.debug )
        self.cm.run( inp_mirror=inp_mirror )

        com = Complex( self.rec, self.lig )

        rt = com.extractLigandMatrix( self.cm.lig )
        com.setLigMatrix( rt )

        return com
Beispiel #3
0
    def random_complex_remote(self):
        """
        Create a complex where the recrptor and ligand have random
        orientations but are spaced within contact distance.

        @return: rec & lig spaced r_rec + r_lig apart in random orientation
        @rtype: Complex
        """
        return Complex(self.rec, self.lig, ligMatrix=self.__random_matrix())
Beispiel #4
0
    def prepareRef(self, fname):
        """
        Prepare reference model.
        
        @param fname: file name 
        @type  fname: str

        @return: reference structure
        @rtype: PDBModel|Complex        

        @raise EntropistError: if unknown reference type
        """
        if not fname:
            return None

        if self.__splitFilenames(fname):
            f1, f2 = self.__splitFilenames(fname)
            m1, m2 = PDBModel( self.__getModel(f1) ), \
                     PDBModel( self.__getModel(f2) )

            ref = Complex(m1, m2)
        else:
            ref = t.load(fname)

        if isinstance(ref, Trajectory):
            ref = ref.ref

        if isinstance(ref, PDBModel):
            return self.__cleanAtoms(ref)

        if isinstance(ref, Complex):
            self.__cleanAtoms(ref.rec_model)
            self.__cleanAtoms(ref.lig_model)
            ref.lig_model_transformed = None
            return ref

        raise EntropistError, 'unknown reference type'
Beispiel #5
0
    def prepareRef( self, fname ):
        """
        Prepare reference model.
        
        @param fname: file name 
        @type  fname: str

        @return: reference structure
        @rtype: PDBModel|Complex        

        @raise EntropistError: if unknown reference type
        """
        if not fname:
            return None

        if self.__splitFilenames( fname ):
            f1, f2 = self.__splitFilenames( fname )
            m1, m2 = PDBModel( self.__getModel(f1) ), \
                     PDBModel( self.__getModel(f2) )

            ref = Complex( m1, m2 )
        else:
            ref = t.load( fname )

        if isinstance( ref, Trajectory ):
            ref = ref.ref

        if isinstance( ref, PDBModel ):
            return self.__cleanAtoms( ref )

        if isinstance( ref, Complex ):
            self.__cleanAtoms( ref.rec_model )
            self.__cleanAtoms( ref.lig_model )
            ref.lig_model_transformed = None
            return ref

        raise EntropistError, 'unknown reference type'
Beispiel #6
0
    def prepareTraj(self, fname, ref=None, cast=1):
        """
        Prepare trajectory for Amber.

        @param fname: path to EnsembleTraj OR ( EnsembleTraj, EnsembleTraj )
        @type  fname: str OR (str,str)
        @param ref: reference structure
        @type  ref: EnsembleTraj
        @param cast: cast to reference (same atom content) (default: 1)
        @type  cast: 1|0

        @return: split, fitted or shuffled, etc. trajectory instance
        @rtype: EnsembleTraj OR (EnsembleTraj, EnsembleTraj )
        """
        ## Load 1 or 2
        if self.__splitFilenames(fname):
            f1, f2 = self.__splitFilenames(fname)
            t = self.loadTraj(f1), self.loadTraj(f2)
        else:
            t = self.loadTraj(fname)
            if self.chains:
                t = t.takeChains(self.chains)

        ## split 1 into 2 if necessary
        if not type(t) is tuple and self.border:
            lig = range(self.border, t.ref.lenChains())
            t = t.takeChains(range(self.border)), t.takeChains(lig)

        ## check 2 trajectories were suplied
        if not type(t) is tuple and (self.shift or self.shuffle or self.split):
            raise EntropistError, 'split,shift,shuffle require -border.'

        ## adapt reference to type of trajectory input
        if ref and type(t) is tuple and not isinstance(ref, Complex):
            rec = ref.takeChains(range(t[0].ref.lenChains()))
            lig = ref.takeChains(
                range(t[0].ref.lenChains(), t[1].ref.lenChains()))
            ref = Complex(rec, lig)

        if ref and type(t) is not tuple and isinstance(ref, Complex):
            ref = ref.rec_model.concat(ref.lig())

        ## remove member trajectories (if requested)
        t = self.__removeMembers(t)

        ## cast 1 or 2
        if cast and type(t) is not tuple:
            self.castTraj(t, ref)

        if cast and type(t) is tuple:
            self.castTraj(t[0], ref.rec_model)
            self.castTraj(t[1], ref.lig_model)

        ## reorder one half (requires -border or file name pair )
        if self.shift:
            t = self.shiftTraj(t[0], self.shift), t[1]

        if self.shuffle:
            t = self.shuffleTraj(t[0]), self.shuffleTraj(t[1])

        ## fit seperately (requires -border or file name pair)
        if self.split and ref:
            self.fit(t[0], ref.rec())
            self.fit(t[1], ref.lig())
        if self.split and not ref:
            self.fit(t[0])
            self.fit(t[1])

        if type(t) is tuple:
            t = t[0].concatAtoms(t[1])
            ref = ref.rec_model.concat(ref.lig())

        ## joint fit
        if not self.split:
            self.fit(t, ref)

        if self.verbose:
            self.log.add( 'Analysing trajectory with %i atoms and %i frames.' \
                          % (t.lenAtoms(), t.lenFrames()))

        return t
Beispiel #7
0
    
cName = nameFromPath( cFile )
outName = outDir + '/' + cName + '_model-CAD.txt'
outName_over = outDir + '/' + cName + '_model-CAD_overwiev.txt'

## load
flushPrint('Loading complex list \n')
cList = load( options['cl'] )
flushPrint('Loading bound complex \n')
ref_com = load( options['ref'] )

## get models
rec_models, lig_models, rec_b_ref, lig_b_ref = get_models( cList, ref_com )

## contacts
ref_com_b_cast = ProteinComplex( rec_b_ref, lig_b_ref )
ref_b_resCont = ref_com_b_cast.resContacts()

rec_aContacts = rec_b_ref.res2atomMask( sum( ref_b_resCont, 1 ) )
lig_aContacts = lig_b_ref.res2atomMask( sum( ref_b_resCont, 0 ) )

## get pw_rmsds
rec_rmsd_cont = pw_rmsd( rec_models, rec_b_ref, rec_aContacts )
lig_rmsd_cont = pw_rmsd( lig_models, lig_b_ref, lig_aContacts )

rec_rmsd_bb = pw_rmsd( rec_models, rec_b_ref, rec_b_ref.maskBB() )
lig_rmsd_bb = pw_rmsd( lig_models, lig_b_ref, lig_b_ref.maskBB() )

## get pw cad
rec_cad = pw_cad(  rec_models, rec_b_ref, rec_aContacts )
lig_cad = pw_cad(  lig_models, lig_b_ref, lig_aContacts )
Beispiel #8
0
cName = nameFromPath(cFile)
outName = outDir + '/' + cName + '_model-CAD.txt'
outName_over = outDir + '/' + cName + '_model-CAD_overwiev.txt'

## load
flushPrint('Loading complex list \n')
cList = load(options['cl'])
flushPrint('Loading bound complex \n')
ref_com = load(options['ref'])

## get models
rec_models, lig_models, rec_b_ref, lig_b_ref = get_models(cList, ref_com)

## contacts
ref_com_b_cast = ProteinComplex(rec_b_ref, lig_b_ref)
ref_b_resCont = ref_com_b_cast.resContacts()

rec_aContacts = rec_b_ref.res2atomMask(sum(ref_b_resCont, 1))
lig_aContacts = lig_b_ref.res2atomMask(sum(ref_b_resCont, 0))

## get pw_rmsds
rec_rmsd_cont = pw_rmsd(rec_models, rec_b_ref, rec_aContacts)
lig_rmsd_cont = pw_rmsd(lig_models, lig_b_ref, lig_aContacts)

rec_rmsd_bb = pw_rmsd(rec_models, rec_b_ref, rec_b_ref.maskBB())
lig_rmsd_bb = pw_rmsd(lig_models, lig_b_ref, lig_b_ref.maskBB())

## get pw cad
rec_cad = pw_cad(rec_models, rec_b_ref, rec_aContacts)
lig_cad = pw_cad(lig_models, lig_b_ref, lig_aContacts)
Beispiel #9
0
    def prepareTraj( self, fname, ref=None, cast=1 ):
        """
        Prepare trajectory for Amber.

        @param fname: path to EnsembleTraj OR ( EnsembleTraj, EnsembleTraj )
        @type  fname: str OR (str,str)
        @param ref: reference structure
        @type  ref: EnsembleTraj
        @param cast: cast to reference (same atom content) (default: 1)
        @type  cast: 1|0

        @return: split, fitted or shuffled, etc. trajectory instance
        @rtype: EnsembleTraj OR (EnsembleTraj, EnsembleTraj )
        """
        ## Load 1 or 2
        if self.__splitFilenames( fname ):
            f1, f2 = self.__splitFilenames( fname )
            t = self.loadTraj( f1 ), self.loadTraj( f2 )
        else:
            t = self.loadTraj( fname )
            if self.chains:
                t = t.takeChains( self.chains )

        ## split 1 into 2 if necessary
        if not type(t) is tuple and self.border:
            lig = range( self.border, t.ref.lenChains() )
            t = t.takeChains( range(self.border) ), t.takeChains( lig )

        ## check 2 trajectories were suplied
        if not type(t) is tuple and (self.shift or self.shuffle or self.split):
            raise EntropistError,'split,shift,shuffle require -border.'

        ## adapt reference to type of trajectory input 
        if ref and type(t) is tuple and not isinstance( ref, Complex ):
            rec = ref.takeChains( range(t[0].ref.lenChains()) )
            lig = ref.takeChains( range(t[0].ref.lenChains(),
                                        t[1].ref.lenChains()) )
            ref = Complex( rec, lig )

        if ref and type(t) is not tuple and isinstance( ref, Complex ):
            ref = ref.rec_model.concat( ref.lig() )

        ## remove member trajectories (if requested)
        t = self.__removeMembers( t )

        ## cast 1 or 2
        if cast and type( t ) is not tuple:
            self.castTraj( t, ref )

        if cast and type( t ) is tuple:
            self.castTraj( t[0], ref.rec_model )
            self.castTraj( t[1], ref.lig_model )

        ## reorder one half (requires -border or file name pair )
        if self.shift:
            t = self.shiftTraj( t[0], self.shift ), t[1]

        if self.shuffle:
            t = self.shuffleTraj( t[0] ), self.shuffleTraj( t[1] )

        ## fit seperately (requires -border or file name pair)
        if self.split and ref:
            self.fit( t[0], ref.rec() )
            self.fit( t[1], ref.lig() )
        if self.split and not ref:
            self.fit( t[0] )
            self.fit( t[1] )

        if type( t ) is tuple:
            t = t[0].concatAtoms( t[1] )
            ref = ref.rec_model.concat( ref.lig() )

        ## joint fit
        if not self.split:
            self.fit( t, ref )
            
        if self.verbose:
            self.log.add( 'Analysing trajectory with %i atoms and %i frames.' \
                          % (t.lenAtoms(), t.lenFrames()))

        return t