-
Notifications
You must be signed in to change notification settings - Fork 0
/
motifArrayMaker.py
36 lines (29 loc) · 1.11 KB
/
motifArrayMaker.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
#
# USE: python motifMaker.py <number of seeds> <number of footprints> <min footprint length> <max footprint length> <outfile name>
# OUTPUT: Footprint sequence, sequence position(number), motif start position, Seed info (list)
import random
import sys
#how long should the generated motifs be? (Change to an input for a command/bash?)
maxMotifLength = 7
# motifLength = int(sys.argv[1])
#alternative mass generation
minMotifLength = 5
maxMotifLength = 9
bases = ['A','T','G','C']
def recMotifDictBuilder(listMotifs,currMotif,lengthCount):
if lengthCount <= 0:
listMotifs = listMotifs + currMotif + "\": 0, \""
return listMotifs
else:
for base in bases:
listMotifs = recMotifDictBuilder(listMotifs, currMotif + base, lengthCount - 1)
return listMotifs
# main. Get info, generate motif tuple, write footprints to output.
# motifLength = int(sys.argv[1])
outfile = open('variableSet.py', 'w')
for i in range(minMotifLength,maxMotifLength):
outfile.write("\n\nmotifDictL" + str(i) + " = ")
motifDict = recMotifDictBuilder("","",i)
motifDict = "{\"" + motifDict[:-3] + "}"
outfile.write(motifDict)
outfile.close()