示例#1
0
def getLipids(readme, molecules=lipids_dict.keys()):
    lipids = 'resname '

    for key1 in readme['COMPOSITION'].keys():
        if key1 in molecules:
            mapping_file = readme['COMPOSITION'][key1]['MAPPING']

            mapping_dict = loadMappingFile(mapping_file)

            switch = 0
            for key2 in mapping_dict:
                try:
                    res = mapping_dict[key2]['RESIDUE']
                except KeyError:
                    switch = 1
                    continue
                else:
                    if res not in lipids:
                        lipids = lipids + res + ' or resname '

            if switch == 1:
                lipids = lipids + readme['COMPOSITION'][key1][
                    'NAME'] + ' or resname '
                break

    lipids = lipids[:-12]
    #  print(lipids)
    return lipids
示例#2
0
def getLipids(readme):
        lipids = []
        for key in lipids_dict.keys():
            try:
                if readme['N'+key] != [0,0]: 
                    lipids.append(key)
            except KeyError:
                continue
        return lipids
import os
import yaml
import json
import matplotlib.pyplot as plt
import numpy as np
import math

from matplotlib import cm
from scipy.stats import norm

from databankLibrary import lipids_dict

databank_path = '../../Data/Simulations'

lipid_numbers_list = lipids_dict.keys()  # should contain all lipid names
ions_list = ['POT', 'SOD', 'CLA', 'CAL']  # should contain names of all ions


class Data:
    def __init__(self, molecule, data_path):
        self.molecule = molecule
        self.data = {}
        self.__load_data__(data_path)

    def __load_data__(self, data_path):
        with open(data_path) as json_file:
            self.data = json.load(json_file)
        json_file.close()


class Simulation:
示例#4
0
#print(sims_valid_software) 


# ### Check that all entry keys provided for each simulation are valid:

wrong_key_entries = 0
software_dict_name = "{0}_dict".format(sim['SOFTWARE'].lower())
#print(sim.items())
for key_sim, value_sim in sim.items():
        #print(key_sim, value_sim)
        #print(key_sim.upper())
    if key_sim.upper() in ("SOFTWARE"):
            #print("NOT REQUIRED")
        continue
    #Anne: check if key is in molecules_dict, molecule_numbers_dict or molecule_ff_dict too
    if (key_sim.upper() not in software_dict[sim['SOFTWARE'].upper()].keys()) and (key_sim.upper() not in molecules_dict.keys()) and (key_sim.upper() not in lipids_dict.keys()) and (key_sim.upper() not in molecule_ff_dict.keys()):
        print ("{0} NOT in {1}".format(key_sim, software_dict_name)) 
        wrong_key_entries += 1
if wrong_key_entries:
    print("Simulation has {0} unknown entry/ies and won't be longer considered, please correct.\n".format(wrong_key_entries))
    quit()
else:
    msg_info = "All entries in simulation are understood and will be further processed\n"
    print(msg_info)
#        sims_valid_entries.append(sim.copy())
#print(sims_valid_entries)


# PLEASE CLARIFY THIS COMMENT
# ### Process entries with files information to contain file names in arrays
示例#5
0
def getWater(readme, molecules=lipids_dict.keys()):
    waters = 'resname ' + readme['COMPOSITION']['SOL']['NAME']
    return waters
示例#6
0
            outfile.close()
            #outfile2.close()

        # os.system('cp ' + str(dir_tmp) + '/' + key + 'OrderParameters.dat ' + DATAdir) #Or should these be put into Data/Simulations/
        # os.system('cp ' +str(dir_tmp) + '/' + key + 'OrderParameters.json ' + DATAdir)
    else:
        #trj = str(DATAdir) + '/' + str(trj)
        gro = path + '/conf.gro'

        #make gro file
        print("\n Makin gro file")
        os.system('echo System | gmx trjconv -f ' + trj_name + ' -s ' +
                  tpr_name + ' -dump 0 -o ' + gro)

        for key in system['COMPOSITION']:
            if key in lipids_dict.keys():
                print('Calculating ', key, ' order parameters')
                mapping_file = system['COMPOSITION'][key]['MAPPING']
                resname = system['COMPOSITION'][key]['NAME']
                outfilename = path + key + 'OrderParameters.dat'
                outfilename2 = path + key + 'OrderParameters.json'
                if (os.path.isfile(outfilename2)):
                    print('Order parameter file already found')
                    continue
                outfile = open(outfilename, 'w')

                try:
                    OrdParam = find_OP(mapping_file, tpr_name, xtcwhole,
                                       resname)
                except:
                    print('Using tpr did not work, trying with gro')