-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmerge-selection-lists.py
43 lines (36 loc) · 1.02 KB
/
merge-selection-lists.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
#!/usr/bin/env python2
list1file = './manualselected-herg25oc1.txt'
list2file = './figs/manual-unselected-validation-herg25oc1.txt'
list1IsSelect = True
list2IsSelect = False
saveas = './manualv2selected-herg25oc1.txt'
description = "Based on manual selection of staircase-ramp (with auto QC)" \
+ " and validation recordings."
if not list1IsSelect:
raise ValueError('List 1 provided must be a selection list')
# Read lists
list1 = []
with open(list1file, 'r') as f:
for l in f:
if not l.startswith('#'):
list1.append(l.split()[0])
list2 = []
with open(list2file, 'r') as f:
for l in f:
if not l.startswith('#'):
list2.append(l.split()[0])
# Start merging
if list2IsSelect:
for i in list2:
if i not in list1:
list1.append(i)
list1.sort()
else:
for i in list2:
if i in list1:
list1.remove(i)
# Save merged list
with open(saveas, 'w') as f:
f.write('# ' + description + '\n')
for i in list1:
f.write(i + '\n')