Пример #1
0
def get_temp_vs_z(file):
    title, atom, box = groio.parse_file(file)
    box_z = float((box[21:30]))  ##grab z coord
    ###inital Dataframe
    df = pd.DataFrame(atom)
    del atom
    df = df.drop(columns=['resid', 'resname', 'atomid'])
    df = df[df['atom_name'] != 'MW']  # delete lone pair
    df['m'] = (df['atom_name'].map(lambda x: mass_table[x[0:2]]))
    df['z'] = (df['z'].map(lambda x: x / box_z * box_z_ini))
    df['T'] = (df.apply(
        lambda x: (x['vx'] * x['vx'] + x['vy'] * x['vy'] + x['vz'] * x['vz']) *
        0.5 * x['m'] * 1e6 * 2 * rkb, 1))
    df['T'] = (df.apply(lambda x: (x['T'] / deg_freedom[x['atom_name'][0:2]]),
                        1))
    df = df[['z', 'T']]
    df.sort_values(by='z', inplace=True)
    df.index = pd.date_range('1/1/2000', periods=len(df), freq='s')
    df = (pd.DataFrame(df[['T', 'z']].resample('200s').mean()))
    df.reset_index(drop=True, inplace=False)
    return df[['z', 'T']]
            tuple2.append(i)

# Get all the movies in the collection            
tuple3 = []
for movie in movie2:
    weights = movie.getElementsByTagName('weights')[0]
    print ("weights: %s" % weights.childNodes[0].data)
    tuple3.append(weights.childNodes[0].data)
            
#print (tuple2)         
#print (tuple3)

#comps = i.split(":")

#Read a gro file
title, gro_atoms, box = groio.parse_file("aa.gro")

#atoms - dictionary
# attributes: ['resid', 'resname', 'atom_name', 'atomid', 'x', 'y', 'z']
#"%5d%-5s%5s%5d%8.3f%8.3f%8.3f%8.4f%8.4f%8.4f"

resid =[]
resname = []
atoms = []
mass = tuple3[0].split(" ")
for x in tuple2:
    comp = x.split(":")
    resid.append(comp[0])
    resname.append(comp[1])
    atoms.append(comp[2])