def run_test(filepath, pdbfile, repeats=10):
    (*_, dirname, filename) = Path(filepath).parts
    (basename, _) = os.path.splitext(filename)
    (pdbid, _) = os.path.splitext(os.path.basename(pdbfile))
    print(format(f'{dirname}/{basename}/{pdbid}', '<40'), end='', flush=True)
    if ('schrodinger' in filepath):
        cmd = [os.path.join(os.environ['SCHRODINGER'], 'run'), filepath, pdbfile, str(repeats)]
    elif filepath.endswith('.py'):
        cmd = ['python3', filepath, pdbfile, str(repeats)]
    elif filepath.endswith('.cr'):
        cmd = ['crystal', 'run', '--release', filepath, '--', pdbfile, str(repeats)]
    elif filepath.endswith('.tcl'):
        cmd = ['vmd', '-dispdev', 'none', '-e', filepath, '-args', pdbfile, str(repeats)]
    try:
        output = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
        output = output.decode(sys.stdout.encoding).strip()
        try:
            elapsed = float(output)
        except ValueError:
            elapsed = float(re.findall('elapsed *= *([\\d\\.e\\-]+)', output)[0])
        print(format(elapsed, '.6f'))
    except subprocess.CalledProcessError:
        print('failed')
def run_test(filepath, pdbfile, repeats=10):
    (*_, dirname, filename) = Path(filepath).parts
    (basename, _) = os.path.splitext(filename)
    (pdbid, _) = os.path.splitext(os.path.basename(pdbfile))
    print(format(f'{dirname}/{basename}/{pdbid}', '<40'), end=, flush=True)
    if ('schrodinger' in filepath):
        cmd = [os.path.join(os.environ['SCHRODINGER'], 'run'), filepath, pdbfile, str(repeats)]
    elif filepath.endswith('.py'):
        cmd = ['python3', filepath, pdbfile, str(repeats)]
    elif filepath.endswith('.cr'):
        cmd = ['crystal', 'run', '--release', filepath, '--', pdbfile, str(repeats)]
    elif filepath.endswith('.tcl'):
        cmd = ['vmd', '-dispdev', 'none', '-e', filepath, '-args', pdbfile, str(repeats)]
    try:
        output = subprocess.check_output(cmd, stderr=subprocess.DEVNULL)
        output = output.decode(sys.stdout.encoding).strip()
        try:
            elapsed = float(output)
        except ValueError:
            elapsed = float(re.findall('elapsed *= *([\\d\\.e\\-]+)', output)[0])
        print(format(elapsed, '.6f'))
    except subprocess.CalledProcessError:
        print('failed')