source: rotdif/bin/main_elmdock.py @ 1699

Last change on this file since 1699 was 1699, checked in by yuexi, 2 years ago

before ellipsoid

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1#!/usr/bin/python
2import os,sys
3import glob
4import re
5import shutil
6import sys
7import subprocess
8import json
9import cStringIO
10import shlex 
11import socket
12import time
13import pty
14import select
15import atexit
16import signal
17import functools
18import itertools
19import math
20import pandas as pd
21import numpy as np
22from itertools import groupby
23from matplotlib import cm, colors
24from StringIO import StringIO
25from subprocess import Popen, PIPE, STDOUT
26from os.path import join
27#import our functions
28from run_rotdif_elmdock import rotdif
29from plot_2d_3d import plot_2d_3d
30from plot_exp_elmdock import exp_plot
31from plot_vec import vec_plot
32from plot_iso import iso_plot
33from plot_axi import axi_plot
34from plot_ani import ani_plot
35from plot_diso import diso_plot
36from plot_daxi import daxi_plot
37from plot_dani import dani_plot
38from plot_chi2 import chi2_plot
39from save_elm import save_elm
40from save_dock_elmdock import save_dock
41from indicator_chain import dock
42from StringIO import StringIO
43import shutil
44import sys
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    run_name = json_variables['run_name']
54    #create subfolders
55    sub_dir = run_name + "_ELMDOCK"
56    if os.path.isdir(sub_dir):
57        sys.stderr.write("run name already used\n")
58    else:
59        os.mkdir(sub_dir)
60    old_relax = os.path.basename(json_variables['relax_location'][0])
61    old_pdb = os.path.basename(json_variables['pdb_location'][0])
62    to_dock = dock(old_relax)
63    if to_dock == True:
64        new_pdb = join(sub_dir, old_pdb)
65        new_relax = join(sub_dir, old_relax)
66        shutil.move(old_pdb,new_pdb)
67        shutil.move(old_relax,new_relax)
68        os.chdir(sub_dir)
69        output_res, base_dir, dyna_flag, elm_flag, elmdock_flag,relax_loc = rotdif(to_dock,new_relax, new_pdb,sub_dir)
70        exp_keys = exp_plot(color_list, dyna_flag, elm_flag, elmdock_flag,relax_loc)[1]
71        outputmd_arr_files = []
72
73        if dyna_flag == True:
74            output_res[ 'diso_plot' ] = diso_plot(color_list, exp_keys, to_dock, dyna_flag, elm_flag, elmdock_flag)
75            output_res[ 'daxi_plot' ] = daxi_plot(color_list, exp_keys, to_dock, dyna_flag, elm_flag, elmdock_flag)
76            output_res[ 'dani_plot' ] = dani_plot(color_list,exp_keys, to_dock, dyna_flag, elm_flag, elmdock_flag)
77 
78        if elm_flag == True:
79            save_elm(dyna_flag, elm_flag, elmdock_flag)
80            elm_out = ['ELM_prediction']
81            output_res[ 'elm_out' ] = elm_out   
82
83        if elmdock_flag == True:
84            save_dock(dyna_flag, elm_flag, elmdock_flag)     
85            output_res[ 'elmdock_out' ] = [join(str(base_dir),join(sub_dir,'ELMDOCK'))]
86            output_res[ 'pdb'] = [join(str(base_dir), join(sub_dir,'out_dock.pdb'))]
87            view_pdb = join(str(base_dir), join(sub_dir,'out_dock.pdb'))
88            output_res['outputpdb'] = { "file" : view_pdb, "script" : "ribbon ONLY" }
89       
90        output_res[ 'outputrotdif' ] = [join(str(base_dir), join(sub_dir,'elmdock_log.out'))]
91        print (json.dumps(output_res))
92    else:
93        sys.stderr.write("Only accept 2-domain proteins!")
Note: See TracBrowser for help on using the repository browser.