Skip to content

Instantly share code, notes, and snippets.

@readbio
Created January 29, 2016 23:08
Show Gist options
  • Save readbio/e9de7fd045d017993bd0 to your computer and use it in GitHub Desktop.
Save readbio/e9de7fd045d017993bd0 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
import sys
import re
gene_list = sys.argv[1]
motif = sys.argv[2]
#print(gene_list)
#print(motif)
dict_motif = {}
with open(motif) as f:
for line in f:
line.rstrip('\n')
line = line.replace(".promoter", "")
ele = line.split()
dict_motif[ele[1]] = ele[0]
with open(gene_list) as f:
for line in f:
line = line.rstrip('\n')
#print(line)
if not line.startswith('AT'):
line = line + "\tmotif"
list_ele = re.split(r'\t+', line)
if dict_motif.has_key(list_ele[0]):
motif_num = dict_motif.get(list_ele[0])
line = line + "\t" + str(motif_num)
print line
else:
line = line + "\t" + "None";
print line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment