-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcalculation.py
More file actions
79 lines (72 loc) · 2.25 KB
/
calculation.py
File metadata and controls
79 lines (72 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import mdtraj as md
import os
import statistics as st
import numpy as np
# This script is trying to integrate my existing stand alone analysis scripts.
# These stand alone scripts are written in procedural programming.
# Calculate the Radius of Gyration of the trajectory
def calculate_rg(repeats,directory):
os.chdir(directory)
frametraj=[]
meantraj=[]
for nn in range(repeats):
t = md.load({'__traj_' + str(nn) + '.xtc'}, top='__START_0.pdb')
u = t.top.select('Protein')
r = t.atom_slice(u)
j = r.n_frames
frametraj.append(j)
d = md.compute_rg(r)
meantraj.append(st.mean(d))
mean,sd,frame=mean_feng(meantraj,frametraj)
return (mean,sd,frame)
# Different repeats may have different number of frames. We create a algorithm to calculated the average based on its
# frame number
def mean_feng(value,count,repeats):
framesum=0
meanadj=0
for nn in range(repeats):
framesum += count[nn]
meanadj += count[nn] * value[nn]
meanref = meanadj / framesum
stdadj = 0
for nn in range(repeats):
stdadj += count[nn] * (value[nn] - meanref) * (value[nn] - meanref)
sd=np.sqrt((stdadj / framesum) * repeats / (repeats-1))
return (meanref,sd,framesum)
# Calculation template for these stand alone functions.
def calculation_structure(protein,function):
string=protein.path
os.chdir(string)
l=protein.get_sss_solution_type()
for h in l:
mean = []
sd = []
frame = []
k=h.getsssvalue()
for p in k:
repeats=p.getrepeats()
runpath = str(string) + '/' + h.name + '/' + p.name
if function=='rg':
meanvalue,sdvalue,framevalue=calculate_rg(repeats,runpath)
mean.append(meanvalue)
sd.append(sdvalue)
frame.append(framevalue)
return()
# Here, we will add a function to automatically run the existing scripts under the certain folder.
def run_exist_scripts(datatype,entry_directory):
os.chdir(entry_directory)
if datatype is 'abc' :
pass
elif 1:
pass
elif 1:
pass
elif 1:
pass
return()
def chi_calculation():
return
def std_calculation():
return
def temp_calculation():
return