def it_computes_p_bright_from_product(): error_model = ErrorModel.no_errors(n_channels=2) error_model.labels[0].p_failure_to_bind_amino_acid = 0.9 error_model.labels[1].p_failure_to_bind_amino_acid = 0.8 error_model.labels[0].p_failure_to_attach_to_dye = 0.7 error_model.labels[1].p_failure_to_attach_to_dye = 0.6 error_model.dyes[0].p_non_fluorescent = 0.5 error_model.dyes[1].p_non_fluorescent = 0.4 sim_params = SimParams.construct_from_aa_list(("A", "C"), error_model=error_model, n_edmans=3) flu, p_bright = sim_worker._step_1_create_flu_and_p_bright( pep_seq_df, sim_params) assert flu.shape == (2, 4) expected = np.array([ [ ((1 - 0.9) * (1 - 0.7) * (1 - 0.5)), 0, 0, 0, ], [ 0, 0, ((1 - 0.8) * (1 - 0.6) * (1 - 0.4)), 0, ], ]) assert np.allclose(p_bright, expected)
def zest_step_5_make_radmat(): # fmt: off dyemat = npf([ [ [2, 1], [2, 1], ], [ [0, 0], [0, 0], ], ]) sim_params = SimParams.construct_from_aa_list( ["DE", "C"], error_model=ErrorModel.no_errors(n_channels=2, beta=7500.0, sigma=0.16), n_pres=1, n_mocks=0, n_edmans=1, ) radmat = sim_worker._step_5_make_radmat(dyemat, sim_params) def it_makes_radmat(): assert np.all(radmat[0] > 4000.0) def it_deals_with_zeros(): assert np.all(radmat[1] == 0.0) # fmt: on zest()
def it_labels_in_tail(): sim_params = SimParams.construct_from_aa_list( ("A", "C"), error_model=ErrorModel.no_errors(n_channels=2), n_edmans=6, ) pep_seq_df = pd.DataFrame( [ (1, "B", 0), (1, "B", 1), (1, "B", 2), (1, "B", 3), (1, "A", 4), (1, "C", 5), ], columns=PrepResult.pep_seqs_columns, ) flu, p_bright = sim_worker._step_1_create_flu_and_p_bright( pep_seq_df, sim_params) assert np.all(flu == [ [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], ]) assert np.all(p_bright == [ [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], ])
def _before(): nonlocal sim_params sim_params = SimParams.construct_from_aa_list( ["DE", "C"], error_model=ErrorModel.no_errors(n_channels=2, beta=7500.0), n_pres=0, n_mocks=1, n_edmans=1, )
def it_extends_short_peptides(): sim_params = SimParams.construct_from_aa_list( ("A", "C"), error_model=ErrorModel.no_errors(n_channels=2), n_edmans=6, ) flu, p_bright = sim_worker._step_1_create_flu_and_p_bright( pep_seq_df, sim_params) assert flu.shape == (2, 7) assert np.all(flu[:, 3:] == 0.0)
) from plaster.tools.schema import check def _stub_sim_params(error_model, n_samples): return SimParams.construct_from_aa_list( ["A", "C"], error_model=error_model, n_samples=n_samples, n_pres=1, n_mocks=0, n_edmans=2, ) some_error_model = ErrorModel.no_errors(n_channels=2, sigma=0.16) no_error_model = ErrorModel.no_errors(n_channels=2) def _stub_dyemat_and_true(): dyemat = np.array([ [[2.0, 1.0, 0.0], [1.0, 1.0, 1.0]], [[2.0, 1.0, 0.0], [1.0, 1.0, 1.0]], [[2.0, 1.0, 0.0], [1.0, 1.0, 1.0]], [[3.0, 2.0, 1.0], [2.0, 1.0, 0.0]], [[3.0, 2.0, 1.0], [2.0, 1.0, 0.0]], [[2.0, 1.0, 0.0], [1.0, 1.0, 1.0]], [[0.1, 0.1, 0.0], [0.1, 0.1, 0.1]], ])
def zest_step_1_create_flu(): sim_params = SimParams.construct_from_aa_list( ("A", "C"), error_model=ErrorModel.no_errors(n_channels=2), ) pep_seq_df = pd.DataFrame([ (1, "A", 0), (1, "B", 1), (1, "C", 2), ], columns=PrepResult.pep_seqs_columns) def it_return_flu_and_p_bright(): flu, p_bright = sim_worker._step_1_create_flu_and_p_bright( pep_seq_df, sim_params) assert np.all(flu == [ [ 1, 0, 0, ], [ 0, 0, 1, ], ]) assert np.all(p_bright == [ [ 1, 0, 0, ], [ 0, 0, 1, ], ]) def it_extends_short_peptides(): sim_params = SimParams.construct_from_aa_list( ("A", "C"), error_model=ErrorModel.no_errors(n_channels=2), n_edmans=6, ) flu, p_bright = sim_worker._step_1_create_flu_and_p_bright( pep_seq_df, sim_params) assert flu.shape == (2, 7) assert np.all(flu[:, 3:] == 0.0) def it_computes_p_bright_from_product(): error_model = ErrorModel.no_errors(n_channels=2) error_model.labels[0].p_failure_to_bind_amino_acid = 0.9 error_model.labels[1].p_failure_to_bind_amino_acid = 0.8 error_model.labels[0].p_failure_to_attach_to_dye = 0.7 error_model.labels[1].p_failure_to_attach_to_dye = 0.6 error_model.dyes[0].p_non_fluorescent = 0.5 error_model.dyes[1].p_non_fluorescent = 0.4 sim_params = SimParams.construct_from_aa_list(("A", "C"), error_model=error_model, n_edmans=3) flu, p_bright = sim_worker._step_1_create_flu_and_p_bright( pep_seq_df, sim_params) assert flu.shape == (2, 4) expected = np.array([ [ ((1 - 0.9) * (1 - 0.7) * (1 - 0.5)), 0, 0, 0, ], [ 0, 0, ((1 - 0.8) * (1 - 0.6) * (1 - 0.4)), 0, ], ]) assert np.allclose(p_bright, expected) def it_labels_in_tail(): sim_params = SimParams.construct_from_aa_list( ("A", "C"), error_model=ErrorModel.no_errors(n_channels=2), n_edmans=6, ) pep_seq_df = pd.DataFrame( [ (1, "B", 0), (1, "B", 1), (1, "B", 2), (1, "B", 3), (1, "A", 4), (1, "C", 5), ], columns=PrepResult.pep_seqs_columns, ) flu, p_bright = sim_worker._step_1_create_flu_and_p_bright( pep_seq_df, sim_params) assert np.all(flu == [ [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], ]) assert np.all(p_bright == [ [0, 0, 0, 0, 1, 0, 0], [0, 0, 0, 0, 0, 1, 0], ]) zest()