-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsampling.py
114 lines (105 loc) · 3.9 KB
/
sampling.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
from __future__ import print_function
from subprocess import Popen, PIPE
from math import *
import random,os
import numpy as np
import random as pr
from copy import deepcopy
#from types import IntType, ListType, TupleType, StringTypes
import itertools
import time
import math
import argparse
import subprocess
from keras.preprocessing import sequence
from keras.models import model_from_json
#from mpi4py import MPI
import sys,os
from multiprocessing import Pool
from HMUtil.HMpara import *
from MDutil.embedding import *
from HPCUtil.HPCtool import *
from GRURNN.execRNN import *
from GRURNN.execRNN import *
import time
from parameter import *
###############init the service#################
#checkparam()
os.system(AMBERtoolconfig)
os.system(GMXconfig)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
os.environ["KMP_DUPLICATE_LIB_OK"]="TRUE"
import tensorflow as tf
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
##################################################
# evaluation step using homology modeling and MD simulation
def evaluateMD(seqsel,wd,seqfn,HPC,HPCtype,HMpath,HMlib,groupid,qstatcmd):
#Call Homology modeling from here
#jobid=execHM(seqsel,wd,seqfn,HPC,HPCtype,HMpath,HMlib,groupid)
#if HPC==True:
# waitcheck(jobid,qstatcmd)
##Call MD validating from here
#jobid=execMD(len(seqsel),wd,acpype,GMXpath,ntomp,mpicall)
#if HPC==True:
# waitcheck(jobid,qstatcmd)
if HPC==True:
#Call Homology modeling from here
jobid=execHMHPC(seqsel,wd,seqfn,HPC,HPCtype,HMpath,HMlib,groupid)
waitcheck(jobid,qstatcmd)
#Call MD validating from here
jobid=execMDHPC(len(seqsel),wd,acpype,GMXpath,ntomp,mpicall,HPCtype,groupid)
waitcheck(jobid,qstatcmd)
else:
#Call Homology modeling from here
jobid=execHMserial(seqsel,wd,seqfn,HPC,HPCtype,HMpath,HMlib,groupid)
#Call MD validating from here
jobid=execMDserial(len(seqsel),wd,GMXpath,ntomp,mpicall)
return
#user-defined evaluation:
def evaluate(seqsel,wd,seqfn,HPC,HPCtype,HMpath,HMlib,groupid,qstatcmd):
#user defined evaluation from here
##########Explanation for the input of evaluation procedure#########
#seqsel is the list of the selected of the sequence candidates by Neural network
#wd is current working directory
#seqfn is the file containing the sequence list
#HPC is boolean variable to control the activation of using HPC
#HPCtype is the variable to check which HPC is using
#HMlib is the variable indicating the library to I-TASSER
#groupid is the groupid on HPC system
#qstatcmd is the checking status of job on HPC
return valpospep,valnegpep
#main process come from here
def main():
global aalen,aalist,val,wd,geninter,genepoch,peplength,numcore,cutoffrate
genmodroot=genmod
clasmodroot=clasmod
###########sampling the actor-critic model####################
#checking existence of output folder
if not(os.path.isdir(wd)):
os.system("mkdir "+wd)
#call generator and classifier
pool = Pool(processes=numcore)
pepgenerate=pool.map(actcrit,range(genepoch))
tmppepgen=[]
#flattening the output list out of the ranks
for x in range(0,len(pepgenerate)):
for y in range(0,len(pepgenerate[x])):
print(pepgenerate[x][y])
tmppepgen.append(pepgenerate[x][y])
# removing the duplicates between ranks
tmppepgen=list(set(tmppepgen))
#save all to file
fn=open(wd+"/genpep.txt","w")
for x in range(0,len(tmppepgen)):
fn.write(tmppepgen[x]+" \n")
fn.close()
print(tmppepgen)
print(len(tmppepgen))
#call evaluation from here:
if not(usereval):
for seqsel in tmppepgen:
evaluateMD(seqsel,wd,"/genpep.txt",HPC,HPCtype,HMpath,HMlib,groupid,qstatcmd)
else:
for seqsel in tmppepgen:
evaluate(seqsel,wd,"/genpep.txt",HPC,HPCtype,HMpath,HMlib,groupid,qstatcmd)
main()