Esempio n. 1
0
    def test_TrajCluster(self):
        """TrajCluster test"""
        from Biskit.EnsembleTraj import traj2ensemble

        traj = T.load( T.testRoot()+'/lig_pcr_00/traj.dat')

        traj = traj2ensemble( traj )

        aMask = traj.ref.mask( lambda a: a['name'] in ['CA','CB','CG'] )

        traj = traj.thin( 1 )

        traj.fit( aMask, verbose=self.local )
        self.tc = TrajCluster( traj, verbose=self.local )

        ## check how many clusters that are needed with the given criteria
        n_clusters = self.tc.calcClusterNumber( min_clst=3, max_clst=15,
                                                rmsLimit=0.7, aMask=aMask )

        ## cluster
        self.tc.cluster( n_clusters, aMask=aMask )

        if self.local:
            member_frames = self.tc.memberFrames()

            print 'There are %i clusters where the members are:'%n_clusters
            for i in range(n_clusters):
                print 'Cluster %i (%i members): %s'%( i+1,
                                                      len(member_frames[i]),
                                                      member_frames[i] )
Esempio n. 2
0
    def test_TrajCluster(self):
        """TrajCluster test"""
        from Biskit.EnsembleTraj import traj2ensemble

        traj = T.load(T.testRoot() + '/lig_pcr_00/traj.dat')

        traj = traj2ensemble(traj)

        aMask = traj.ref.mask(lambda a: a['name'] in ['CA', 'CB', 'CG'])

        traj = traj.thin(1)

        traj.fit(aMask, verbose=self.local)
        self.tc = TrajCluster(traj, verbose=self.local)

        ## check how many clusters that are needed with the given criteria
        n_clusters = self.tc.calcClusterNumber(min_clst=3,
                                               max_clst=15,
                                               rmsLimit=0.7,
                                               aMask=aMask)

        ## cluster
        self.tc.cluster(n_clusters, aMask=aMask)

        if self.local:
            member_frames = self.tc.memberFrames()

            print 'There are %i clusters where the members are:' % n_clusters
            for i in range(n_clusters):
                print 'Cluster %i (%i members): %s' % (
                    i + 1, len(member_frames[i]), member_frames[i])
Esempio n. 3
0
    def loadTraj( self, ftraj ):
        """
        Load trajectories from disc.

        @param ftraj: path to trajectory
        @type  ftraj: str

        @return: ensemble trajectory object
        @rtype: EnsembleTraj
        """
        t = T.load( T.absfile( ftraj ) )
        return traj2ensemble( t )
Esempio n. 4
0
    def loadTraj(self, ftraj):
        """
        Load trajectories from disc.

        @param ftraj: path to trajectory
        @type  ftraj: str

        @return: ensemble trajectory object
        @rtype: EnsembleTraj
        """
        t = T.load(T.absfile(ftraj))
        return traj2ensemble(t)
Esempio n. 5
0
    def test_FlexMaster(self):
        """TrajFlexMaster test"""
        from Biskit.MatrixPlot import MatrixPlot
        from numpy.random.mtrand import random_sample as random

        assert len(hosts.cpus_all) > 0,\
               'Master requires at least 1 PVM node for initialisation.'

        traj_1 = T.load(T.testRoot() + '/lig_pcr_00/traj.dat')
        traj_1 = traj2ensemble(traj_1)

        ## create fake second trajectory by adding
        ## increasing noise to first
        frames = []
        for i in range(len(traj_1)):
            f = traj_1.frames[i]
            d = N0.zeros(N0.shape(f), N0.Float32)
            if i > 0:
                d = random(N0.shape(f)) * ((i / 10) + 1)
            frames += [f + d]

        traj_2 = traj_1.clone()
        traj_2.frames = frames

        master = TrajFlexMaster(traj_1,
                                traj_2,
                                hosts=hosts.cpus_all,
                                show_output=self.local,
                                add_hosts=1,
                                log=None,
                                slaveLog=None,
                                verbose=self.local,
                                only_cross_member=0)

        r = master.calculateResult(mirror=0)

        if self.local:
            p = MatrixPlot(r, palette='plasma2', legend=1)
            p.show()
