Esempio n. 1
0
def data3DList(c, key='fnac_10', inverse=0, rm=range(1, 12), soln=512):
    """
    Create an matrix: len(rec_model) * len((lig_model) * solutions
    containing the values of the info dic with given key.
    c - ComplexList
    """
    rm = range(1, max(c.valuesOf('model1')) + 1)
    lm = range(1, max(c.valuesOf('model2')) + 1)

    matrix = zeros((len(rm), len(lm), soln), 'f')

    try:

        for r in rm:
            rl = c.filter('model1', r)
            for l in lm:
                cl = rl.filter('model2', l)
                if inverse:
                    matrix[r - 1][l - 1] = (
                        1. / array(cl.valuesOf(key, default=0))).tolist()
                else:
                    matrix[r - 1][l - 1] = cl.valuesOf(key, default=0)

    except ValueError, why:
        try:
            lenM = len(matrix[r - 1][l - 1])
            lenV = len(cl.valuesOf(key, default=0))
        except:
            lenM = lenV = 0
        s = '%i : %i len(matrix)=%i <> len(values)=%i' % (r, l, lenM, lenV)
        EHandler.error('Cannot extract fnac data. ' + s)
Esempio n. 2
0
    def concat( self, *traj ):
        """
        Concatenate this with other trajectories. The ref model of the
        new Trajectory is a 'semi-deep' copy of this trajectorie's model.
        (see L{PDBModel.take()} )::
           concat( traj [, traj2, traj3, ..] ) -> Trajectory 

        @param traj: one or more Trajectory with identical atoms as this one
        @type  traj: Trajectories

        @return: concatenated trajecties
        @rtype: Trajectory
        """
        if len( traj ) == 0:
            return self

        r = self.__class__()

        r.frames = N.concatenate( (self.frames, traj[0].frames), 0 )

        r.setRef( self.ref.clone())

        if self.frameNames and traj[0].frameNames:
            r.frameNames = self.frameNames + traj[0].frameNames

        try:
            if self.pc is not None and traj[0].pc is not None:
                r.pc['p'] = N.concatenate( (self.pc['p'], traj[0].pc['p']),0)
                r.pc['u'] = N.concatenate( (self.pc['u'], traj[0].pc['u']),0)
        except TypeError, why:
            EHandler.error('cannot concat PC '+str(why) )
Esempio n. 3
0
def data3DList( c, key='fnac_10', inverse=0,
                rm=range(1,12), soln=512 ):
    """
    Create an matrix: len(rec_model) * len((lig_model) * solutions
    containing the values of the info dic with given key.
    c - ComplexList
    """
    rm = range( 1, max(c.valuesOf( 'model1'))+1 )
    lm = range( 1, max(c.valuesOf( 'model2'))+1 )

    matrix = zeros( ( len( rm ), len( lm ), soln ), 'f' )
    
    try:

        for r in rm:
            rl = c.filter( 'model1', r )
            for l in lm:
                cl = rl.filter( 'model2', l )
                if inverse:
                    matrix[r-1][l-1] = (1./array(
                        cl.valuesOf( key, default=0 ))).tolist()
                else:
                    matrix[r-1][l-1] = cl.valuesOf( key, default=0 )

    except ValueError, why:
        try:
            lenM = len( matrix[r-1][l-1] )
            lenV = len( cl.valuesOf( key, default=0 ) )
        except:
            lenM = lenV = 0
        s =  '%i : %i len(matrix)=%i <> len(values)=%i' % (r, l, lenM, lenV)
        EHandler.error('Cannot extract fnac data. '+ s )
Esempio n. 4
0
    def concat(self, *traj):
        """
        Concatenate this with other trajectories. The ref model of the
        new Trajectory is a 'semi-deep' copy of this trajectorie's model.
        (see L{PDBModel.take()} )::
           concat( traj [, traj2, traj3, ..] ) -> Trajectory 

        @param traj: one or more Trajectory with identical atoms as this one
        @type  traj: Trajectories

        @return: concatenated trajecties
        @rtype: Trajectory
        """
        if len(traj) == 0:
            return self

        r = self.__class__()

        r.frames = N.concatenate((self.frames, traj[0].frames), 0)

        r.setRef(self.ref.clone())

        if self.frameNames and traj[0].frameNames:
            r.frameNames = self.frameNames + traj[0].frameNames

        try:
            if self.pc is not None and traj[0].pc is not None:
                r.pc['p'] = N.concatenate((self.pc['p'], traj[0].pc['p']), 0)
                r.pc['u'] = N.concatenate((self.pc['u'], traj[0].pc['u']), 0)
        except TypeError, why:
            EHandler.error('cannot concat PC ' + str(why))
