Skip to content

Instantly share code, notes, and snippets.

@heliy
Created December 4, 2013 13:39
Show Gist options
  • Save heliy/7787535 to your computer and use it in GitHub Desktop.
Save heliy/7787535 to your computer and use it in GitHub Desktop.
转录因子文件的处理。
#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