52 cutoffs=[float(e)
for e
in section[0].split()[2:]]
53 num_ca=[int(e)
for e
in section[1].split()[2:]]
54 gdt_ts=[float(e)
for e
in section[2].split()[2:]]
55 scores=dict(list(zip(cutoffs, gdt_ts)))
56 numbers=dict(list(zip(cutoffs, num_ca)))
57 factor=(1.0/(4*residue_count))*100
58 ts_cutoffs=(1.0, 2.0, 4.0, 8.0)
59 ha_cutoffs=(0.5, 1.0, 2.0, 4.0)
60 gdt_ts=(sum([numbers[c]
for c
in ts_cutoffs]))*factor
61 gdt_ha=(sum([numbers[c]
for c
in ha_cutoffs]))*factor
66 found_gdt_section=
False
67 found_transform_section=
False
68 for index, line
in enumerate(output):
69 if line.startswith(
'GLOBAL_DISTANCE_TEST'):
70 next_lines=output[index+1:index+5]
72 found_gdt_section=
True
73 if line.startswith(
'Unitary ROTATION matrix'):
74 next_lines=output[index+1:index+4]
76 found_transform_section=
True
78 assert found_transform_section
and found_gdt_section
81def GDT(pdb1, pdb2, chain1='', chain2='', reference_length=None, lga_bin=None):
83 Calculate GDT value between pdb1 and pdb2. It is assumed that the
84 corresponding residues in pdb1 and pdb2 have the same residue numbers.
87 temp_d=tempfile.mkdtemp(prefix=
'lga_gdt_ts_')
88 for d
in (
'MOL2',
'TMP',
'RESULTS'):
89 os.mkdir(os.path.join(temp_d, d))
92 chain1=pdb1.chains[0].name
94 chain2=pdb2.chains[0].name
95 pdb_one_name=os.path.join(temp_d,
'MOL2',
'one.pdb')
96 pdb_two_name=os.path.join(temp_d,
'MOL2',
'two.pdb')
97 io.SaveEntity(pdb1, pdb_one_name)
98 io.SaveEntity(pdb2, pdb_two_name)
100 os.path.join(temp_d,
'MOL2',
'input.pdb'))
101 output_file=os.path.join(temp_d,
'out.txt')
103 if len(chain1.strip()): ch1=
' -ch1:%s ' % chain1
104 if len(chain2.strip()): ch2=
' -ch2:%s ' % chain2
106 params=(temp_d, lga_bin,
'input.pdb', ch1, ch2)
107 command=
'cd %s; %s %s %s%s-ie -3 -d:4 -sda'
109 expanded_cmd=command % params
110 lga_proc=subprocess.Popen(expanded_cmd, shell=
True,
111 stdout=subprocess.PIPE)
112 stdout, _ = lga_proc.communicate()
114 length=reference_length
or max(pdb1.residue_count, pdb2.residue_count)
116 os.system(
'rm -r %s' % temp_d)