Created
December 4, 2013 13:39
-
-
Save heliy/7787535 to your computer and use it in GitHub Desktop.
转录因子文件的处理。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#transfactor | |
def factorlist(filename): | |
fl=[] | |
factor={} | |
for line in open(filename,'r').readlines(): | |
if line=='XX\n':continue #Lines for split | |
if line=='//\n': | |
if len(factor)==0:continue # Have NO info | |
else: | |
fl.append(factor) #Add factor | |
factor={} #For the next factor | |
continue | |
cons=line.split(' ') | |
if False==factor.has_key(cons[0]): | |
factor[cons[0]]=cons[1] | |
else: | |
factor[cons[0]]=factor[cons[0]]+cons[1] | |
return fl | |
fl=factorlist('factor.dat') | |
for factor in fl: | |
if factor['OS']=='human, Homo sapiens\n': | |
print 'AC:',factor['AC'] | |
for record in factor['BS'].split('\n'): | |
if 'human, Homo sapiens' in record: | |
print 'BS:',record | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment