def main(argv):
    parser = argparse.ArgumentParser(description='Extract frame-by-frame MMPSA/MMGBSA Energy Totals')
    parser.add_argument('outfile', help='output file (CSV)')
    parser.add_argument('calc', help='gb (for GBSA) or pb (for PBSA)')
    parser.add_argument('-p', '--prefix', help='prefix for MMPBSA files (default _MMPBSA_)')
    args = parser.parse_args()
    
    if args.calc not in ['gb', 'pb']:
        print('calc must be either "gb" or "pb"')
        quit()
    
    prefix = '_MMPBSA_' if args.prefix is None else args.prefix
    data=MMPBSA_API.load_mmpbsa_info(prefix + 'info')
    head = ['TOTAL']
    
    with open(args.outfile, 'w') as csvfile:
        writer = csv.DictWriter(csvfile, fieldnames=head)
        writer.writeheader()
        tot = 0
        count = 0
    
        for i in range(len(data[args.calc]['complex']['EEL'])):
            row = {}
            row['TOTAL'] = data[args.calc]['complex']['TOTAL'][i] - data[args.calc]['ligand']['TOTAL'][i] -data[args.calc]['receptor']['TOTAL'][i]
            writer.writerow(row)
            tot += row['TOTAL']
            count += 1
        print("%d frames in total. Mean %f.".format(count, tot/count))
def main():
    from MMPBSA_mods import API as MMPBSA_API
    
    data = MMPBSA_API.load_mmpbsa_info('_MMPBSA_info')
    decomp_data = data['decomp']['gb']['complex']['TDC']

    for residue in decomp_data:
        energy_term = 'tot'
        print('res = {}, energy={}'.format(residue, decomp_data[residue][energy_term]))
Esempio n. 3
0
def getDataFrames(info_file, calculation_type='gb'):
    '''
    Reads an MMPBSA info file and returns a dictionary with four keys
    'complex', 'receptor', 'ligand' and 'difference'
    each with an associated pd.DataFrame with all the corresponding data
    '''
    data = MMPBSA_API.load_mmpbsa_info(info_file)  # data is a dictionary
    data_dfs = OrderedDict.fromkeys(['complex', 'receptor', 'ligand', 'difference'])
    for key in data[calculation_type]:
        df = pd.DataFrame.from_dict(data[calculation_type][key])
        data_dfs[key] = df
    # Calculate the difference between complex, receptor and ligand contributions
    data_dfs['difference'] = data_dfs['complex'] - data_dfs['receptor'] - data_dfs['ligand']
    return data_dfs
Esempio n. 4
0
def getDataFrames(info_file, calculation_type='gb'):
    '''
    Reads an MMPBSA info file and returns a dictionary with four keys
    'complex', 'receptor', 'ligand' and 'difference'
    each with an associated pd.DataFrame with all the corresponding data
    '''
    data = MMPBSA_API.load_mmpbsa_info(info_file)  # data is a dictionary
    data_dfs = OrderedDict.fromkeys(
        ['complex', 'receptor', 'ligand', 'difference'])
    for key in data[calculation_type]:
        df = pd.DataFrame.from_dict(data[calculation_type][key])
        data_dfs[key] = df
    # Calculate the difference between complex, receptor and ligand contributions
    data_dfs['difference'] = data_dfs['complex'] - data_dfs[
        'receptor'] - data_dfs['ligand']
    return data_dfs
def main():
    from MMPBSA_mods import API as MMPBSA_API
    
    data = MMPBSA_API.load_mmpbsa_info('_MMPBSA_info')
    decomp_data = data['decomp']['gb']['complex']['TDC']
    
    elist = ['tot', 'vdw', 'int', 'eel', 'pol', 'sas']
    line0 = [','.join(['residue', ] + elist[:]),]

    lines = []
    for residue in sorted(decomp_data.keys()):
        res_data = decomp_data[residue]
        line = str(residue) + ',' + ','.join(str(np.mean(res_data[k])) for k in elist)
        lines.append(line)

    line0.extend(lines)
    content = '\n'.join(line0)
    with open('res.csv', 'w') as fh:
        fh.write(content)
Esempio n. 6
0
def main():
    from MMPBSA_mods import API as MMPBSA_API
    
    data = MMPBSA_API.load_mmpbsa_info('_MMPBSA_info')
    decomp_data = data['decomp']['gb']['complex']['TDC']
    pt.to_pickle(decomp_data, 'energy_per_residue_per_structure.pk')
Esempio n. 7
0
#!/usr/bin/env python

from MMPBSA_mods import API as MMPBSA_API

# check http://ambermd.org/doc12/Amber15.pdf
# page 637 (Python API)
# data is nested python dict

data = MMPBSA_API.load_mmpbsa_info('_MMPBSA_info')
print(data.keys())
decomp_data = data['decomp']['gb']['complex']['TDC']
print(decomp_data.keys())

# res 1
print(decomp_data[1])