コード例 #1
0
from cpin_data import getData
from chemistry.amber.readparm import amberParm
import sys, os


def printusage():
    """ Prints the usage statement and quits """
    print "ChangeState.py <prmtop> <residue> <state> <new_prmtop>"
    sys.exit(0)


if len(sys.argv) != 5 or sys.argv[1] in ['--help', '-help', '-h', '--h']:
    printusage()

prmtop = amberParm(sys.argv[1])

if not prmtop.valid:
    print >> sys.stderr, 'Error: %s is not a valid prmtop!' % sys.argv[1]
    printusage()

res = int(sys.argv[2]) - 1
data = getData(prmtop.parm_data['RESIDUE_LABEL'][res], 5)
starting_point = prmtop.parm_data['RESIDUE_POINTER'][res] - 1
state = int(sys.argv[3])

for i in range(2, len(data[state])):
    atnum = starting_point + i - 2
    print "Changing %-4s from charge %8.4f to %8.4f" % \
       ( prmtop.parm_data['ATOM_NAME'][atnum], prmtop.parm_data['CHARGE'][atnum],
         data[state][i] )
コード例 #2
0
ファイル: FindSaltbridge.py プロジェクト: jeiros/JmsScripts
         output = sys.argv[x+1]
      elif sys.argv[x] == '-fraction':
         fraction = float(sys.argv[x+1])
      elif sys.argv[x] == '-y':
         x += 1
         while x < len(sys.argv) and not sys.argv[x].startswith('-'):
            mdcrds.append(sys.argv[x])
            x += 1
except IndexError:
   print 'Error: Improper command!'
   printusage()
except ValueError:
   print 'Error: "percent" must be a floating point decimal!'
   printusage()

parm = amberParm(prmtop)
if len(mdcrds) == 0: # if no mdcrd supplied, give default
   mdcrds.append('mdcrd')

ptraj = utilities.which('cpptraj') # look for ptraj

if ptraj is None:
   print 'Error: cpptraj needed for FindSaltbridge.py!'
   sys.exit() # quit if not found

if not parm.valid:
   printusage()

for x in range(len(mdcrds)): # check for mdcrd existences
   if utilities.fileexists(mdcrds[x]) == -1:
      printusage()
コード例 #3
0
ファイル: FindSaltbridge.py プロジェクト: swails/JmsScripts
            output = sys.argv[x + 1]
        elif sys.argv[x] == '-fraction':
            fraction = float(sys.argv[x + 1])
        elif sys.argv[x] == '-y':
            x += 1
            while x < len(sys.argv) and not sys.argv[x].startswith('-'):
                mdcrds.append(sys.argv[x])
                x += 1
except IndexError:
    print 'Error: Improper command!'
    printusage()
except ValueError:
    print 'Error: "percent" must be a floating point decimal!'
    printusage()

parm = amberParm(prmtop)
if len(mdcrds) == 0:  # if no mdcrd supplied, give default
    mdcrds.append('mdcrd')

ptraj = utilities.which('cpptraj')  # look for ptraj

if ptraj is None:
    print 'Error: cpptraj needed for FindSaltbridge.py!'
    sys.exit()  # quit if not found

if not parm.valid:
    printusage()

for x in range(len(mdcrds)):  # check for mdcrd existences
    if utilities.fileexists(mdcrds[x]) == -1:
        printusage()
コード例 #4
0
parser.addOption('-debug',
                 'debug',
                 help='0: Suppress tracebacks, ' + '1: print tracebacks',
                 default=0)

opt = parser.Parse()

debug_printlevel = opt.debug
opt.number = int(opt.number)

if not opt.prmtop1 or not opt.prmtop2:
    parser.print_help()

# Set up the prmtop objects
print >> sys.stdout, 'Reading topology files'
parm1 = amberParm(opt.prmtop1)
parm2 = amberParm(opt.prmtop2)

print >> sys.stdout, 'Validating topology files'
if not (parm1.valid and parm2.valid):
    print >> sys.stderr, 'Error: Problems with input prmtop files!'
    parser.print_help()

