<commit_before>'''
PathwayGenie (c) University of Manchester 2017

PathwayGenie is licensed under the MIT License.

To view a copy of this license, visit <http://opensource.org/licenses/MIT/>.

@author:  neilswainston
'''
from threading import Thread
import json
import time

from ice.ice import IceThread
from parts_genie.parts import PartsThread
from plasmid_genie.plasmid import PlasmidThread


# from metabolomics_genie.metabolomics import MetabolomicsThread
class PathwayGenie(object):
    '''Class to run PathwayGenie application.'''

    def __init__(self):
        self.__status = {}
        self.__threads = {}
        self.__writers = {}

    def submit(self, data):
        '''Responds to submission.'''
        query = json.loads(data)

        # Do job in new thread, return result when completed:
        job_ids = []
        threads = _get_threads(query)

        for thread in threads:
            job_id = thread.get_job_id()
            job_ids.append(job_id)
            thread.add_listener(self)
            self.__threads[job_id] = thread

        # Start new Threads:
        for thread in threads:
            thread_pool = ThreadPool(threads)
            thread_pool.start()

        return job_ids

    def get_progress(self, job_id):
        '''Returns progress of job.'''
        def _check_progress(job_id):
            '''Checks job progress.'''<commit_msg>Fixed issue with attempting to start same thread multiple times.<commit_after>'''
PathwayGenie (c) University of Manchester 2017

PathwayGenie is licensed under the MIT License.

To view a copy of this license, visit <http://opensource.org/licenses/MIT/>.

@author:  neilswainston
'''
from threading import Thread
import json
import time

from ice.ice import IceThread
from parts_genie.parts import PartsThread
from plasmid_genie.plasmid import PlasmidThread


# from metabolomics_genie.metabolomics import MetabolomicsThread
class PathwayGenie(object):
    '''Class to run PathwayGenie application.'''

    def __init__(self):
        self.__status = {}
        self.__threads = {}
        self.__writers = {}

    def submit(self, data):
        '''Responds to submission.'''
        query = json.loads(data)

        # Do job in new thread, return result when completed:
        job_ids = []
        threads = _get_threads(query)

        for thread in threads:
            job_id = thread.get_job_id()
            job_ids.append(job_id)
            thread.add_listener(self)
            self.__threads[job_id] = thread

        # Start new Threads:
        thread_pool = ThreadPool(threads)
        thread_pool.start()

        return job_ids

    def get_progress(self, job_id):
        '''Returns progress of job.'''
        def _check_progress(job_id):
            '''Checks job progress.'''
{'fraction_non_alphanumeric': 0.08908045977011494, 'fraction_numerical': 0.0028735632183908046, 'mean_word_length': 2.6887417218543046, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5685664', 'n_tokens_mistral': 815, 'n_tokens_neox': 772, 'n_words': 234}