0
|
1 import csv
|
|
2 import sys
|
|
3
|
|
4 __author__ = "Marcel Kempenaar"
|
|
5 __contact__ = "brs@nbic.nl"
|
|
6 __copyright__ = "Copyright, 2012, Netherlands Bioinformatics Centre"
|
|
7 __license__ = "MIT"
|
|
8
|
|
9 in_file = sys.argv[1]
|
|
10 out_file = sys.argv[2]
|
|
11 to_select_list = [str(select.strip()) for select in sys.argv[3].split(',') if (len(select) > 0)]
|
|
12
|
|
13 data = list(csv.reader(open(in_file, 'rb'), delimiter='\t'))
|
|
14 header = data.pop(0)
|
|
15 header_clean = [i.lower().strip().replace(".", "").replace("%", "") for i in header]
|
|
16 rank = header_clean.index("rank")
|
|
17
|
|
18 writer = csv.writer(open(out_file, 'wb'), delimiter='\t')
|
|
19 writer.writerow(header)
|
|
20 for select in to_select_list:
|
|
21 writer.writerows([i for i in data if i[rank] == select])
|