-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathAtannoByLocus.py
executable file
·46 lines (43 loc) · 1.42 KB
/
AtannoByLocus.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
44
45
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#from __future__ import division, with_statement
'''
Copyright 2010, 陈同 ([email protected]).
Please see the license file for legal information.
===========================================================
'''
__author__ = 'chentong & ct586[9]'
__author_email__ = '[email protected]'
#=========================================================
import sys
def readAnno(annofile, head=1):
aDict = {}
for line in open(annofile):
if head:
head -= 1
continue
#--------------------------
key, value = line.strip().split('\t',1)
if key not in aDict:
aDict[key] = value
else:
print >>sys.stderr, "duplicated key %s" % key
#------------------------------
#---------------End reading-------------
return aDict
#--------------------------------------------
def main():
print >>sys.stderr, "Print the result to screen"
if len(sys.argv) != 3:
print >>sys.stderr, 'Using python %s locus anno' % sys.argv[0]
sys.exit(0)
#--------------------------------------------
locusFile = sys.argv[1]
annofile = sys.argv[2]
aDict = readAnno(annofile)
for line in open(locusFile):
locus = line.strip()
print "%s\t%s" % (locus, aDict[locus])
#-----------------------------------------------------
if __name__ == '__main__':
main()