Check nested sampling run member keys and values.

    Parameters
    ----------
    run: dict
        nested sampling run to check.

    Raises
    ------
    AssertionError
        if run does not have expected properties.
497797
def check_ns_run_members(run):
    
    run_keys = list(run.keys())
    # Mandatory keys
    for key in ['logl', 'nlive_array', 'theta', 'thread_labels',
                'thread_min_max']:
        assert key in run_keys
        run_keys.remove(key)
    # Optional keys
    for key in ['output']:
        try:
            run_keys.remove(key)
        except ValueError:
            pass
    # Check for unexpected keys
    assert not run_keys, 'Unexpected keys in ns_run: ' + str(run_keys)
    # Check type of mandatory members
    for key in ['logl', 'nlive_array', 'theta', 'thread_labels',
                'thread_min_max']:
        assert isinstance(run[key], np.ndarray), (
            key + ' is type ' + type(run[key]).__name__)
    # check shapes of keys
    assert run['logl'].ndim == 1
    assert run['logl'].shape == run['nlive_array'].shape
    assert run['logl'].shape == run['thread_labels'].shape
    assert run['theta'].ndim == 2
    assert run['logl'].shape[0] == run['theta'].shape[0]
662804
def validate_split_runs_file(split_runs_file):
    """"""
    try:
        content = [l.strip() for l in split_runs_file.readlines()]
        if content[0].upper().split('\t') == ['NAME', 'RUN_ID']:
            return {c.split('\t')[1]: c.split('\t')[0] for c in content[1:] if c}
        else:
            sys.exit("ERROR: Mandatory header of --split_runs tsv file not found: 'NAME', 'RUN_ID'")
            logging.error("Mandatory header of --split_runs tsv file not found: 'NAME', 'RUN_ID'")
    except IndexError:
        sys.exit("ERROR: Format of --split_runs tab separated file not as expected")
        logging.error("ERROR: Format of --split_runs tab separated file not as expected")
940947
def get_run_as_identifiers_stack(self):
        
        session = self.get_session(False)

        try:
            return session.get_internal_attribute(self.run_as_identifiers_session_key)
        except AttributeError:
            return None
1061687
def check_rtl_assertions(sim):
    

    for (w, exp) in sim.block.rtl_assert_dict.items():
        try:
            value = sim.inspect(w)
            if not value:
                raise exp
        except KeyError:
            pass
384938
def execute(self, example_groups):
        
        total_successes, total_errors, total_skipped = 0, 0, 0
        for group in example_groups:
            runner = ExampleRunner(group, self.formatter)
            successes, errors, skips = runner.run()
            total_successes += successes
            total_errors += errors
            total_skipped += skips
        return total_successes, total_errors, total_skipped
1018321
def check_valid_hierarchies(instance):
    
    hierarchies = instance.get('hierarchies', {}).values()
    dimensions = set(instance.get('dimensions', {}).keys())
    all_levels = set()
    for hierarcy in hierarchies:
        levels = set(hierarcy.get('levels', []))
        if len(all_levels.intersection(levels)) > 0:
            # Dimension appears in two different hierarchies
            return False
        all_levels = all_levels.union(levels)
        if not dimensions.issuperset(levels):
            # Level which is not in a dimension
            return False
    return True
373778
def if_running(meth):
        """"""

        @wraps(meth)
        def check_running(self, *args, **kwargs):
            if not self.running:
                return
            return meth(self, *args, **kwargs)

        return check_running
869893
def _check_sample_config(items, in_file, config):
    
    logger.info("Checking sample YAML configuration: %s" % in_file)
    _check_quality_format(items)
    _check_for_duplicates(items, "lane")
    _check_for_duplicates(items, "description")
    _check_for_degenerate_interesting_groups(items)
    _check_for_batch_clashes(items)
    _check_for_problem_somatic_batches(items, config)
    _check_for_misplaced(items, "algorithm",
                         ["resources", "metadata", "analysis",
                          "description", "genome_build", "lane", "files"])

    [_check_toplevel_misplaced(x) for x in items]
    [_check_algorithm_keys(x) for x in items]
    [_check_algorithm_values(x) for x in items]
    [_check_aligner(x) for x in items]
    [_check_variantcaller(x) for x in items]
    [_check_svcaller(x) for x in items]
    [_check_hetcaller(x) for x in items]
    [_check_indelcaller(x) for x in items]
    [_check_jointcaller(x) for x in items]
    [_check_hlacaller(x) for x in items]
    [_check_realign(x) for x in items]
    [_check_trim(x) for x in items]
