<commit_before>#! /usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
import logging
import time
import math
import multiprocessing
import breakmer.processor.target as target
import breakmer.utils as utils

__author__ = "<NAME>"
__copyright__ = "Copyright 2015, <NAME>"
__email__ = "<EMAIL>"
__license__ = "MIT"


def check_status(results):
    notready = 0
    for r in results:
        if not r.ready():
            notready += 1
    return (notready)


def wait(results):
    njobs = check_status(results)

    while njobs > 0:
        time.sleep(5)
        jobs = check_status(results)
        if jobs < njobs:
            print '\n', jobs, '/', njobs, " jobs not complete."
            njobs = jobs
        else:
            sys.stdout.write('.')
            sys.stdout.flush()


def analyze_targets(targetList):
    """Analyze a list of targets.
    A list of TargetManager objects are passed in to be analyzed independently.
    Each target ref data is set, if necessary, then the reads are extracted,
    contigs built, and calls made.
    Args:
        targetList: A list of TargetManager objects, representing target regions.
    Returns:
        None
    """
    aggregateResults = []
    for targetRegion in targetList:
        utils.log('breakmer.processor.analysis', 'info', 'Analyzing %s' % targetRegion.name)
        targetRegion.set_ref_data()

        # If only presetting data stop here.
        if targetRegion.params.get_param('preset_ref_data'):
            continue
        # targetRegion fails to find any interesting reads to use. Exiting.
        if not targetRegion.find_sv_reads():
            continue
        targetRegion.compare_kmers()
        targetRegion.resolve_sv()
        if targetRegion.has_results():
            aggregateResults.extend(targetRegion.get_results())
        targetRegion.complete_analysis()
    return aggregateResults


class RunTracker:
    """Class to manage the running of all the target region analyses.
    The params object is passed in with all the input information.
    The run() function creates the target region objects from the
    param inputs and then starts the analysis for each target.
    Args:
        params: ParamManager object.
    Returns:
        None
    """
    def __init__(self, params):
        self.params = params
        self.results = []
        self.targets = {}
        self.summary = {}
        self.summary_header = ''
        self.loggingName = 'breakmer.processor.analysis'
<commit_msg>Bug fix<commit_after>#! /usr/bin/python
# -*- coding: utf-8 -*-

import os
import sys
import logging
import time
import math
import multiprocessing
import breakmer.processor.target as target
import breakmer.utils as utils

__author__ = "<NAME>"
__copyright__ = "Copyright 2015, <NAME>"
__email__ = "<EMAIL>"
__license__ = "MIT"


def check_status(results):
    notready = 0
    for r in results:
        if not r.ready():
            notready += 1
    return (notready)


def wait(results):
    njobs = check_status(results)

    while njobs > 0:
        time.sleep(5)
        jobs = check_status(results)
        if jobs < njobs:
            print '\n', jobs, '/', njobs, " jobs not complete."
            njobs = jobs
        else:
            sys.stdout.write('.')
            sys.stdout.flush()


def analyze_targets(targetList):
    """Analyze a list of targets.
    A list of TargetManager objects are passed in to be analyzed independently.
    Each target ref data is set, if necessary, then the reads are extracted,
    contigs built, and calls made.
    Args:
        targetList: A list of TargetManager objects, representing target regions.
    Returns:
        None
    """
    aggregateResults = []
    print 'Multiprocessing name', multiprocessing.current_process().name
    for targetRegion in targetList:
        utils.log('breakmer.processor.analysis', 'info', 'Analyzing %s' % targetRegion.name)
        targetRegion.set_ref_data()

        # If only presetting data stop here.
        if targetRegion.params.get_param('preset_ref_data'):
            continue
        # targetRegion fails to find any interesting reads to use. Exiting.
        if not targetRegion.find_sv_reads():
            continue
        targetRegion.compare_kmers()
        targetRegion.resolve_sv()
        print multiprocessing.current_process().name, 'finished resolve_sv'
        if targetRegion.has_results():
            aggregateResults.extend(targetRegion.get_results())
        targetRegion.complete_analysis()
    return aggregateResults


class RunTracker:
    """Class to manage the running of all the target region analyses.
    The params object is passed in with all the input information.
    The run() function creates the target region objects from the
    param inputs and then starts the analysis for each target.
    Args:
        params: ParamManager object.
    Returns:
        None
    """
    def __init__(self, params):
        self.params = params
        self.results = []
        self.targets = {}
        self.summary = {}
        self.summary_header = ''
        self.loggingName = 'breakmer.processor.analysis'

{'fraction_non_alphanumeric': 0.08738053442559002, 'fraction_numerical': 0.003510825043885313, 'mean_word_length': 2.53168044077135, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1981675', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1371, 'n_words': 461}