Esempio n. 5
0
    def add(self, str):
        """
        Add String str and line break to xplor input file.

        @param str: string to add to file
        @type  str: str        
        """
        try:
            self.fgenerate.write(str + '\n')
        except (IOError):
            EHandler.error(
                "XPlorInput.append(): Error adding str to xplor input file.")
Esempio n. 6
0
    def add(self, str):
        """
        Add String str and line break to xplor input file.

        @param str: string to add to file
        @type  str: str        
        """
        try:
            self.fgenerate.write(str + '\n')
        except (IOError):
            EHandler.error(
                "XPlorInput.append(): Error adding str to xplor input file.")
Esempio n. 7
0
    def writePdb( self, index, fname):
        """
        Write (possibly transformed) coordinates back to pdb.

        @param index: frame index in trajectory
        @type  index: int
        @param fname: name of new file
        @type  fname: str 
        """
        try:
            self.getPDBModel( index ).writePdb( fname )
        except:
            EHandler.error('Error writing %s.' % fname)
Esempio n. 8
0
    def writePdb(self, index, fname):
        """
        Write (possibly transformed) coordinates back to pdb.

        @param index: frame index in trajectory
        @type  index: int
        @param fname: name of new file
        @type  fname: str 
        """
        try:
            self.getPDBModel(index).writePdb(fname)
        except:
            EHandler.error('Error writing %s.' % fname)
Esempio n. 9
0
## note 1: If there are more than approximately 50 sequences overall
##         t_coffe will eat all the memory and the job will not finish
##         This should be fixed in more recent versions of T-Coffee
##         (v > 3.2) where T-Coffee, according to the manual "switches
##         to a heuristic mode, named DPA, where DPA stands for Double
##         Progressive Alignment."

## note 2: If there is only one template structure step 2 of T-coffee
##         will not work. Solution, skip the structural alignment if
##         only one template structure is provided.

## note 3: In quite som cases the sequence retrieved from the nrpdb
##         sequence database is different from the sequence extracted
##         from the coordinates in the pdb-file. This will sometimes
##         cause t-coffee to terminate with an error (two sequences
##         with the same name but with different sequences). Temporary
##         solution: Choose another  structure from the same cluster
##         as the troublemaker.

try:
    a = Aligner(outFolder, log, verbose=1, sap=sap)

    a.align_for_modeller_inp()

    a.go(host)

except:
    EHandler.error('Error while building alingnments.')
    print "\nalign.py -? or align.py -help for help screen"
Esempio n. 10
0
#    searcher.localPSIBlast( target, seq_db, e=0.1, alignments=1000)

    ## local Blast
    searcher.localBlast( f_target, seq_db, 'blastp', alignments=500, e=0.0001 )

    ## cluster blast results. Defaults: simCut=1.75, lenCut=0.9, ncpu=1
    ## expects all.fasta
#    searcher.clusterFastaIterative( )
    searcher.clusterFasta() 

    searcher.writeFastaClustered()
    
    tools.flushPrint('Done.\n')
    
except:
    EHandler.error( 'Error while searching for homologues.')
    

###############
## TemplateSearcher
##
## Find modelling templates, blasting the target sequence against "tmp_db"
## Cluster the sequences and download the pdbs to templates/all

## input: target.fasta
##
## output: templates/blast.out
##         templates/all.fasta
##         templates/cluster_result.out
##         templates/nr.fasta              (input for Aligner)
##         templates/all/*.pdb
Esempio n. 11
0
if '?' in options or 'help' in options:
    _use(defaultOptions())

log = None
if options['log']:
    log = LogFile(outFolder + '/' + options['log'], 'a')

###################
## TemplateCleaner
##
## Prepare pdb files in templates/nr for T-coffee and modeller
## (replace nonstandard residues, remove hydrogens,
#    remove atoms with nultiple configurations, etc.)

## input: templates/nr/*.pdb
##        templates/nr/chain_index.txt
##
## output: templates/t_coffee/*.alpha    (input for Alignar)
##         templates/modeller/*.pdb      (input for Modeller)

