Пример #1
0
    def charge(self, model):
        """
        Assign atom charges to given model
        @param model: input structure
        @type  model: PDBModel
        """
        q = N.array([], float)

        for j, res in enumerate(model.resModels()):
            refres = self.lookupResidue(res)

            if refres is None:
                if self.verbose:
                    self.log.add('Warning: no residue type for '+\
                                  self.__resinfo(res,j) +\
                                 '\nWhole residue will be set to charge 0.')
                refres = res
                refres['partial_charge'] = N.zeros(len(refres))

            iref, i = refres.compareAtoms(res)

            qres = N.take(refres['partial_charge'], iref)

            if len(iref) < len(refres):
                if self.verbose:
                    self.log.add('Warning: %i atoms missing from residue %s:'%\
                             (len(refres)-len(iref), self.__resinfo(res,j)) )

                    missing = MA.difference(range(len(refres)), iref)
                    self.log.add('\t' + str(N.take(refres['name'], missing)))
                    self.log.add(
                        '\tIgnored. Residue will have incomplete charge.')

            if len(i) < len(res):
                if self.verbose:
                    self.log.add('Warning: %i unknown  atoms in residue %s:' %\
                             (len(res)-len(i), self.__resinfo(res,j)) )

                    missing = MA.difference(range(len(res)), i)
                    self.log.add('\t' + str(N.take(res['name'], missing)))
                    self.log.add(
                        '\tGiving up. Whole residue will be set to charge 0.')

                qres = N.zeros(len(res))

##            assert len(qres) == len(res), 'missmatch of atom number'

            q = N.concatenate((q, qres))

        assert len(q) == len(model), 'AtomCharger: missing charge records'
        model['partial_charge'] = q
Пример #2
0
    def charge(self, model):
        """
        Assign atom charges to given model
        @param model: input structure
        @type  model: PDBModel
        """
        q = N.array( [], float )
        
        for j,res in enumerate(model.resModels()):
            refres = self.lookupResidue( res )

            if refres is None:
                if self.verbose:
                    self.log.add('Warning: no residue type for '+\
                                  self.__resinfo(res,j) +\
                                 '\nWhole residue will be set to charge 0.')
                refres = res
                refres['partial_charge'] = N.zeros( len(refres) )
            
            iref, i = refres.compareAtoms( res )
            
            qres = N.take( refres['partial_charge'], iref )
            
            if len(iref) < len(refres):
                if self.verbose:
                    self.log.add('Warning: %i atoms missing from residue %s:'%\
                             (len(refres)-len(iref), self.__resinfo(res,j)) )
                    
                    missing = MA.difference( range(len(refres)), iref )
                    self.log.add('\t'+str(N.take( refres['name'], missing )) )
                    self.log.add(
                        '\tIgnored. Residue will have incomplete charge.')
                         
            if len(i) < len( res ):
                if self.verbose:
                    self.log.add('Warning: %i unknown  atoms in residue %s:' %\
                             (len(res)-len(i), self.__resinfo(res,j)) )
    
                    missing = MA.difference( range(len(res)), i )
                    self.log.add('\t'+str(N.take( res['name'], missing )) )
                    self.log.add('\tGiving up. Whole residue will be set to charge 0.')

                qres = N.zeros( len(res) )
                
##            assert len(qres) == len(res), 'missmatch of atom number'
            
            q = N.concatenate( (q, qres ) )
        
        assert len(q) == len(model), 'AtomCharger: missing charge records'
        model['partial_charge'] = q
