def compareVersions(): from htmd.version import version from natsort import natsorted import os import time #t = time.time() from os.path import expanduser __home = expanduser("~") __htmdconf = os.path.join(__home, '.htmd') if not os.path.exists(__htmdconf): try: os.makedirs(__htmdconf) except error: print('Unable to create {} folder. Will not check for new HTMD versions.'.format(__htmdconf)) return __file = os.path.join(__htmdconf, '.latestversion') if not os.path.isfile(__file) or time.time() > os.path.getmtime(__file) + 86400: #86400: # Check if one day has passed since last version check _writeLatestVersionFile(__file) try: f = open(__file, 'r') except: print('Unable to open {} file for reading. Will not check for new HTMD versions.'.format(__file)) return latestver = f.read() f.close() currver = version() if currver != 'unpackaged' and natsorted((latestver, currver))[1] != currver: print('New HTMD version ({}) is available. You are currently on ({}). Use \'conda update htmd\' to update to the new version.'.format(latestver, currver)) else: print('You are on the latest HTMD version ({}).'.format(currver))
def compareVersions(): from htmd.home import home from htmd.version import version from natsort import natsorted import os import time #t = time.time() __file = os.path.join(home(), '.latestversion') if not os.path.isfile(__file) or time.time() > os.path.getmtime( __file ) + 86400: #86400: # Check if one day has passed since last version check _writeLatestVersionFile(__file) f = open(__file, 'r') latestver = f.read() f.close() currver = version() if currver != 'unpackaged' and natsorted( (latestver, currver))[1] != currver: print( 'New HTMD version ({}) is available. You are currently on ({}). Use \'conda update htmd\' to update to the new version.' .format(latestver, currver)) else: print('You are on the latest HTMD version ({}).'.format(currver))
def getArgumentParser(): parser = argparse.ArgumentParser(description='Acellera small molecule parameterization tool') parser.add_argument('filename', help='Molecule file in MOL2 format') parser.add_argument('-c', '--charge', type=int, help='Total charge of the molecule (default: sum of partial charges)') parser.add_argument('-l', '--list', action='store_true', help='List parameterizable dihedral angles') parser.add_argument('--rtf-prm', nargs=2, metavar='<filename>', help='CHARMM RTF and PRM files') parser.add_argument('-ff', '--forcefield', default='GAFF2', choices=fftypemethods, help='Initial atom type and parameter assignment (default: %(default)s)') parser.add_argument('--fix-charge', nargs='+', default=[], metavar='<atom name>', help='Fix atomic charge during charge fitting (default: none)') parser.add_argument('-d', '--dihedral', nargs='+', default=[], metavar='A1-A2-A3-A4', help='Select dihedral angle to parameterize (default: all parameterizable dihedral angles)') parser.add_argument('--code', default='Psi4', choices=['Psi4', 'Gaussian'], help='QM code (default: %(default)s)') parser.add_argument('--theory', default='B3LYP', choices=['HF', 'B3LYP', 'wB97X-D'], help='QM level of theory (default: %(default)s)') parser.add_argument('--basis', default='cc-pVDZ', choices=['6-31G*', '6-31+G*', '6-311G**', '6-311++G**', 'cc-pVDZ', 'aug-cc-pVDZ'], help='QM basis set (default: %(default)s)') parser.add_argument('--environment', default='vacuum', choices=['vacuum', 'PCM'], help='QM environment (default: %(default)s)') parser.add_argument('--no-min', action='store_false', dest='minimize', help='DDEPRECATED: use `--min-type` instead') parser.add_argument('--min-type', default='qm', dest='min_type', choices=['None', 'qm', 'mm'], help='Type of initial structure optimization (default: %(default)s)') parser.add_argument('--charge-type', default='ESP', choices=['None', 'Gasteiger', 'AM1-BCC', 'ESP'], help='Partial atomic charge type (default: %(default)s)') parser.add_argument('--no-dihed', action='store_false', dest='fit_dihedral', help='Do not perform QM scanning of dihedral angles') parser.add_argument('--no-dihed-opt', action='store_false', dest='optimize_dihedral', help='DEPRECATED: use `--scan-type` instead') parser.add_argument('--scan-type', default='qm', dest='dihed_opt_type', choices=['None', 'qm', 'mm'], help='Type of structure optimization when scanning dihedral angles (default: %(default)s)') parser.add_argument('--dihed-num-searches', default=None, type=int, help='Number of random searches during the dihedral parameter fitting') parser.add_argument('-q', '--queue', default='local', choices=['local', 'Slurm', 'LSF', 'AceCloud'], help='QM queue (default: %(default)s)') parser.add_argument('-n', '--ncpus', default=None, type=int, help='Number of CPU per QM job (default: queue ' 'defaults)') parser.add_argument('-m', '--memory', default=None, type=int, help='Maximum amount of memory in MB to use.') parser.add_argument('--groupname', default=None, help=argparse.SUPPRESS) parser.add_argument('-o', '--outdir', default='./', help='Output directory (default: %(default)s)') parser.add_argument('--seed', default=20170920, type=int, help='Random number generator seed (default: %(default)s)') parser.add_argument('--version', action='version', version=version()) # Enable replacement of any real QM class with FakeQM. # This is intedended for debugging only and should be kept hidden. parser.add_argument('--fake-qm', action='store_true', default=False, dest='fake_qm', help=argparse.SUPPRESS) # NNP module name parser.add_argument('--nnp', help=argparse.SUPPRESS) # Debug mode parser.add_argument('--debug', action='store_true', default=False, dest='debug', help=argparse.SUPPRESS) return parser
def compareVersions(): from htmd.version import version from natsort import natsorted import os import time #t = time.time() from os.path import expanduser __home = expanduser("~") __htmdconf = os.path.join(__home, '.htmd') if not os.path.exists(__htmdconf): try: os.makedirs(__htmdconf) except: print('Unable to create {} folder. Will not check for new HTMD versions.'.format(__htmdconf)) return __file = os.path.join(__htmdconf, '.latestversion') # Check if one day has passed since last version check. If yes, get new version and write to file if not os.path.isfile(__file) or time.time() > os.path.getmtime(__file) + 86400: _writeLatestVersionFile(__file) try: f = open(__file, 'r') except: print('Unable to open {} file for reading. Will not check for new HTMD versions.'.format(__file)) return latestversions = f.readlines() f.close() currver = version() if currver != 'unpackaged' and len(latestversions) == 2: # Supporting users which still haven't passed the one day limit. Can remove in next if _is_stable(currver): latest = latestversions[0].strip() verstring = 'stable' else: latest = latestversions[1].strip() verstring = 'devel' elif len(latestversions) == 1: # Supporting users which still haven't passed the one day limit. Can remove in next version latest = latestversions[0].strip() verstring = '' elif currver == 'unpackaged': pass else: return if currver != 'unpackaged' and natsorted((latest, currver))[1] != currver: print('New {} HTMD version ({}) is available. You are currently on ({}). Use \'conda update -c acellera htmd\' to ' 'update to the new version.'.format(verstring, latest, currver)) else: if currver != 'unpackaged': print('You are on the latest HTMD version ({}).'.format(currver)) else: from htmd import home print('You are on the latest HTMD version ({} : {}).'.format(currver, home())) print("")
def getArgumentParser(): parser = argparse.ArgumentParser(description='Acellera small molecule parameterization tool') parser.add_argument('filename', help='Molecule file in MOL2 format') parser.add_argument('-c', '--charge', type=int, help='Total charge of the molecule (default: sum of partial charges)') parser.add_argument('-l', '--list', action='store_true', help='List parameterizable dihedral angles') parser.add_argument('--rtf-prm', nargs=2, metavar='<filename>', help='CHARMM RTF and PRM files') parser.add_argument('-ff', '--forcefield', nargs='+', default=['GAFF2'], choices=['GAFF', 'GAFF2', 'CGENFF'], help='Inital force field guess (default: %(default)s)') parser.add_argument('--fix-charge', nargs='+', default=[], metavar='<atom name>', help='Fix atomic charge during charge fitting (default: none)') parser.add_argument('-d', '--dihedral', nargs='+', default=[], metavar='A1-A2-A3-A4', help='Select dihedral angle to parameterize (default: all parameterizable dihedral angles)') parser.add_argument('--code', default='Psi4', choices=['Psi4', 'Gaussian'], help='QM code (default: %(default)s)') parser.add_argument('--theory', default='B3LYP', choices=['HF', 'B3LYP'], help='QM level of theory (default: %(default)s)') parser.add_argument('--basis', default='cc-pVDZ', choices=['6-31G*', '6-31+G*', 'cc-pVDZ', 'aug-cc-pVDZ'], help='QM basis set (default: %(default)s)') parser.add_argument('--environment', default='vacuum', choices=['vacuum', 'PCM'], help='QM environment (default: %(default)s)') parser.add_argument('--no-min', action='store_false', dest='minimize', help='Do not perform QM structure minimization') parser.add_argument('--no-esp', action='store_false', dest='fit_charges', help='Do not perform QM charge fitting') parser.add_argument('--no-dihed', action='store_false', dest='fit_dihedral', help='Do not perform QM scanning of dihedral angles') parser.add_argument('--no-dihed-opt', action='store_false', dest='optimize_dihedral', help='Do not perform QM structure optimisation when scanning dihedral angles') parser.add_argument('-q', '--queue', default='local', choices=['local', 'Slurm', 'LSF', 'AceCloud'], help='QM queue (default: %(default)s)') parser.add_argument('-n', '--ncpus', default=None, type=int, help='Number of CPU per QM job (default: queue ' 'defaults)') parser.add_argument('-m', '--memory', default=None, type=int, help='Maximum amount of memory in MB to use.') parser.add_argument('--groupname', default=None, help=argparse.SUPPRESS) parser.add_argument('-o', '--outdir', default='./', help='Output directory (default: %(default)s)') parser.add_argument('--seed', default=20170920, type=int, help='Random number generator seed (default: %(default)s)') parser.add_argument('--version', action='version', version=version()) # Enable replacement of any real QM class with FakeQM. # This is intedended for debugging only and should be kept hidden. parser.add_argument('--fake-qm', action='store_true', default=False, dest='fake_qm', help=argparse.SUPPRESS) return parser
def compareVersions(): from htmd.version import version from natsort import natsorted import os import time #t = time.time() from os.path import expanduser __home = expanduser("~") __htmdconf = os.path.join(__home, '.htmd') if not os.path.exists(__htmdconf): try: os.makedirs(__htmdconf) except error: print( 'Unable to create {} folder. Will not check for new HTMD versions.' .format(__htmdconf)) return __file = os.path.join(__htmdconf, '.latestversion') if not os.path.isfile(__file) or time.time() > os.path.getmtime( __file ) + 86400: #86400: # Check if one day has passed since last version check _writeLatestVersionFile(__file) try: f = open(__file, 'r') except: print( 'Unable to open {} file for reading. Will not check for new HTMD versions.' .format(__file)) return latestver = f.read() f.close() currver = version() if currver != 'unpackaged' and natsorted( (latestver, currver))[1] != currver: print( 'New HTMD version ({}) is available. You are currently on ({}). Use \'conda update htmd\' to update to the new version.' .format(latestver, currver)) else: print('You are on the latest HTMD version ({}).'.format(currver))
def compareVersions(): from htmd.version import version from natsort import natsorted import os import time from os.path import expanduser __home = expanduser("~") __htmdconf = os.path.join(__home, '.htmd') if not os.path.exists(__htmdconf): try: os.makedirs(__htmdconf) except: print( 'Unable to create {} folder. Will not check for new HTMD versions.' .format(__htmdconf)) return __file = os.path.join(__htmdconf, '.latestversion') # Check if one day has passed since last version check. If yes, get new version and write to file if not os.path.isfile(__file) or time.time( ) > os.path.getmtime(__file) + 86400 or os.stat(__file).st_size == 0: _writeLatestVersionFile(__file) try: f = open(__file, 'r') except: print( 'Unable to open {} file for reading. Will not check for new HTMD versions.' .format(__file)) return latestversions = f.readlines() f.close() if len(latestversions) != 2: print( 'There is something wrong with your {} file. Will not check for new HTMD versions.' .format(__file)) return currver = version() if currver != 'unpackaged': if _is_stable(currver): pieces = latestversions[0].split() latest = pieces[0].strip() verstring = 'stable' else: pieces = latestversions[1].split() latest = pieces[0].strip() verstring = 'devel' pydeps = '' if len(pieces) > 1: pydeps = ' python[{}]'.format(pieces[1]) elif currver == 'unpackaged': pass else: return if currver != 'unpackaged' and natsorted((latest, currver))[1] != currver: print( 'New {} HTMD version ({}{}) is available. You are currently on ({}). Use \'conda update -c ' 'acellera htmd\' to update to the new version. You might need to update your python version as well ' 'if there is no release for your current version.'.format( verstring, latest, pydeps, currver)) else: if currver != 'unpackaged': print('You are on the latest HTMD version ({}).'.format(currver)) else: from htmd.home import home print('You are on the latest HTMD version ({} : {}).'.format( currver, home())) print("")
def compareVersions(): from htmd.version import version from natsort import natsorted import os import time from os.path import expanduser __home = expanduser("~") __htmdconf = os.path.join(__home, ".htmd") if not os.path.exists(__htmdconf): try: os.makedirs(__htmdconf) except Exception: print( f"Unable to create {__htmdconf} folder. Will not check for new HTMD versions." ) return __file = os.path.join(__htmdconf, ".latestversion") # Check if one day has passed since last version check. If yes, get new version and write to file if (not os.path.isfile(__file) or time.time() > os.path.getmtime(__file) + 86400 or os.stat(__file).st_size == 0): _writeLatestVersionFile(__file) try: f = open(__file, "r") except Exception: print( f"Unable to open {__file} file for reading. Will not check for new HTMD versions." ) return latestversions = f.readlines() f.close() if len(latestversions) != 2: print( f"There is something wrong with your {__file} file. Will not check for new HTMD versions." ) return currver = version() if currver != "unpackaged": if _is_stable(currver): pieces = latestversions[0].split() latest = pieces[0].strip() verstring = "stable" else: pieces = latestversions[1].split() latest = pieces[0].strip() verstring = "devel" pydeps = "" if len(pieces) > 1: pydeps = f" python[{pieces[1]}]" elif currver == "unpackaged": pass else: return if currver != "unpackaged" and natsorted((latest, currver))[1] != currver: print( f"New {verstring} HTMD version ({latest}{pydeps}) is available. You are currently on ({currver})." "There are several methods to update:" f" - Create a new conda env. using `conda create -n htmd{latest} htmd={latest} -c acellera -c conda-forge`" " - Create a brand new conda installation and run `conda install htmd -c acellera -c conda-forge`" " - Run: `conda update htmd -c acellera -c conda-forge` (NOT RECOMMENDED!)" ) else: if currver != "unpackaged": print(f"You are on the latest HTMD version ({currver}).") else: from htmd.home import home print( f"You are on the latest HTMD version ({currver} : {home()}).") print("")
def compareVersions(): from htmd.version import version from natsort import natsorted import os import time from os.path import expanduser __home = expanduser("~") __htmdconf = os.path.join(__home, '.htmd') if not os.path.exists(__htmdconf): try: os.makedirs(__htmdconf) except: print('Unable to create {} folder. Will not check for new HTMD versions.'.format(__htmdconf)) return __file = os.path.join(__htmdconf, '.latestversion') # Check if one day has passed since last version check. If yes, get new version and write to file if not os.path.isfile(__file) or time.time() > os.path.getmtime(__file) + 86400 or os.stat(__file).st_size == 0: _writeLatestVersionFile(__file) try: f = open(__file, 'r') except: print('Unable to open {} file for reading. Will not check for new HTMD versions.'.format(__file)) return latestversions = f.readlines() f.close() if len(latestversions) != 2: print('There is something wrong with your {} file. Will not check for new HTMD versions.'.format(__file)) return currver = version() if currver != 'unpackaged': if _is_stable(currver): pieces = latestversions[0].split() latest = pieces[0].strip() verstring = 'stable' else: pieces = latestversions[1].split() latest = pieces[0].strip() verstring = 'devel' pydeps = '' if len(pieces) > 1: pydeps = ' python[{}]'.format(pieces[1]) elif currver == 'unpackaged': pass else: return if currver != 'unpackaged' and natsorted((latest, currver))[1] != currver: print('New {} HTMD version ({}{}) is available. You are currently on ({}). Use \'conda update -c ' 'acellera htmd\' to update to the new version. You might need to update your python version as well ' 'if there is no release for your current version.'.format(verstring, latest, pydeps, currver)) else: if currver != 'unpackaged': print('You are on the latest HTMD version ({}).'.format(currver)) else: from htmd.home import home print('You are on the latest HTMD version ({} : {}).'.format(currver, home())) print("")
def compareVersions(): from htmd.version import version from natsort import natsorted import os import time #t = time.time() from os.path import expanduser __home = expanduser("~") __htmdconf = os.path.join(__home, '.htmd') if not os.path.exists(__htmdconf): try: os.makedirs(__htmdconf) except: print( 'Unable to create {} folder. Will not check for new HTMD versions.' .format(__htmdconf)) return __file = os.path.join(__htmdconf, '.latestversion') # Check if one day has passed since last version check. If yes, get new version and write to file if not os.path.isfile( __file) or time.time() > os.path.getmtime(__file) + 86400: _writeLatestVersionFile(__file) try: f = open(__file, 'r') except: print( 'Unable to open {} file for reading. Will not check for new HTMD versions.' .format(__file)) return latestversions = f.readlines() f.close() currver = version() if currver != 'unpackaged' and len( latestversions ) == 2: # Supporting users which still haven't passed the one day limit. Can remove in next if _is_stable(currver): latest = latestversions[0].strip() verstring = 'stable' else: latest = latestversions[1].strip() verstring = 'devel' elif len( latestversions ) == 1: # Supporting users which still haven't passed the one day limit. Can remove in next version latest = latestversions[0].strip() verstring = '' elif currver == 'unpackaged': pass else: return if currver != 'unpackaged' and natsorted((latest, currver))[1] != currver: print( 'New {} HTMD version ({}) is available. You are currently on ({}). Use \'conda update htmd\' to ' 'update to the new version.'.format(verstring, latest, currver)) else: if currver != 'unpackaged': print('You are on the latest HTMD version ({}).'.format(currver)) else: from htmd import home print('You are on the latest HTMD version ({} : {}).'.format( currver, home()))
def compareVersions(): from htmd.version import version from natsort import natsorted import os import time from os.path import expanduser __home = expanduser("~") __htmdconf = os.path.join(__home, '.htmd') if not os.path.exists(__htmdconf): try: os.makedirs(__htmdconf) except: print( 'Unable to create {} folder. Will not check for new HTMD versions.' .format(__htmdconf)) return __file = os.path.join(__htmdconf, '.latestversion') # Check if one day has passed since last version check. If yes, get new version and write to file if not os.path.isfile(__file) or time.time( ) > os.path.getmtime(__file) + 86400 or os.stat(__file).st_size == 0: _writeLatestVersionFile(__file) try: f = open(__file, 'r') except: print( 'Unable to open {} file for reading. Will not check for new HTMD versions.' .format(__file)) return latestversions = f.readlines() f.close() if len(latestversions) != 2: print( 'There is something wrong with your {} file. Will not check for new HTMD versions.' .format(__file)) return currver = version() if currver != 'unpackaged': if _is_stable(currver): pieces = latestversions[0].split() latest = pieces[0].strip() verstring = 'stable' else: pieces = latestversions[1].split() latest = pieces[0].strip() verstring = 'devel' pydeps = '' if len(pieces) > 1: pydeps = ' python[{}]'.format(pieces[1]) elif currver == 'unpackaged': pass else: return if currver != 'unpackaged' and natsorted((latest, currver))[1] != currver: print( 'New {verstring} HTMD version ({latest}{pydeps}) is available. You are currently on ({currver}).' 'There are several methods to update:' ' - Create a new conda env. using `conda create -n htmd{latest} htmd={latest} -c acellera -c psi4`' ' - Create a brand new conda installation and run `conda install htmd -c acellera -c psi4`' ' - Run: `conda update htmd -c acellera -c psi4` (NOT RECOMMENDED)' ''.format(verstring=verstring, latest=latest, pydeps=pydeps, currver=currver)) else: if currver != 'unpackaged': print('You are on the latest HTMD version ({}).'.format(currver)) else: from htmd.home import home print('You are on the latest HTMD version ({} : {}).'.format( currver, home())) print("")