if parm1.parm_data['RESIDUE_LABEL'] != parm2.parm_data['RESIDUE_LABEL']:
    print >> sys.stderr, 'Error: You must have the same number of residues ' + \
                         ' in each prmtop!'
    sys.exit(1)
if parm1.parm_data['ATOM_NAME'] != parm2.parm_data['ATOM_NAME']:
    print >> sys.stderr, 'Error: Atom sequences must be the same in each prmtop!'
    sys.exit(1)
コード例 #5
0
#!/usr/bin/env python

# Find the number of residues in a given prmtop

from sys import stderr, stdout, exit, argv
from chemistry.amber.readparm import amberParm
from os import path


def usage():
    print >> stderr, "{0} <prmtop>".format(path.split(argv[0])[1])
    exit()


if len(argv) != 2:
    usage()

x = amberParm(argv[1])

if x.exists:
    print x.ptr(path.split(argv[0])[1].strip('.py'))

else:
    print >> stderr, '{0} does not exist!'.format(argv[1])
コード例 #6
0
ファイル: nres.py プロジェクト: jeiros/JmsScripts
#!/usr/bin/env python

# Find the number of residues in a given prmtop

from sys import stderr, stdout, exit, argv
from chemistry.amber.readparm import amberParm
from os import path

def usage():
   print >> stderr, "{0} <prmtop>".format(path.split(argv[0])[1])
   exit()

if len(argv) != 2:
   usage()

x = amberParm(argv[1])

if x.exists:
   print x.ptr(path.split(argv[0])[1].strip('.py'))

else:
   print >> stderr, '{0} does not exist!'.format(argv[1])
コード例 #7
0
      # Get arbitrary num of resnames to remove from the list
      elif sys.argv[x] == '-states':        # states flag
         x += 1
         while x < len(sys.argv) and not sys.argv[x].startswith("-"):
            dataholder = sys.argv[x].split(",")
            for y in range(len(dataholder)):
               if len(dataholder[y].strip()) != 0:
                  residue_states.append(dataholder[y].strip())
            x += 1
         # while loop may have been triggered by a flag; rewind to read flag
         x -= 1
except IndexError:
   print >> sys.stderr, 'Error: Command line error!'
   printusage()

prmtop_object = amberParm(prmtop)
has_water = 'WAT' in prmtop_object.parm_data['RESIDUE_LABEL']

if not prmtop_object.exists:
   sys.exit()
if igb == ' ':
   if not ignore_warn:
      print >> sys.stderr, 'Warning: igb value not specified. igb = 5 used as default. ' + \
            'Be sure to use this value for your constant pH simulations!'
   igb = '5'

try:
   prmtop_residues = prmtop_object.parm_data["RESIDUE_LABEL"]
   prmtop_indices = prmtop_object.parm_data['RESIDUE_POINTER']
except KeyError:
   'Error: Could not find RESIDUE_LABEL or RESIDUE_POINTER in %s!' % prmtop
コード例 #8
0
ファイル: ChangeState.py プロジェクト: jeiros/JmsScripts
""" Changes the protonation state of a given residue in a given prmtop """

from cpin_data import getData
from chemistry.amber.readparm import amberParm
import sys, os

def printusage():
   """ Prints the usage statement and quits """
   print "ChangeState.py <prmtop> <residue> <state> <new_prmtop>"
   sys.exit(0)

if len(sys.argv) != 5 or sys.argv[1] in ['--help','-help','-h','--h']:
   printusage()

prmtop = amberParm(sys.argv[1])

if not prmtop.valid:
   print >> sys.stderr, 'Error: %s is not a valid prmtop!' % sys.argv[1]
   printusage()

res = int(sys.argv[2]) - 1
data = getData(prmtop.parm_data['RESIDUE_LABEL'][res],5)
starting_point = prmtop.parm_data['RESIDUE_POINTER'][res] - 1
state = int(sys.argv[3])

for i in range(2,len(data[state])):
   atnum = starting_point + i - 2
   print "Changing %-4s from charge %8.4f to %8.4f" % \
      ( prmtop.parm_data['ATOM_NAME'][atnum], prmtop.parm_data['CHARGE'][atnum],
        data[state][i] )