Пример #3
0
    def processTrajs( self ):
        """
        Extract reference model and member trajectories from rec, lig, and
        com trajectories. Identify outlier member trajectories, if requested.
        """
        ## free rec
        self.ref_frec = self.nameRef( self.rec )

        t, self.ex_frec, self.members_frec = self.loadTraj(
            self.rec, self.ex_frec, self.ref_frec )

        n_rec_members = t.n_members
        self.cr       = self.cr or range( t.ref.lenChains( breaks=0 ) )
        del t

        ## free lig
        self.ref_flig = self.nameRef( self.lig )

        t, self.ex_flig, self.members_flig = self.loadTraj(
            self.lig, self.ex_flig, self.ref_flig )

        n_lig_members = t.n_members
        del t

        ## complex
        fname = T.stripSuffix( T.absfile( self.com, resolveLinks=0 ) )
        self.ref_com = fname + '_ref.complex'
        self.ref_blig= fname + '_blig.model'
        self.ref_brec= fname + '_brec.model'

        t, self.ex_com, self.members_com = self.loadTraj(
            self.com, self.ex_com  )

        n_com_members = t.n_members

        self.cl = self.cl or MU.difference( range(t.ref.lenChains()), self.cr)
        rec = t.ref.takeChains( self.cr, breaks=0 )
        lig = t.ref.takeChains( self.cl, breaks=0 )

        del t
        self.dumpMissing( Complex( rec, lig ), self.ref_com )
        self.dumpMissing( rec, self.ref_brec )
        self.dumpMissing( lig, self.ref_blig )

        self.equalizeMemberCount( n_rec_members, n_lig_members, n_com_members )

        if self.jack:  self.prepareJackknife()
Пример #4
0
    def processTrajs( self ):
        """
        Extract reference model and member trajectories from rec, lig, and
        com trajectories. Identify outlier member trajectories, if requested.
        """
        ## free rec
        self.ref_frec = self.nameRef( self.rec )

        t, self.ex_frec, self.members_frec = self.loadTraj(
            self.rec, self.ex_frec, self.ref_frec )

        n_rec_members = t.n_members
        self.cr       = self.cr or range( t.ref.lenChains( breaks=0 ) )
        del t

        ## free lig
        self.ref_flig = self.nameRef( self.lig )

        t, self.ex_flig, self.members_flig = self.loadTraj(
            self.lig, self.ex_flig, self.ref_flig )

        n_lig_members = t.n_members
        del t

        ## complex
        fname = T.stripSuffix( T.absfile( self.com, resolveLinks=0 ) )
        self.ref_com = fname + '_ref.complex'
        self.ref_blig= fname + '_blig.model'
        self.ref_brec= fname + '_brec.model'

        t, self.ex_com, self.members_com = self.loadTraj(
            self.com, self.ex_com  )

        n_com_members = t.n_members

        self.cl = self.cl or MU.difference( range(t.ref.lenChains()), self.cr)
        rec = t.ref.takeChains( self.cr, breaks=0 )
        lig = t.ref.takeChains( self.cl, breaks=0 )

        del t
        self.dumpMissing( Complex( rec, lig ), self.ref_com )
        self.dumpMissing( rec, self.ref_brec )
        self.dumpMissing( lig, self.ref_blig )

        self.equalizeMemberCount( n_rec_members, n_lig_members, n_com_members )

        if self.jack:  self.prepareJackknife()
Пример #5
0
    def __add1(self, n_members, excluded, index):
        """
        Add one number from range( n_members ) to list of excluded indices

        @param n_members: number of member trajectories
        @type  n_members: int
        @param excluded: excluded member trajectories
        @type  excluded: [ int ]
        @param index: 
        @type  index: int

        @return: the indices of all excluded member trajectories
        @rtype: [ int ]
        """
        remaining = MU.difference(range(n_members), excluded)
        new_i = remaining[index]
        return excluded + [new_i]
Пример #6
0
    def __add1( self, n_members, excluded, index ):
        """
        Add one number from range( n_members ) to list of excluded indices

        @param n_members: number of member trajectories
        @type  n_members: int
        @param excluded: excluded member trajectories
        @type  excluded: [ int ]
        @param index: 
        @type  index: int

        @return: the indices of all excluded member trajectories
        @rtype: [ int ]
        """
        remaining = MU.difference( range( n_members ), excluded )
        new_i = remaining[index]
        return excluded + [ new_i ]
Пример #7
0
    def __exclude(self, traj, exclude):
        """
        Exclude members from a (set of) Trajectory.
        @param traj: input trajectory
        @type traj: EnsembleTraj
        @param exclude: set of indices to be excluded
        @type exclude: [ int ]

        @return: 
        @rtype: EnsembleTraj
        """
        if exclude == None or len(exclude) == 0:
            return traj

        members = range(traj.n_members)

        if self.verbose:
            self.log.add("excluding members: " + str(exclude))

        return traj.takeMembers(MU.difference(members, exclude))