Esempio n. 6
0
    def test_FlexMaster(self):
        """TrajFlexMaster test"""
        from Biskit.MatrixPlot import MatrixPlot
        from numpy.oldnumeric.random_array import random

        assert len(hosts.cpus_all) > 0,\
               'Master requires at least 1 PVM node for initialisation.'

        traj_1 = T.load( T.testRoot() + '/lig_pcr_00/traj.dat' )
        traj_1 = traj2ensemble( traj_1 )

        ## create fake second trajectory by adding
        ## increasing noise to first
        frames = []
        for i in range( len( traj_1 ) ):
            f = traj_1.frames[i]
            d = N.zeros( N.shape( f ), N.Float32)
            if i > 0:
                d = random( N.shape( f ) ) * ((i / 10) + 1) 
            frames += [f + d]

        traj_2 = traj_1.clone()
        traj_2.frames = frames

        master = TrajFlexMaster( traj_1, traj_2,
                                 hosts=hosts.cpus_all,
                                 show_output= self.local,
                                 add_hosts=1,
                                 log=None,
                                 slaveLog=None,
                                 verbose= self.local,
                                 only_cross_member=0 )

        r = master.calculateResult( mirror=0 )

        if self.local:
            p = MatrixPlot( r, palette='plasma2', legend=1 )
            p.show()            
Esempio n. 7
0
def load(options):

    f_traj = options['i']
    start = int(options['s'])

    traj = T.load(f_traj)

    if traj.__class__ != EnsembleTraj:
        traj = traj2ensemble(traj)

    end = traj.lenFrames()
    if options.has_key('e'):
        end = int(options['e'])

    step = int(options['step'])

    traj = traj.takeFrames(range(start, end))
    if step != 1:
        traj = traj.thin(step)

    traj.fit()

    return TrajCluster(traj)
Esempio n. 8
0
def load( options ):

    f_traj = options['i']
    start = int( options['s'] )
    
    traj = T.load( f_traj )

    if traj.__class__ != EnsembleTraj:
        traj = traj2ensemble( traj )

    end = traj.lenFrames()
    if options.has_key('e'):
        end = int( options['e'] )

    step = int( options['step'] )

    traj = traj.takeFrames( range( start, end ) )
    if step != 1:
        traj = traj.thin( step )

    traj.fit()

    return TrajCluster( traj )
Esempio n. 9
0
syntax()

## get and clean up options
o = options()
o['z'] = float( o['z'] )
o['step'] = int( o['step'] )
o['i'] = absfile( o['i'] )
o['o'] = o.get('o',
               '%s/%s_rms.eps' % (osp.dirname(o['i']), stripFilename(o['i'])))

flushPrint( "Loading..." )
t = load( o['i'] )
flushPrint( "done." )

if not isinstance( t, EnsembleTraj ):
    t = traj2ensemble( t )

if o['step'] != 1:
    t = t.thin( o['step'] ) 

flushPrint( "Fitting..." )
calcRmsd( t )
flushPrint( "done." )

p = plot( t, o.get( 'title', stripFilename(o['i']) ) )

flushPrint( "Getting outliers ..." )
markOutliers( t, o['z'], p )
flushPrint( "done." )

p.show()
Esempio n. 10
0
## MAIN ##

use()

o = T.cmdDict({'n': 10})

f_in = T.absfile(o['i'])
f_out = T.absfile(o.get('o', f_in))
n = int(o['n'])

T.flushPrint("Loading...")
t = T.load(f_in)

T.flushPrint("Converting %i frames..." % len(t))

if isinstance(t, EnsembleTraj):
    T.flushPrint("Nothing to be done!\n")
    sys.exit(0)

t = traj2ensemble(t, n)
if 'pdb' in o:
    t.ref.pdbCode = o['pdb']

if f_in == f_out:
    os.rename(f_in, f_in + '_backup')

T.flushPrint("Saving...")
T.dump(t, f_out)

T.flushPrint("Done.\n")
Esempio n. 11
0
    
