-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsecondary_structure.py
More file actions
66 lines (54 loc) · 1.91 KB
/
secondary_structure.py
File metadata and controls
66 lines (54 loc) · 1.91 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
import biotite.structure.io as strucio
import biotite.structure as struc
import matplotlib.pyplot as plt
import numpy as np
def pdb2biotite(msaName):
pdbDir = "PDB_benchmark_structures\\"
# msaName = "1FM0_E_1FM0_D"
array = strucio.load_structure("{}.pdb".format(pdbDir + msaName[:4]))
return array
def calculate_ss(msaName, chain):
# msaName = "1FM0_E_1FM0_D"
array = pdb2biotite(msaName)
array = array[array.hetero == False] # filters out hetatoms
# Estimate secondary structure
if len(chain) > 1:
sse = []
for ch in chain:
sse.append(struc.annotate_sse(array, chain_id=ch))
return np.append(sse[0], sse[1])
else:
return struc.annotate_sse(array, chain_id=chain)
def calculate_dihedral(msaName):
array = pdb2biotite(msaName)
# plt.figure(0)
# plt.plot(phi * 360/(2*np.pi), psi * 360/(2*np.pi),
# marker="o", linestyle="None")
# plt.xlim(-180,180)
# plt.ylim(-180,180)
# plt.xlabel("$\phi$")
# plt.ylabel("$\psi$")
# plt.close()
return struc.dihedral_backbone(array)
def _add_sse_to_sasa_file(msaName):
"""
function to add calculated secondary structure values to sasa file.
:param msaName:
:return:
"""
import os
import pandas as pd
# msaName = "1FM0_E_1FM0_D"
sasa_file = "sasa\\total_{}_freesasa.txt".format(msaName)
dfSasa = pd.read_csv(sasa_file, delimiter='\t', header=0)
# Calculate ss
chains = [msaName.split("_")[1], msaName.split("_")[3]]
sse_chains = calculate_ss(msaName, chains)
dfSasa["ss"] = sse_chains
outfile = "{}_ss.txt".format(sasa_file.strip(".txt"))
header = 'Residue\tResidue_num\tChain\tTotal\tApolar\tBackbone\tmainchain\tSidechain\tRatio\tss'
dfSasa.to_csv(outfile, sep='\t', index=False, header=header)
# msaName = "1FM0_E_1FM0_D"
# msaName = "1SXJ_A_1SXJ_G"
msaName = "1WA5_A_1WA5_C"
_add_sse_to_sasa_file(msaName)