Пример #8
0
    def __add3(self, n_members, excluded, trippleIndex):
        """
        Add a tripple of numbers from range( n_members ) to be
        excluded for error estimation. Tripples are chosen to have
        minimal overlap. For 10 trajectories (*n_members*=10), the
        first 3 tripples will be (1,2,3), (4,5,6), (7,8,9).

        @param n_members: number of member trajectories
        @type  n_members: int
        @param excluded: excluded member trajectories
        @type  excluded: [ int ]
        @param trippleIndex: 
        @type  trippleIndex: int

        @return: the indices of all excluded member trajectories
        @rtype: [ int ]
        """
        remaining = MU.difference(range(n_members), excluded)
        tripple = self.tripples(remaining, trippleIndex + 1)[-1]
        return MU.union(excluded, list(tripple))
Пример #9
0
    def __exclude( self, traj, exclude ):
        """
        Exclude members from a (set of) Trajectory.
        @param traj: input trajectory
        @type traj: EnsembleTraj
        @param exclude: set of indices to be excluded
        @type exclude: [ int ]

        @return: 
        @rtype: EnsembleTraj
        """
        if exclude == None or len( exclude ) == 0:
            return traj

        members = range( traj.n_members )

        if self.verbose:
            self.log.add("excluding members: " + str(exclude))

        return traj.takeMembers( MU.difference( members, exclude ) )
Пример #10
0
    def __add3( self, n_members, excluded, trippleIndex ):
        """
        Add a tripple of numbers from range( n_members ) to be
        excluded for error estimation. Tripples are chosen to have
        minimal overlap. For 10 trajectories (*n_members*=10), the
        first 3 tripples will be (1,2,3), (4,5,6), (7,8,9).

        @param n_members: number of member trajectories
        @type  n_members: int
        @param excluded: excluded member trajectories
        @type  excluded: [ int ]
        @param trippleIndex: 
        @type  trippleIndex: int

        @return: the indices of all excluded member trajectories
        @rtype: [ int ]
        """
        remaining = MU.difference( range( n_members ), excluded )
        tripple = self.tripples( remaining, trippleIndex+1 )[-1]
        return MU.union( excluded, list(tripple) )
Пример #11
0
    print "                  -h |host1 host2 host3 ..| -e |host4 host5 ..|]"
    print "        -n ... search phrase"
    print "        -a ... kill all without asking"
    print "        -f ... don't ask anything at all"
    print "        -h ... only look on these hosts  (default: all)"
    print "        -e ... exclude one or more hosts from killing"
    sys.exit(0)

o = cmdDict({'h': nodes_all})
phrase = o['n']
hosts = toList(o['h'])
user = getpass.getuser()
ask = 'a' not in o
force = 'f' in o
if 'e' in o:
    hosts = MU.difference(hosts, toList(o['e']))

msg = "KILL All jobs matching '%s' on all hosts?? Y/N " % phrase

if (not ask) and (force or string.upper(raw_input(msg)) != 'Y'):
    print "Aborted."
    sys.exit()

for h in hosts:
    try:
        kill(h, phrase, user, ask)
    except KeyboardInterrupt:
        print "\nAborted."
        sys.exit()
    except Exception, why:
        print "Error killing %s: " % str(why), lastError()
Пример #12
0
    print "                  -h |host1 host2 host3 ..| -e |host4 host5 ..|]"
    print "        -n ... search phrase"
    print "        -a ... kill all without asking"
    print "        -f ... don't ask anything at all"
    print "        -h ... only look on these hosts  (default: all)"
    print "        -e ... exclude one or more hosts from killing"
    sys.exit(0)

o = cmdDict( { 'h':nodes_all } )
phrase = o['n']
hosts  = toList( o['h'] )
user = getpass.getuser()
ask  = 'a' not in o
force= 'f' in o
if 'e' in o:
    hosts = MU.difference( hosts, toList( o['e'] ) )

msg = "KILL All jobs matching '%s' on all hosts?? Y/N " % phrase

if (not ask) and (force or string.upper( raw_input( msg ) ) != 'Y'):
    print "Aborted."
    sys.exit()

for h in hosts:
    try:
        kill( h, phrase, user, ask )
    except KeyboardInterrupt:
        print "\nAborted."
        sys.exit()
    except Exception, why:
        print "Error killing %s: " % str(why),  lastError()