source: rotdif/bin/indicator_chain.py @ 1529

Last change on this file since 1529 was 1529, checked in by yuexi, 3 years ago

differentiate chains

  • Property svn:executable set to *
File size: 1.4 KB
Line 
1#!/usr/bin/python
2import os,sys
3import pandas as pd
4import re
5
6def dock():
7    for root, dirs, files in os.walk('./'):
8        for name in files:
9            filename = os.path.join(root, name)
10            if '.txt' in filename:
11                exp_file = filename
12    ##preprocess exp_file in multi-frequencies
13    with open(exp_file) as in_f:
14        tmp_lists = in_f.read().splitlines()
15        exp_list = []
16        for items in tmp_lists:
17            if len(items) > 0:
18                exp_list.append(items.split()) 
19    exp_pd = pd.DataFrame(data = exp_list[1:],\
20columns = ["residue","chain","atom 1","atom 2","magnet","T1","T1 error","T2","T2 error","NOE","NOE error"])
21    resi = list(exp_pd["residue"])
22    digi_resi = []
23    #eliminate * in residue number
24    for list_elem in resi:
25        digi_resi.extend(re.findall("\d+", list_elem)) 
26    digi_resi = [int(elem) for elem in digi_resi]
27    exp_pd["residue"] = digi_resi
28    sort_exp = exp_pd.sort_values(['magnet', 'residue'], ascending=[True, True])
29    freq_set = set(list(exp_pd["magnet"]))
30    chain_set = set(list(exp_pd["chain"])) 
31    if len(chain_set) == 0:
32        to_dock = False
33        sys.stderr.write("must be at least 1 chain")
34    elif len(chain_set) == 1:
35        to_dock = False
36    elif len(chain_set) == 2:
37        to_dock = True
38    elif len(chain_set) > 2:
39        sys.stderr.write("More than 2 chains are not supported")
40    return to_dock
41   
Note: See TracBrowser for help on using the repository browser.