Exemple #1
0
import motifFinder as mf
import helperFunctions as hf
from time import time, sleep
from multiprocessing import Pool
from functools import partial
import sys


# Running the program:
print('Running...')
print('1/3 - Applying Gibbs Sampling...')
# List for the multiprogramming pool
bestMotifsRes = []
# List of best motifs returned by gibbsSampling()
bestMotifsDict = []
fileToRead = mf.readInput('TraR.txt')
# Only used to print time values on the screen for reference
startTime = time()

# Number of times we'll run gibbsSampling()
iterable = range(2000)
# Max and min motifs sizes
minMotifSize = 12
maxMotifSize = 20
for kmerSize in range(minMotifSize, maxMotifSize + 1):
    pool = Pool()
    function = partial(mf.gibbsSampling, fileToRead, kmerSize, 200)
    bestMotifsRes = pool.map_async(function, iterable)
    # Updates the percentage on the console screen
    while not bestMotifsRes.ready():
        remaining = 100 - (bestMotifsRes._number_left * bestMotifsRes._chunksize / (len(iterable) / 100))
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}))