annotate predict/ct_to_dot.py @ 119:7bb98e9296e9 draft default tip

Uploaded
author tyty
date Tue, 14 Apr 2015 14:18:40 -0400
parents 43ea205aa49e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
102
43ea205aa49e Uploaded
tyty
parents:
diff changeset
1 #!/usr/bin/env python
43ea205aa49e Uploaded
tyty
parents:
diff changeset
2 # -*- coding: utf-8 -*-
43ea205aa49e Uploaded
tyty
parents:
diff changeset
3
43ea205aa49e Uploaded
tyty
parents:
diff changeset
4 import sys
43ea205aa49e Uploaded
tyty
parents:
diff changeset
5 import shlex
43ea205aa49e Uploaded
tyty
parents:
diff changeset
6 import os
43ea205aa49e Uploaded
tyty
parents:
diff changeset
7 import subprocess
43ea205aa49e Uploaded
tyty
parents:
diff changeset
8 from read_file import *
43ea205aa49e Uploaded
tyty
parents:
diff changeset
9
43ea205aa49e Uploaded
tyty
parents:
diff changeset
10 ct_file = sys.argv[1]
43ea205aa49e Uploaded
tyty
parents:
diff changeset
11 path = sys.argv[2]
43ea205aa49e Uploaded
tyty
parents:
diff changeset
12 id_s = sys.argv[3]
43ea205aa49e Uploaded
tyty
parents:
diff changeset
13 result_file = sys.argv[4]
43ea205aa49e Uploaded
tyty
parents:
diff changeset
14
43ea205aa49e Uploaded
tyty
parents:
diff changeset
15 h = file(result_file, 'w')
43ea205aa49e Uploaded
tyty
parents:
diff changeset
16 os.system('grep "'+id_s+'" '+ct_file+' |wc -l > '+path+'/count.txt')
43ea205aa49e Uploaded
tyty
parents:
diff changeset
17 count = read_t_file(path+'/count.txt')
43ea205aa49e Uploaded
tyty
parents:
diff changeset
18 comm = ''
43ea205aa49e Uploaded
tyty
parents:
diff changeset
19 for i in range(int(count[0][0])):
43ea205aa49e Uploaded
tyty
parents:
diff changeset
20 command = shlex.split('ct2dot %s %s %s' % (ct_file, str(i+1), os.path.join(path, 'db_file_%s.dbnn' % str(i+1))))
43ea205aa49e Uploaded
tyty
parents:
diff changeset
21 subprocess.call(command)
43ea205aa49e Uploaded
tyty
parents:
diff changeset
22 comm = comm +' '+path+'/db_file_'+str(i+1)+'.dbnn'
43ea205aa49e Uploaded
tyty
parents:
diff changeset
23
43ea205aa49e Uploaded
tyty
parents:
diff changeset
24
43ea205aa49e Uploaded
tyty
parents:
diff changeset
25
43ea205aa49e Uploaded
tyty
parents:
diff changeset
26 os.system('cat'+comm+' > '+result_file)
43ea205aa49e Uploaded
tyty
parents:
diff changeset
27 for i in range(int(count[0][0])):
43ea205aa49e Uploaded
tyty
parents:
diff changeset
28 command = shlex.split('rm %s' % (os.path.join(path, 'db_file_%s.dbnn' % str(i+1))))
43ea205aa49e Uploaded
tyty
parents:
diff changeset
29 subprocess.call(command)
43ea205aa49e Uploaded
tyty
parents:
diff changeset
30 command = shlex.split('rm %s' % (os.path.join(path, 'count.txt')))
43ea205aa49e Uploaded
tyty
parents:
diff changeset
31 subprocess.call(command)
43ea205aa49e Uploaded
tyty
parents:
diff changeset
32
43ea205aa49e Uploaded
tyty
parents:
diff changeset
33
43ea205aa49e Uploaded
tyty
parents:
diff changeset
34
43ea205aa49e Uploaded
tyty
parents:
diff changeset
35 h.close()
43ea205aa49e Uploaded
tyty
parents:
diff changeset
36