def test_get_true_positives_returns_correct_number_of_entries(): tpms = _get_test_tpms() t.mark_positives_and_negatives(tpms) tp_tpms = t.get_true_positives(tpms) assert len(tp_tpms) == \ len([x for x, y in zip(CALC_TPMS_VALS, REAL_TPMS_VALS) if x > t.NOT_PRESENT_CUTOFF and y > t.NOT_PRESENT_CUTOFF])
def test_get_true_positives_returns_correct_number_of_entries(): tpms = _get_test_tpms() t.mark_positives_and_negatives(NOT_PRESENT_CUTOFF, tpms) tp_tpms = t.get_true_positives(tpms) assert len(tp_tpms) == \ len([x for x, y in zip(CALC_TPMS_VALS, REAL_TPMS_VALS) if x > NOT_PRESENT_CUTOFF and y > NOT_PRESENT_CUTOFF])
def test_mark_positives_negatives_marks_correct_entries_as_true_negative(): tpms = _get_test_tpms() t.mark_positives_and_negatives(tpms) for index, row in tpms.iterrows(): if _true_negative(row[t.REAL_TPM], row[t.CALCULATED_TPM]): assert row[t.TRUE_NEGATIVE] assert not row[t.FALSE_POSITIVE] assert not row[t.TRUE_POSITIVE] assert not row[t.FALSE_NEGATIVE] else: assert not row[t.TRUE_NEGATIVE]
def test_mark_positives_negatives_marks_correct_entries_as_false_positive(): tpms = _get_test_tpms() t.mark_positives_and_negatives(NOT_PRESENT_CUTOFF, tpms) for index, row in tpms.iterrows(): if _false_positive(row[t.REAL_TPM], row[t.CALCULATED_TPM]): assert row[t.FALSE_POSITIVE] assert not row[t.TRUE_POSITIVE] assert not row[t.TRUE_NEGATIVE] assert not row[t.FALSE_NEGATIVE] else: assert not row[t.FALSE_POSITIVE]
def _get_test_tpms(): tpms = pd.DataFrame.from_dict({ t.REAL_TPM: test_tpms.REAL_TPMS_VALS, t.CALCULATED_TPM: test_tpms.CALC_TPMS_VALS, test_tpms.GROUP_TEST_COL: test_tpms.GROUPS }) t.calculate_log_ratios(tpms) t.calculate_percent_error(tpms) t.mark_positives_and_negatives(tpms) return tpms, t.get_true_positives(tpms)