-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb2.py
More file actions
executable file
·47 lines (38 loc) · 967 Bytes
/
Copy pathdb2.py
File metadata and controls
executable file
·47 lines (38 loc) · 967 Bytes
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
#!/usr/bin/python
import sys,os
def next_family(ifp):
family = None
flag_head = True
for line in ifp:
if flag_head :
if 'Family' in line:
flag_head = False
family = list()
family.append(line)
else:
if 'Family' in line:
yield family
family = list()
family.append(line)
else :
family.append(line)
yield family
def get_id(family):
line = family[1]
name = line[46:56].strip()
index = int(name[1:])
return index
def write_family(ofp,family):
for line in family:
ofp.write(line)
# load db2 list
db2_list = list()
for line in open('db2_list'):
db2_list.append( int(line) )
ifp = open('all.db')
ofp = open('tmp','w')
for family in next_family(ifp):
if get_id(family) in db2_list:
write_family(ofp,family)
ofp.close()
print 'Done'