Scripts:rmin2ex.py

From UC_Chemistry

Jump to: navigation, search

This is a very simple program that tests if the number in the last col. of the input is less than <rad>/10 (conversion from Angstrom to Gromacs units of nm). The first col. of the input file should be the time-stamp or frame serial number or it'll crash.

Source

<nowiki>
#!/usr/bin/python

import sys
from ucgrad import *

def main(argv):
        if len(argv) < 3:
                print "Usage: %s <rad> <rmin file> <list file>"%(argv[0])
                return 1

        x = read_matrix(argv[2])
        x[:,1] = x[:,-1] < float(argv[1])*0.1
        write_matrix(argv[3], x[:,:2])
        N = sum(x[:,1])
        #out = open(argv[3], 'w')
        #i = 0
        #for i, xi in enumerate(x[:,1]):
        #    if xi:
        #       out.write("%d\n"%(i+1))
        print "%d / %d frames marked for deletion."%(N,len(x))
        print "%.2f percent retained."%((100.0*(len(x)-N))/len(x))

        return 0

if __name__=="__main__":
        main(sys.argv)
</nowiki>
Personal tools