try:
    cleaner = TemplateCleaner(outFolder, log)

    inp_dic = modUtils.parse_tabbed_file(chIndex)

    cleaner.process_all(inp_dic)

except:
    EHandler.error('Error while cleaning templates')
Esempio n. 12
0
##         t_coffe will eat all the memory and the job will not finish
##         This should be fixed in more recent versions of T-Coffee
##         (v > 3.2) where T-Coffee, according to the manual "switches
##         to a heuristic mode, named DPA, where DPA stands for Double
##         Progressive Alignment."
    
## note 2: If there is only one template structure step 2 of T-coffee
##         will not work. Solution, skip the structural alignment if
##         only one template structure is provided.

## note 3: In quite som cases the sequence retrieved from the nrpdb
##         sequence database is different from the sequence extracted
##         from the coordinates in the pdb-file. This will sometimes
##         cause t-coffee to terminate with an error (two sequences
##         with the same name but with different sequences). Temporary
##         solution: Choose another  structure from the same cluster
##         as the troublemaker.


try:
    a = Aligner( outFolder, log, verbose=1, sap=sap )

    a.align_for_modeller_inp()

    a.go(host)

except:
    EHandler.error( 'Error while building alingnments.')
    print "\nalign.py -? or align.py -help for help screen"

Esempio n. 13
0
##
## output: modeller/modeller.log
##                 /*.B9999000??   <- models
try:

    if options['verbose'] > 0:
        print "\n"+\
              "Type model.py -? or model.py -help for a full list of options!"

    m8 = M(**options)

    if not 'dry' in options:
        r = m8.run()  ## comment out for testing

except:
    EHandler.error('Error while modelling.')

#####################
## Show output

## show result in PyMol
if options.has_key('s'):
    names = []

    ## fit backbone of all models to average until convergence
    models = glob.glob('%s/target.B*' % (m8.outFolder + m8.F_RESULT_FOLDER))
    traj = Trajectory(models)
    traj.blockFit2ref(mask=traj[0].maskBB())

    ## calculate and print rmsd matrix
    rmsHeavy = traj.pairwiseRmsd()
Esempio n. 14
0
if '?' in options or 'help' in options:
    _use( defaultOptions() )

log = None
if options['log']:
    log = LogFile( outFolder + '/' + options['log'], 'a' ) 

###################
## TemplateCleaner
##
## Prepare pdb files in templates/nr for T-coffee and modeller
## (replace nonstandard residues, remove hydrogens,
#    remove atoms with nultiple configurations, etc.)

## input: templates/nr/*.pdb
##        templates/nr/chain_index.txt
##
## output: templates/t_coffee/*.alpha    (input for Alignar)
##         templates/modeller/*.pdb      (input for Modeller)

try:
    cleaner = TemplateCleaner( outFolder, log )

    inp_dic = modUtils.parse_tabbed_file( chIndex )

    cleaner.process_all( inp_dic )

except:
    EHandler.error( 'Error while cleaning templates')

Esempio n. 15
0
    #    searcher.localPSIBlast( target, seq_db, e=0.1, alignments=1000)

    ## local Blast
    searcher.localBlast(f_target, seq_db, 'blastp', alignments=500, e=0.0001)

    ## cluster blast results. Defaults: simCut=1.75, lenCut=0.9, ncpu=1
    ## expects all.fasta
    #    searcher.clusterFastaIterative( )
    searcher.clusterFasta()

    searcher.writeFastaClustered()

    tools.flushPrint('Done.\n')

except:
    EHandler.error('Error while searching for homologues.')

###############
## TemplateSearcher
##
## Find modelling templates, blasting the target sequence against "tmp_db"
## Cluster the sequences and download the pdbs to templates/all

