forked from 865699871/gCAnno
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuildModelPipline.py
72 lines (57 loc) · 2.24 KB
/
buildModelPipline.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
import os
import time
from pipline.buildGraph import buildGraph
from pipline.embedding import embeddingGraph, distanceMatrix
import argparse
def main():
parser = argparse.ArgumentParser(description='gcAnno for model building')
parser.add_argument('-o','--outdir')
parser.add_argument('-e','--exp')
parser.add_argument('-c','--celltype')
parser.add_argument('-fr', '--filterRate', default=0.3, type=float)
args = parser.parse_args()
outdir = args.outdir
expdataFile = args.exp
clusterFile = args.celltype
filterRate = args.filterRate
if not os.path.exists(outdir):
os.makedirs(outdir)
environment01 = outdir + 'buildGraph/'
environment02 = outdir + 'embedding/'
logfile = outdir + 'logembedding.txt'
logfile = open(logfile, 'w')
print('buildGraph....')
logfile.write('buildGraph....\n')
logfile.flush()
time_start = time.time()
if not os.path.exists(environment01):
os.makedirs(environment01)
print('start build Graph')
logfile.write('start build Graph\n')
logfile.flush()
buildGraph(expdataFile, environment01, clusterFile,filterRate=filterRate)
time_end = time.time()
print('buildGraph cost', (time_end - time_start) / 60)
print('-------------------------------------------------------------')
logfile.write('buildGraph cost ' + str((time_end - time_start) / 60) + '\n')
logfile.write('-------------------------------------------------------------\n')
logfile.flush()
print('embedding....')
logfile.write('embedding....\n')
logfile.flush()
time_start = time.time()
if not os.path.exists(environment02):
os.makedirs(environment02)
print('start embedding')
logfile.write('start embedding\n')
logfile.flush()
embeddingGraph(environment01 + '01.graph.txt', environment02)
distanceMatrix(environment02, clusterFile)
time_end = time.time()
print('embedding cost', (time_end - time_start) / 60)
print('-------------------------------------------------------------')
logfile.write('embedding cost ' + str((time_end - time_start) / 60) + '\n')
logfile.write('-------------------------------------------------------------\n')
logfile.flush()
if __name__ == '__main__':
main()