def main1():
    input_dna = '''ttACCTtaac
gATGTctgtc
ccgGCGTtag
cactaACGAg
cgtcagAGGT'''
    dna = [Seq(line.strip(), IUPAC.unambiguous_dna) for line in input_dna.upper().split('\n')]
    input_motifs = '''ttac
gtct
ggcg
taac
gtca'''
    motifs = [Seq(line.strip(), IUPAC.unambiguous_dna) for line in input_motifs.upper().split('\n')]
    print_motifs(motifs)

    profile = make_profile(motifs, 4)
    print
    print profile

    print
    new_motifs = []
    for seq in dna:
        new_motifs.append(profile_most_prob(profile, seq, 4))
    print_motifs(new_motifs)

    profile = make_profile(new_motifs, 4)
    print
    print profile

    print
    new_motifs = []
    for seq in dna:
        new_motifs.append(profile_most_prob(profile, seq, 4))
    print_motifs(new_motifs)
def randomized_motif_search(dna, k, t):
    best_motifs = []
    for seq in dna:
        pos = random.randrange(len(seq) - k + 1)
        best_motifs.append(seq[pos:pos + k])

    while True:
        profile = make_profile(best_motifs, k)
        motifs = [profile_most_prob(profile, seq, k) for seq in dna]
        if score_motifs(motifs) < score_motifs(best_motifs):
            best_motifs = motifs
        else:
            return best_motifs