Default options:
"""
    for key, value in o.items():
        print "\t-",key, "\t",value
        
    sys.exit(0)



##########
## MAIN ##

if len( sys.argv) < 2:
    _use()

o = cmdDict( o )


print "Loading trajectory .. "
traj = load( absfile(o['i']) )
traj = traj2ensemble( traj )

print "Removing frames ..."
thin_traj = traj.thin( step=int(o['step']) )

print "Dumping thinned trajectory with %i frames (%i frames removed)..."\
      %(thin_traj.lenFrames(), traj.lenFrames()-thin_traj.lenFrames())
dump( thin_traj, absfile( o['i'] ) )

Esempio n. 12
0
    for xyz in t.frames:
        result_xyz.append(xyz.astype('f'))

    for fname in t.frameNames:
        result_frameNames.append(fname)

    T.flushPrint('#')

print " Done"

result = Trajectory()

result.ref = result_ref
result.ref.disconnect()

if 'pdb' in o:
    result.ref.pdbCode = o['pdb']

result.frames = N.array(result_xyz, 'f')
result.frameNames = result_frameNames

del result_xyz
## too much memory required for this
## result = trajLst[0].concat( *trajLst[1:] )

T.flushPrint("Converting to EnsembleTraj...")
result = traj2ensemble(result, len(inLst))

T.flushPrint("Done\nDumping ensemble traj to " + o['o'])
T.dump(result, T.absfile(o['o']))
Esempio n. 13
0
         i     - pickled Trajectory object
         step  - int, 1..keep all frames, 2..skip first and every second, ..
    
Default options:
"""
    for key, value in o.items():
        print "\t-", key, "\t", value

    sys.exit(0)


##########
## MAIN ##

if len(sys.argv) < 2:
    _use()

o = cmdDict(o)

print "Loading trajectory .. "
traj = load(absfile(o['i']))
traj = traj2ensemble(traj)

print "Removing frames ..."
thin_traj = traj.thin(step=int(o['step']))

print "Dumping thinned trajectory with %i frames (%i frames removed)..."\
      %(thin_traj.lenFrames(), traj.lenFrames()-thin_traj.lenFrames())
dump(thin_traj, absfile(o['i']))
Esempio n. 14
0
syntax()

## get and clean up options
o = options()
o['z'] = float( o['z'] )
o['step'] = int( o['step'] )
o['i'] = absfile( o['i'] )
o['o'] = o.get('o',
               '%s/%s_rms.eps' % (osp.dirname(o['i']), stripFilename(o['i'])))

flushPrint( "Loading..." )
t = load( o['i'] )
flushPrint( "done." )

if not isinstance( t, EnsembleTraj ):
    t = traj2ensemble( t )

if o['step'] != 1:
    t = t.thin( o['step'] ) 

flushPrint( "Fitting..." )
calcRmsd( t )
flushPrint( "done." )

p = plot( t, o.get( 'title', stripFilename(o['i']) ) )

flushPrint( "Getting outliers ..." )
markOutliers( t, o['z'], p )
flushPrint( "done." )

p.show()
Esempio n. 15
0
## MAIN ##

use()

o = T.cmdDict( {'n':10} )

f_in  = T.absfile( o['i'] )
f_out = T.absfile( o.get('o', f_in) )
n = int( o['n'] )

T.flushPrint("Loading...")
t = T.load( f_in )

T.flushPrint("Converting %i frames..." % len(t) )

if isinstance(t, EnsembleTraj ):
    T.flushPrint( "Nothing to be done!\n")
    sys.exit(0)
    
t = traj2ensemble( t, n )
if 'pdb' in o:
    t.ref.pdbCode = o['pdb']

if f_in == f_out:
    os.rename( f_in, f_in + '_backup')

T.flushPrint("Saving...")
T.dump( t, f_out )

T.flushPrint("Done.\n")
Esempio n. 16
0
    for xyz in t.frames:
        result_xyz.append( xyz.astype('f') )

    for fname in t.frameNames:
        result_frameNames.append( fname )
    
    T.flushPrint('#')
    
print " Done"

result = Trajectory()

result.ref = result_ref
result.ref.disconnect()

if 'pdb' in o:
    result.ref.pdbCode = o['pdb']

result.frames      = N0.array( result_xyz, 'f' )
result.frameNames  = result_frameNames

del result_xyz
## too much memory required for this
## result = trajLst[0].concat( *trajLst[1:] )

T.flushPrint("Converting to EnsembleTraj...")
result = traj2ensemble( result, len(inLst))

T.flushPrint( "Done\nDumping ensemble traj to " + o['o'] )
T.dump( result, T.absfile( o['o'] ) )