forked from eisenlab/SliceSeq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
FB2name.py
34 lines (28 loc) · 1.12 KB
/
FB2name.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
from argparse import ArgumentParser, FileType
import sys
parser = ArgumentParser()
parser.add_argument('-r', dest="reference",
help="File with conversions between names",
default="Reference/dmelfbgns.txt")
parser.add_argument('-k', dest="keys", action='append',
help="columns to output", type=int, default = [])
parser.add_argument('-i', dest='idkey', type=int, default=0,
help="The key with the FBgn number (printed by default)")
parser.add_argument('filelist', type=FileType('r'), default=[sys.stdin],
nargs='*', action='store')
options = parser.parse_args()
NameFile = options.reference or 'Reference/dmelfbgns.txt'
idkey = options.idkey
fs = '\t'
FB2name = {}
for line in file(NameFile):
s = line.split()
FB2name[s[0]] = s[1]
sys.stderr.write(str(options.filelist) + '\n')
for infile in options.filelist:
sys.stderr.write(str(infile) + "\n")
for line in infile:
s = line.split()
print (s[idkey] in FB2name and FB2name[s[idkey]]) or s[idkey],
print fs,
print fs.join(s[key] for key in options.keys)