Coverage for /home/pedror/MMS@FCUL/pypka/pypka/cli.py : 70%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""Decimal Range
Requires: dmin (float or int) is the range minimum value dmax (float or int) is the range maximum value step (float or int) is the range step value
Ensures: lrange (list)
Example: drange(5, 7.5, 0.5) -> [5.0, 5.5, 6.0, 6.5, 7.0, 7.5]
""" lrange = [] dmin, dmax = float(dmin), float(dmax) step = float(step) inv_step = step ** -1 dmin_int = int(int(dmin) * inv_step) dmax_int = int(int(dmax) * inv_step) + 1 for i in range(dmin_int, dmax_int): lrange.append(i / inv_step) return lrange
""" Check if input parameters are valid
Mandatory Parameters: - Dielectric Constant - Ionic Strength - Temperature - Percentege of grid filling - pH range - sites_A
""" # MANDATORY # 'pbc_dimensions', 'temp', 'grid_fill', 'ncpus', 'pH', 'sites_A') log.requiredParameterError(param) log.requiredParameterError(param)
# Check parameter conditions: parameter is integer except: log.inputVariableError(param, 'an integer.', '')
# Check parameter conditions: parameter is float 'nonit', 'relfac', 'relpar', 'pHstep', 'epssol', 'temp', 'epsin', 'slice', 'cutoff') except: log.inputVariableError(param, 'a float.', '')
# Check parameter conditions: parameter > 0 # These parameters have already been checked for type int or float 'ncpus', 'temp', 'grid_fill', 'pH_step') except: log.inputVariableError(param, 'greater than zero.', '')
# Check parameters conditions: parameter is boolean else: log.inputVariableError(param, 'either "yes" or "no".', '')
# Check particular parameter conditions settings['bndcon'] not in ('1', '2', '3', '4'):
log.inputVariableError('bndcon', '1 (zero), 2(dipolar),' ' 3(focusing) or 4 (coulombic).', '') setParameter('bndcon', settings['bndcon'])
settings['precision'] not in ('single', 'double'):
log.inputVariableError('precision', 'either "single" or "double".', '') setParameter('precision', settings['precision'])
settings['ffID'] not in ('G54A7'): # for now only GROMOS FF log.inputVariableError('ffID', 'equal to "G54A7".', '') setParameter('ffID', settings['ffID'])
log.inputVariableError('pbc_dimensions', 'either "0" or "2".', '') else:
# Needs to accept both a single value and a range except: log.inputVariableError('pH', 'a float.', '') else: try: setParameter('pHmin', float(pH_parts[0])) setParameter('pHmax', float(pH_parts[0])) except: log.inputVariableError('pH', 'a float.', '') setParameter('pH', [param_value]) log.inputVariableError('pHmax', 'a float greater than pHmin.', '')
# Declare IO Files # Input .pdb File log.inputVariableError('structure', 'a string containing a file extension.', 'Ex: structure.pdb or structure.gro') log.inputVariableError('structure', 'a string containing a valid file extension.', 'Ex: structure.pdb or structure.gro')
# Output pKs File else: outputname = settings['structure'].split('.')[0] config.f_out = outputname
# Output Titration File
# Output log File
# Check coherence between variables getParameter('relfac') != 0.2 and 'relfac' not in settings: setParameter('relfac', 0.2)
resname = settings['lipid_definition'][i] config.lipids[i] = resname if resname in config.lipid_residues: resname_i = config.lipid_residues.index(resname) del config.lipid_residues[resname_i]
"""Reads the settings file.
This file should have the following format: - commented lines should being with a '#' - every parameter should be declared as such: name = value
All parameter values are interpreted as strings, however, a type check is later performed for each declared input value.
All parameter names not recognizable are reported as a warning. """ parts = param_value.split(':') old_name = parts[0] new_name = parts[1] parameters['lipid_definition'][old_name] = new_name not len(param_name) > 0 or \ not len(param_value) > 0: raise IOError('Incorrect format in line {0} of file {1}: ' '\n{1}#{0}: {2}'.format(nline, filename, line)) else:
# Search for all titrable sites in different chains
"""Gets the CLI arguments and interprets them"""
formatter_class=argparse.RawDescriptionHelpFormatter, description=""" Object-Oriented Script to Calculate the pKint of each site \ as well as the pairwise energies Requires: DelPhi2Py module installation Nanoshaper and cppSolver are optional libraries
Objects: DelPhiParams stores the DelPhi input parameters like a .prm file
TitratingMolecule is the molecule which has more than one Site
Site
Tautomer
Example: python pypka.py test.pdb test.dat -o pKas.out --debug
""")
# Mandatory Arguments default="settings.dat", action='store')
# Optional Arguments 'to print extra information', action='store_true')
# Apply some criteria to input arguments raise IOError('File {0} does not exist.'.format(args.settings))
# Read Settings File
|