Changeset 1654 in rotdif


Ignore:
Timestamp:
Feb 18, 2019, 10:01:39 PM (17 months ago)
Author:
yuexi
Message:

ELM folder

File:
1 edited

Legend:

Unmodified
Added
Removed
  • bin/main_elm.py

    r1647 r1654  
    2626from subprocess import Popen, PIPE, STDOUT
    2727from os.path import join
     28import shutil
    2829
    2930def message_box(text,icon):
     
    4748    return
    4849
    49 def rotdif():
     50def rotdif(Pdbfilename,sub_dir):
    5051    output_res = {}
    5152    json_variables = " "
     
    5354    argv_io_string = StringIO(sys.argv[1])
    5455    json_variables = json.load(argv_io_string)
    55     pdb_location   = json_variables['pdb_location']
    56     PdbStr = pdb_location[0]
    57     Pdbfilename = os.path.basename(PdbStr)
     56    #pdb_location   = json_variables['pdb_location']
     57    #PdbStr = pdb_location[0]
     58    #Pdbfilename = os.path.basename(PdbStr)
    5859## UDP messaging ##################################################
    5960    UDP_IP = json_variables['_udphost']
     
    9899    stdout_rotdif = os.fdopen(master_rotdif, 'r', 0)
    99100    rotdif_log = open('ELM_prediction','w')
    100     path_to_live_log = str(base_dir) + "/" + 'ELM_prediction'
     101    path_to_live_log = join(str(base_dir),join(str(sub_dir),'ELM_prediction'))
    101102    error_string_md = ''
    102103    timeout = 4 # seconds
     
    158159
    159160if __name__ == "__main__":
    160     output_res,base_dir = rotdif()   
     161    output_res = {}
     162    json_variables = " "
     163    InitialDirectoryStr = os.path.abspath(os.path.dirname(sys.argv[0]))
     164    argv_io_string = StringIO(sys.argv[1])
     165    json_variables = json.load(argv_io_string)
     166    pdb_location   = json_variables['pdb_location']
     167    PdbStr = pdb_location[0]
     168    Pdbfilename = os.path.basename(PdbStr)
     169    run_name = json_variables['run_name']
     170    sub_dir = "ELM_"+run_name
     171    #output_res,base_dir = rotdif(sub_dir)
     172    if os.path.isdir(sub_dir):
     173        sys.stderr.write("Run name already existed!")
     174    else:   
     175        os.mkdir(sub_dir)
     176    new_pdb = join(sub_dir,Pdbfilename)
     177    shutil.move(Pdbfilename,new_pdb)
     178    os.chdir(sub_dir)
     179    output_res,base_dir = rotdif(Pdbfilename, sub_dir)
    161180    #save elm
    162     elm_out = [str(base_dir) + "/" + 'ELM_prediction']   
     181    elm_out = [join(str(base_dir),join(sub_dir,'ELM_prediction'))]
     182    with open('test.txt','w') as wf:
     183        wf.write(str(elm_out)+'\n'+str(base_dir))       
    163184    #save params
    164     with open(join(str(base_dir),"ELM_prediction")) as in_f:
     185    with open(join(str(base_dir),join(sub_dir,"ELM_prediction"))) as in_f:
    165186        tmp = in_f.readlines()
    166187    tmp[0]="Parameters\n"
    167     with open(join(str(base_dir),"ELM_params"),'w') as out_f:
     188    with open(join(str(base_dir),join(sub_dir,"ELM_params")),'w') as out_f:
    168189        for items in tmp[:17]:
    169190            out_f.write(items)
    170     elm_params = [str(base_dir)+"/"+"ELM_params"]
     191    elm_params = [join(str(base_dir),join(sub_dir,"ELM_params"))]
    171192    output_res[ 'elm_out' ] = elm_out
    172193    output_res['elm_params'] = elm_params
Note: See TracChangeset for help on using the changeset viewer.