File size: 1,677 Bytes
174a005
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Prespecified-summary definitions are modeling choices; no inferential thresholds."""
import argparse
import csv
from pathlib import Path


def main():
    parser=argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--dir',type=Path,default=Path(__file__).resolve().parent)
    args=parser.parse_args()
    with (args.dir/'relaxation_endpoints.csv').open() as f:
        rows=list(csv.DictReader(f))
    out=[]
    for label in sorted({r['compound'] for r in rows}):
        for k in ('6.0','20.0'):
            for alt in ('A','B'):
                group=[r for r in rows if r['compound']==label and r['alt']==alt and r['anchor_force_constant']==k]
                fits=[r for r in group if r['converged']=='True' and float(r['all_ligand_heavy_protein_min_A'])>=2.9
                      and max(float(r['carbonyl_O_offset_A']),float(r['amide_N_offset_A']))<=1.0 and float(r['ring_rmsd_A'])<=.75]
                best=min(fits,key=lambda r:float(r['within_compound_strain_kcal_mol'])) if fits else {}
                out.append(dict(compound=label,alt=alt,anchor_k=k,starts=len(group),admissible=len(fits),
                     **{key:best.get(key,'') for key in ['seed','within_compound_strain_kcal_mol','ring_rmsd_A','carbonyl_O_offset_A','amide_N_offset_A','all_ligand_heavy_protein_min_A']}))
    with (args.dir/'least_strain_by_condition.csv').open('w',newline='') as f:
        w=csv.DictWriter(f,fieldnames=list(out[0]));w.writeheader();w.writerows(out)
    for r in out:
        print(r['compound'],r['anchor_k'],r['alt'],round(float(r['within_compound_strain_kcal_mol']),3) if r['admissible'] else 'unresolved')
if __name__=='__main__':
    main()