945021
public void run() {
		try {
			for (String mbean : mbeanMap.keySet()) {
				MBeanHolder h = mbeanMap.get(mbean);
				h.publish();
			}
		} catch (Exception ex) {
			// Robust exception to prevent thread death
			log.warning("Exception thrown sampling Mbeans");
			log.throwing(this.getClass().getName(),
					"Exception thrown sampling Mbeans:", ex);
		}
	}
424752
def runner_check(self, auth_list, fun, args):
        '''
        
        '''
        return self.spec_check(auth_list, fun, args, 'runner')
1330614
def get_stats_of_run_set(runResults, correct_only):
    

    # convert:
    # [['TRUE', 0,1], ['FALSE', 0,2]] -->  [['TRUE', 'FALSE'], [0,1, 0,2]]
    # in python2 this is a list, in python3 this is the iterator of the list
    # this works, because we iterate over the list some lines below
    listsOfValues = zip(*[runResult.values for runResult in runResults])

    columns = runResults[0].columns
    main_status_list = [(runResult.category, runResult.status) for runResult in runResults]

    # collect some statistics
    totalRow = []
    correctRow = []
    correctTrueRow = []
    correctFalseRow = []
    correctUnconfirmedRow = []
    correctUnconfirmedTrueRow = []
    correctUnconfirmedFalseRow = []
    incorrectRow = []
    wrongTrueRow = []
    wrongFalseRow = []
    scoreRow = []

    status_col_index = 0  # index of 'status' column
    for index, (column, values) in enumerate(zip(columns, listsOfValues)):
        col_type = column.type.type
        if col_type != ColumnType.text:
            if col_type == ColumnType.main_status or col_type == ColumnType.status:
                if col_type == ColumnType.main_status:
                    status_col_index = index
                    score = StatValue(sum(run_result.score or 0 for run_result in runResults))
                else:
                    score = None

                total   = StatValue(len([runResult.values[index] for runResult in runResults if runResult.status]))

                curr_status_list = [(runResult.category, runResult.values[index]) for runResult in runResults]

                counts = collections.Counter((category, result.get_result_classification(status))
                                             for category, status in curr_status_list)
                countCorrectTrue             = counts[result.CATEGORY_CORRECT,             result.RESULT_CLASS_TRUE]
                countCorrectFalse            = counts[result.CATEGORY_CORRECT,             result.RESULT_CLASS_FALSE]
                countCorrectUnconfirmedTrue  = counts[result.CATEGORY_CORRECT_UNCONFIRMED, result.RESULT_CLASS_TRUE]
                countCorrectUnconfirmedFalse = counts[result.CATEGORY_CORRECT_UNCONFIRMED, result.RESULT_CLASS_FALSE]
                countWrongTrue               = counts[result.CATEGORY_WRONG,               result.RESULT_CLASS_TRUE]
                countWrongFalse              = counts[result.CATEGORY_WRONG,               result.RESULT_CLASS_FALSE]

                correct                 = StatValue(countCorrectTrue + countCorrectFalse)
                correctTrue             = StatValue(countCorrectTrue)
                correctFalse            = StatValue(countCorrectFalse)
                correctUnconfirmed      = StatValue(countCorrectUnconfirmedTrue + countCorrectUnconfirmedFalse)
                correctUnconfirmedTrue  = StatValue(countCorrectUnconfirmedTrue)
                correctUnconfirmedFalse = StatValue(countCorrectUnconfirmedFalse)
                incorrect               = StatValue(countWrongTrue + countWrongFalse)
                wrongTrue               = StatValue(countWrongTrue)
                wrongFalse              = StatValue(countWrongFalse)

            else:
                assert column.is_numeric()
                total, correct, correctTrue, correctFalse,\
                       correctUnconfirmed, correctUnconfirmedTrue, correctUnconfirmedFalse,\
                       incorrect, wrongTrue, wrongFalse =\
                    get_stats_of_number_column(values, main_status_list, column.title, correct_only)

                score = None

        else:
            total, correct, correctTrue, correctFalse,\
                   correctUnconfirmed, correctUnconfirmedTrue, correctUnconfirmedFalse,\
                   incorrect, wrongTrue, wrongFalse =\
                (None, None, None, None, None, None, None, None, None, None)
            score = None

        totalRow.append(total)
        correctRow.append(correct)
        correctTrueRow.append(correctTrue)
        correctFalseRow.append(correctFalse)
        correctUnconfirmedRow.append(correctUnconfirmed)
        correctUnconfirmedTrueRow.append(correctUnconfirmedTrue)
        correctUnconfirmedFalseRow.append(correctUnconfirmedFalse)
        incorrectRow.append(incorrect)
        wrongTrueRow.append(wrongTrue)
        wrongFalseRow.append(wrongFalse)
        scoreRow.append(score)

    def replace_irrelevant(row):
        if not row:
            return
        count = row[status_col_index]
        if not count or not count.sum:
            for i in range(1, len(row)):
                row[i] = None

    replace_irrelevant(totalRow)
    replace_irrelevant(correctRow)
    replace_irrelevant(correctTrueRow)
    replace_irrelevant(correctFalseRow)
    replace_irrelevant(correctUnconfirmedRow)
    replace_irrelevant(correctUnconfirmedTrueRow)
    replace_irrelevant(correctUnconfirmedFalseRow)
    replace_irrelevant(incorrectRow)
    replace_irrelevant(wrongTrueRow)
    replace_irrelevant(wrongFalseRow)
    replace_irrelevant(scoreRow)

    stats = (totalRow, correctRow, correctTrueRow, correctFalseRow,\
                       correctUnconfirmedRow, correctUnconfirmedTrueRow, correctUnconfirmedFalseRow,\
                       incorrectRow, wrongTrueRow, wrongFalseRow,\
             scoreRow)
    return stats
