Skip to content

Commit

Permalink
Greedy Motif Search with Pseudocounts (updated)
Browse files Browse the repository at this point in the history
Slightly refactored code to make it simpler.  Functionality is still
exactly the same, with a possibly slight performance improvement.
  • Loading branch information
jschendel committed Feb 23, 2014
1 parent 1dd1f3e commit 77f1602
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Textbook_03E.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

def profile_with_pseudocounts(motifs):
'''Returns the profile of the dna list motifs.'''
columns = (''.join([motifs[j][i] for j in xrange(len(motifs))]) for i in xrange(len(motifs[0])))
columns = [''.join(seq) for seq in zip(*motifs)]
return [[float(col.count(nuc)+1) / float(len(col)+4) for nuc in 'ACGT'] for col in columns]


Expand Down Expand Up @@ -48,7 +48,7 @@ def main():
# Read the input data.
with open('data/textbook/rosalind_3e.txt') as input_data:
k, t = map(int, input_data.readline().split())
dna_list = [line.strip() for line in input_data.readlines()]
dna_list = [line.strip() for line in input_data]

# Run the Greedy Motif Search with Pseudocounts.
best_motifs = greedy_motif_search_pseudocounts(dna_list, k, t)
Expand Down

0 comments on commit 77f1602

Please sign in to comment.