source: rotdif/bin/main_rotdif.py @ 1655

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

rotdif subfolder

  • Property svn:executable set to *
File size: 3.9 KB
Line 
1#!/usr/bin/python
2from os.path import join
3import os
4import glob
5import re
6import shutil
7import sys
8import subprocess
9import json
10import cStringIO
11import shlex 
12import socket
13import time
14import pty
15import select
16import atexit
17import signal
18import functools
19import itertools
20import math
21import pandas as pd
22import numpy as np
23from itertools import groupby
24from matplotlib import cm, colors
25from StringIO import StringIO
26from subprocess import Popen, PIPE, STDOUT
27
28#import our functions
29from run_rotdif import rotdif
30from plot_2d_3d import plot_2d_3d
31from plot_exp import exp_plot
32from plot_vec import vec_plot
33from plot_iso import iso_plot
34from plot_axi import axi_plot
35from plot_ani import ani_plot
36from plot_diso import diso_plot
37from plot_daxi import daxi_plot
38from plot_dani import dani_plot
39from plot_chi2 import chi2_plot
40from save_elm import save_elm
41from save_dock import save_dock
42from indicator_chain import dock
43from StringIO import StringIO
44import shutil
45
46if __name__ == "__main__":
47    color_list=[ '#1f77b4','#ff7f0e','#2ca02c','#d62728', '#9467bd',\
48'#8c564b', '#e377c2', '#7f7f7f', '#bcbd22','#17becf']
49    json_variables = " " 
50    InitialDirectoryStr = os.path.abspath(os.path.dirname(sys.argv[0]))
51    argv_io_string = StringIO(sys.argv[1])
52    json_variables = json.load(argv_io_string)
53    relax_location = json_variables['relax_location']
54    old_relax = os.path.basename(relax_location[0])
55    to_dock = dock(old_relax)
56    pdb_location = json_variables['pdb_location']
57    old_pdb = os.path.basename(pdb_location[0])
58
59    run_name = json_variables['run_name']
60    sub_dir = "ROTDIF_" + run_name
61    if os.path.isdir(sub_dir):
62        pass
63    else:
64        os.mkdir(sub_dir)
65
66    new_relax = join(sub_dir,old_relax)
67    new_pdb = join(sub_dir,old_pdb)
68    shutil.move(old_relax,new_relax)
69    shutil.move(old_pdb, new_pdb)
70    os.chdir(sub_dir)
71    output_res, base_dir, dyna_flag, elm_flag, elmdock_flag = rotdif(to_dock,old_pdb,old_relax,sub_dir)
72    exp_graph,exp_keys,exp_resi,dyna_resi = exp_plot(color_list, dyna_flag, elm_flag, elmdock_flag,old_relax)
73    outputmd_arr_files = []
74    log_out = [join(str(base_dir),join(sub_dir,'rotdif_log.out'))]
75    ani_out = [join(str(base_dir),join(sub_dir, 'out_ani.py'))]
76    axi_out = [join(str(base_dir),join(sub_dir, 'out_axial.py'))]
77
78    if dyna_flag == True:
79        output_res[ 'diso_plot' ] = diso_plot(color_list, exp_keys, to_dock, dyna_flag, elm_flag, elmdock_flag)
80        output_res[ 'daxi_plot' ] = daxi_plot(color_list, exp_keys, to_dock, dyna_flag, elm_flag, elmdock_flag)
81        output_res[ 'dani_plot' ] = dani_plot(color_list,exp_keys, to_dock, dyna_flag, elm_flag, elmdock_flag)
82 
83    if elm_flag == True:
84        save_elm(dyna_flag, elm_flag, elmdock_flag)
85        elm_out = [join(str(base_dir),join(sub_dir,'ELM_prediction'))]
86        output_res[ 'elm_out' ] = elm_out   
87
88    if elmdock_flag == True:
89        save_dock(dyna_flag, elm_flag, elmdock_flag)
90        dock_out = [join(str(base_dir),join(sub_dir, 'ELMDOCK'))]     
91        output_res[ 'elmdock' ] = dock_out
92        dock_pdb = [join(str(base_dir),join(sub_dir, 'out_dock.pdb'))]
93        output_res[ 'pdb'] = dock_pdb
94        output_res['outputpdb'] = dock_pdb
95
96    #get residule numbers for the vector plot
97    output_res[ 'outputrotdif' ] = log_out
98    output_res[ 'ani_out' ] = ani_out
99    output_res[ 'axi_out' ] = axi_out
100    output_res[ 'exp_plot' ] = exp_graph
101    output_res[ 'vec_plot' ] = vec_plot(exp_resi)
102    output_res[ 'chi2_plot' ] = chi2_plot()
103    output_res[ 'plot_2d' ] = plot_2d_3d(color_list, exp_keys)[0]
104    output_res[ 'plot_3d' ]  = plot_2d_3d(color_list, exp_keys)[1]
105    output_res[ 'iso_plot' ] = iso_plot(exp_resi, color_list,exp_keys, dyna_flag, elm_flag, elmdock_flag)
106    output_res[ 'axi_plot' ] = axi_plot(exp_resi, color_list,exp_keys, dyna_flag, elm_flag, elmdock_flag)
107    output_res[ 'ani_plot' ] = ani_plot(exp_resi, color_list,exp_keys, dyna_flag, elm_flag, elmdock_flag)
108    print (json.dumps(output_res))
Note: See TracBrowser for help on using the repository browser.