361916
def check_ns_run_threads(run):
    
    assert run['thread_labels'].dtype == int
    uniq_th = np.unique(run['thread_labels'])
    assert np.array_equal(
        np.asarray(range(run['thread_min_max'].shape[0])), uniq_th), \
        str(uniq_th)
    # Check thread_min_max
    assert np.any(run['thread_min_max'][:, 0] == -np.inf), (
        'Run should have at least one thread which starts by sampling the ' +
        'whole prior')
    for th_lab in uniq_th:
        inds = np.where(run['thread_labels'] == th_lab)[0]
        th_info = 'thread label={}, first_logl={}, thread_min_max={}'.format(
            th_lab, run['logl'][inds[0]], run['thread_min_max'][th_lab, :])
        assert run['thread_min_max'][th_lab, 0] <= run['logl'][inds[0]], (
            'First point in thread has logl less than thread min logl! ' +
            th_info + ', difference={}'.format(
                run['logl'][inds[0]] - run['thread_min_max'][th_lab, 0]))
        assert run['thread_min_max'][th_lab, 1] == run['logl'][inds[-1]], (
            'Last point in thread logl != thread end logl! ' + th_info)
670077
def run(self, *args):
        
        if self.running:
            return self

        self._mut_finished(False)  # in case of recovery from a disaster.
        self._mut_running(True)

        stream = self.target(*args)

        # noinspection SpellCheckingInspection
        def subr():
            self._mut_running(True)
            try:
                for each in stream:
                    self._product = each
                    desc = self.descriptor_mapping(each)
                    event = self.events.get(desc)
                    if event:
                        event(self, each, globals)
                self._mut_finished(True)
            except ThreadExit:
                pass
            finally:
                self._mut_running(False)

        self._thread = thread = threading.Thread(target=subr, args=())
        thread.start()
        return self
228596
def Runs(self):
    
    with self._accumulators_mutex:
      # To avoid nested locks, we construct a copy of the run-accumulator map
      items = list(six.iteritems(self._accumulators))
    return {run_name: accumulator.Tags() for run_name, accumulator in items}
825712
def step_impl13(context, runs):
    
    executor_ = context.fuzz_executor
    stats = executor_.stats
    count = stats.cumulated_counts()
    assert count == runs, "VERIFY: Number of recorded runs."
    successful_runs = stats.cumulated_counts_for_status(Status.SUCCESS)
    assert successful_runs == runs
995030
def run(self, instance):
        

        last = instance

        for item in self.stack:
            if isinstance(item, str):
                last = getattr(last, item)
            else:
                last = last(*item[0], **item[1])

        self.stack = []
        return last
29853
def run(samples, run_parallel):
    
    to_process = []
    extras = []
    for data in (xs[0] for xs in samples):
        hlacaller = tz.get_in(["config", "algorithm", "hlacaller"], data)
        if hlacaller:
            to_process.append(data)
        else:
            extras.append([data])
    processed = run_parallel("call_hla", ([x] for x in to_process))
    return extras + processed