## input: target.fasta
##
## output: templates/blast.out
##         templates/all.fasta
##         templates/cluster_result.out
##         templates/nr.fasta              (input for Aligner)
##         templates/all/*.pdb
##         templates/nr/chain_index.txt    (input for TemplateCleaner)
Esempio n. 16
0
    def concatEnsembles(self, *traj):
        """
        Concatenate this with other trajectories in a zig zac manner,
        resulting in an ensembleTraj with additional members.
        The ref model of the new Trajectory is a 'semi-deep' copy of this
        trajectorie's model.(see L{PDBModel.take()} )::
          concat( traj [, traj2, traj3, ..] ) -> Trajectory
        
        @param traj: with identical atoms as this one
        @type  traj: one or more EnsembleTrajectory

        @todo: fix so that pc, and profiles are not lost
        """
        if len(traj) == 0:
            return self

        r = self.__class__(n_members=self.n_members + traj[0].n_members)

        min_members = min(self.n_members, traj[0].n_members)
        min_frames = min(self.lenFrames(), traj[0].lenFrames())

        steps = self.lenFrames()/self.n_members + \
                traj[0].lenFrames()/traj[0].n_members

        def __everyOther(traj_0, traj_1, list_0, list_1, minMembers, minFrames,
                         loops):
            result = []
            for j in range(0, minMembers / 2):

                for i in range(j * loops,
                               j * loops + minFrames * 2 / minMembers):
                    result += [list_0[i]]
                    result += [list_1[i]]

                while i < j * traj_0.n_members:
                    result += [list_0[i]]

                while i < j * traj_1.n_members:
                    result += [list_1[i]]

            return result

        frames = __everyOther(self, traj[0], self.frames, traj[0].frames,
                              min_members, min_frames, steps)

        r.frames = N0.array(frames)
        r.setRef(self.ref.clone())

        if self.frameNames and traj[0].frameNames:
            r.frameNames = __everyOther(self, traj[0], self.frameNames,
                                        traj[0].frameNames, min_members,
                                        min_frames, steps)
        try:
            # NOT TESTED!!
            if self.pc and traj[0].pc:
                r.pc['p'] = __everyOther(self, traj[0], self.pc['p'],
                                         traj[0].pc['p'], min_members, steps)

                r.pc['u'] = __everyOther(self, traj[0], self.pc['u'],
                                         traj[0].pc['u'], min_members, steps)

#                r.pc['p'] = N0.concatenate( (self.pc['p'], traj[0].pc['p']),0)
#                r.pc['u'] = N0.concatenate( (self.pc['u'], traj[0].pc['u']),0)
        except TypeError, why:
            EHandler.error('cannot concat PC ' + str(why))
Esempio n. 17
0
    def concatEnsembles( self, *traj ):
        """
        Concatenate this with other trajectories in a zig zac manner,
        resulting in an ensembleTraj with additional members.
        The ref model of the new Trajectory is a 'semi-deep' copy of this
        trajectorie's model.(see L{PDBModel.take()} )::
          concat( traj [, traj2, traj3, ..] ) -> Trajectory
        
        @param traj: with identical atoms as this one
        @type  traj: one or more EnsembleTrajectory

        @todo: fix so that pc, and profiles are not lost
        """
        if len( traj ) == 0:
            return self

        r = self.__class__( n_members = self.n_members + traj[0].n_members )

        min_members = min( self.n_members, traj[0].n_members )
        min_frames = min( self.lenFrames(), traj[0].lenFrames() )

        steps = self.lenFrames()/self.n_members + \
                traj[0].lenFrames()/traj[0].n_members

        def __everyOther( traj_0, traj_1, list_0, list_1, minMembers,
                          minFrames, loops ):
            result = []
            for j in range( 0, minMembers/2 ):

                for i in range( j*loops , j*loops + minFrames*2/minMembers ):
                    result += [ list_0[i] ]
                    result += [ list_1[i] ]

                while i < j*traj_0.n_members:
                    result += [ list_0[i] ]

                while i < j*traj_1.n_members:
                    result += [ list_1[i] ]

            return result

        frames = __everyOther( self, traj[0], self.frames,
                               traj[0].frames, min_members,
                               min_frames, steps )

        r.frames = N.array(frames) 
        r.setRef( self.ref.clone())

        if self.frameNames and traj[0].frameNames:
            r.frameNames =  __everyOther( self, traj[0], self.frameNames,
                                          traj[0].frameNames, min_members,
                                          min_frames, steps )
        try:
            # NOT TESTED!!
            if self.pc and traj[0].pc:
                r.pc['p'] =  __everyOther( self, traj[0], self.pc['p'],
                               traj[0].pc['p'], min_members, steps )

                r.pc['u'] =  __everyOther( self, traj[0], self.pc['u'],
                               traj[0].pc['u'], min_members, steps )

#                r.pc['p'] = N.concatenate( (self.pc['p'], traj[0].pc['p']),0)
#                r.pc['u'] = N.concatenate( (self.pc['u'], traj[0].pc['u']),0)
        except TypeError, why:
            EHandler.error('cannot concat PC '+str(why) )