Пример #1
0
    def it_generates_flu_info():
        with tmp.tmp_folder(chdir=True):
            prep_result = PrepResult.prep_result_fixture(
                pros=[".", "XAXCD", "XAXCDXX", "XCCXX"],
                pro_is_decoys=[False, False, False, False],
                peps=[".", "XAXCD", "XAXCDXX", "XCCXX"],
                pep_pro_iz=[0, 1, 2, 3],
            )
            sim_params = _stub_sim_params(some_error_model, n_samples)
            sim_result = sim_v1_worker.sim_v1(sim_params, prep_result)
            sim_result._generate_flu_info(prep_result)

            def it_computes_head_and_tail():
                _flus = sim_result._flus
                assert np.all(_flus[_flus.pep_i.isin([1, 2])].flu_count == 2)
                assert np.all(_flus[_flus.pep_i.isin([1, 2])].n_head_ch_0 == 1)
                assert np.all(_flus[_flus.pep_i.isin([1, 2])].n_head_ch_1 == 0)
                assert np.all(_flus[_flus.pep_i.isin([1, 2])].n_tail_ch_0 == 0)
                assert np.all(_flus[_flus.pep_i.isin([1, 2])].n_tail_ch_1 == 1)
                assert np.all(_flus[_flus.pep_i == 3].flu_count == 1)

            def it_peps__flus():
                df = sim_result.peps__flus(prep_result)
                assert "flustr" in df
                assert len(df) == 4

            def it_peps__flus__unique_flus():
                df = sim_result.peps__flus__unique_flus(prep_result)
                assert np.all(df.pep_i.values == [0, 3])

            zest()
Пример #2
0
    def it_drop_all_darks():
        with tmp.tmp_folder(chdir=True):
            prep_result = PrepResult.prep_result_fixture(
                pros=[".", "DD", "EE"],
                pro_is_decoys=[False, False, False],
                peps=[".", "DD", "EE"],
                pep_pro_iz=[0, 1, 2],
            )
            n_peptides = 3
            sim_params = _stub_sim_params(no_error_model, n_samples)
            sim_result = sim_v1_worker.sim_v1(sim_params, prep_result)
            assert sim_result.test_dyemat.shape == (
                0,
                n_channels,
                n_cycles,
            )
            assert sim_result.test_dyemat.dtype == np.uint8
            assert np.all(sim_result.test_dyemat[:] == 0)  # All dark

            assert sim_result.train_dyemat.shape == (
                1,
                n_channels,
                n_cycles,
            )
            assert sim_result.train_dyemat.dtype == np.uint8
            assert np.all(sim_result.train_pep_recalls[:] == 0.0)
Пример #3
0
    def start(self):
        sim_params = SimV1Params(include_dfs=True, **self.config.parameters)

        prep_result = PrepResult.load_from_folder(self.inputs.prep)

        sim_result = sim_v1(
            sim_params, prep_result, progress=self.progress, pipeline=self
        )
        sim_result._generate_flu_info(prep_result)
        sim_result.save()
Пример #4
0
def result_from_prep_fixture(prep_result, labels, n_edmans=5, error_model=None):
    labels = labels.split(",")
    n_labels = len(labels)
    if error_model is None:
        error_model = ErrorModel.from_defaults(n_labels)

    sim_v1_params = SimV1Params.from_aa_list_fixture(
        labels, error_model=error_model, n_pres=1, n_mocks=0, n_edmans=n_edmans,
    )

    return sim_v1_worker.sim_v1(sim_v1_params, prep_result)
Пример #5
0
 def it_surveys():
     with tmp.tmp_folder(chdir=True):
         n_samples = 1
         sim_params = _stub_sim_params(some_error_model, n_samples)
         sim_params.is_survey = True
         sim_params.n_samples_train = n_samples
         sim_params.n_samples_test = None
         sim_result = sim_v1_worker.sim_v1(sim_params, prep_result)
         assert sim_result.train_dyemat.shape == (
             n_peptides * n_samples,
             n_channels,
             n_cycles,
         )
         assert sim_result.train_dyemat.dtype == np.uint8
         assert sim_result.test_dyemat is None
Пример #6
0
 def it_raises_if_train_and_test_identical():
     with tmp.tmp_folder(chdir=True):
         with zest.raises(in_message="are identical"):
             sim_params = _stub_sim_params(no_error_model, n_samples)
             sim_v1_worker.sim_v1(sim_params, prep_result)
Пример #7
0
 def it_removes_decoys_for_test():
     with tmp.tmp_folder(chdir=True):
         sim_params = _stub_sim_params(some_error_model, n_samples)
         sim_result = sim_v1_worker.sim_v1(sim_params, prep_result)
         assert not np.any(sim_result.test_true_pep_iz == 4)