annotate predict/dot_convert.py @ 109:4e13117db219 draft

Uploaded
author tyty
date Thu, 26 Mar 2015 14:52:19 -0400
parents f1eb39775b93
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
93
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
1 #!/usr/bin/env python
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
2 # -*- coding: utf-8 -*-
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
3
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
4 import sys
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
5
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
6 dot_file = sys.argv[1]
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
7 result_file = sys.argv[2]
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
8
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
9 h = file(result_file, 'w')
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
10 f = open(dot_file)
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
11
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
12
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
13
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
14 for aline in f.readlines():
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
15 line = aline.strip()
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
16 if line.find('>')!=-1:
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
17 id_line = line
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
18 idt = id_line.split('>')
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
19 ids = idt[1].strip()
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
20 else:
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
21 if line.find('(')!=-1:
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
22 structure_line = line
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
23 st = structure_line.split(' ')
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
24 structure = st[0].strip()
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
25 enert = st[1].strip()
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
26 if len(enert)>1:
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
27 enertt = enert.split('(')
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
28 enertt = enertt[1].strip()
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
29 else:
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
30 enertt = st[2].strip()
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
31 enerttt = enertt.split(')')
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
32 ener = enerttt[0].strip()
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
33 h.write('>ENERGY = '+ener+' '+ids+'\n')
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
34 h.write(seq+'\n')
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
35 h.write(structure+'\n')
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
36 else:
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
37 seq = line
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
38
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
39
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
40
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
41
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
42
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
43 f.close()
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
44 h.close()
f1eb39775b93 Uploaded
tyty
parents:
diff changeset
45