Exemple #1
0
maxScoreIndex = next(index for (index, d) in enumerate(bestMotifsDict) if d['highestScore'] == max(item['highestScore'] for item in bestMotifsDict))
# Adds the best found motifs into a list
bestMotifs = bestMotifsDict[maxScoreIndex]['motifs']
# Creates a file that reports the best scoring motifs, k and the scoreProfile()
print('Gathering the Best Motifs Done!')


# --------------------------------------------------------------------------------------------------------------


print('3/3 - Applying Profile to Genome...')
profile = mf.constructProfile(bestMotifs)
singleScores = []
# Get each motif's single score and puts the worstScoring motif into a dictionary
for motif in bestMotifs:
    singleScores.append(mf.getSingleScore(profile, motif))
worstScoringMotif = {'Motif': bestMotifs[singleScores.index(min(singleScores))], 'Score': min(singleScores)}

# Getting the reverse complement
reverseComplement = hf.getSecondStrand(fileToRead)
dnaScores = hf.gatherFinalResults(profile, fileToRead, worstScoringMotif, 1) + hf.gatherFinalResults(profile, reverseComplement, worstScoringMotif, 2)

print('Applying Profile to Genome Done!')

# Reporting the results to a file
hf.writeFile('Results/Profile.json', profile, singleScores, bestMotifs, dnaScores, bestMotifsDict[maxScoreIndex])

print('Done!')


# --------------------------------------------------------------------------------------------------------------
Exemple #2
0
""" File containing the functions test for motifFinder.py """
import motifFinder


# Tests ------------------------------------------------------------------

print(motifFinder.readInput('TraR.txt'))
print(motifFinder.randomStart(['ACACGTAC', 'CCACGTCACA', 'TTCGTCGTACG'], 4))
print(motifFinder.getMotif(['ACACGTAC', 'CCACGTCACA', 'TTCGTCGTACG'], [3, 5, 2], 4))
print(motifFinder.constructProfile(['CGTA', 'TCAC', 'CGTC']))
print(motifFinder.getSingleScore(motifFinder.constructProfile(['CGTA', 'TCAC', 'CGTC']), 'CACA'))
print(motifFinder.applyProfile(motifFinder.constructProfile(['CGTA', 'TCAC', 'CGTC']), 'CCACGTCACA'))
print(motifFinder.randomlySelect([0.014994, 0.001249, 0.000833, 0.033736, 0.000833, 0.009996, 0.002499]))
print(motifFinder.nucleotideFrequencies(['ACACGTAC', 'CCACGTCACA', 'TTCGTCGTACG']))
print(motifFinder.scoreProfile([{'A': 0.142857, 'C': 0.428571, 'G': 0.142857, 'T': 0.285714}, {'A': 0.142857, 'C': 0.285714, 'G': 0.428571, 'T': 0.142857}, {'A': 0.285714, 'C': 0.142857, 'G': 0.142857, 'T': 0.428571}, {'A': 0.285714, 'C': 0.428571, 'G': 0.142857, 'T': 0.142857}], {'A': 0.241379, 'C': 0.379310, 'G': 0.172413, 'T': 0.206897}))