コード例 #1
0
ファイル: base_generator.py プロジェクト: manastech/plaster
    def run_parameter_permutator(self):
        """
        Generate permutations of all the variable parameters
        Defaults all arguments to self.*
        Gracefully handles lack of protease.
        """
        proteases = utils.non_none(self.get("protease"), [None])
        if len(proteases) == 0:
            proteases = [None]
        proteases = [("protease", p) for p in proteases]

        label_sets = self.label_set_permutate()
        label_sets = [("label_set", s) for s in label_sets]

        err_sets = self.error_set_permutate()

        combined = [proteases, label_sets] + err_sets

        for params in itertools.product(*combined):
            protease = utils.filt_first(params, lambda i: i[0] == "protease")
            protease = protease[1]
            label_set = utils.filt_first(params, lambda i: i[0] == "label_set")
            label_set = label_set[1]

            # Given that the label_set is now known, the error model can be setup
            n_channels = len(label_set)
            err_set = Munch(
                p_edman_failure=[
                    self.error_model_defaults.err_p_edman_failure
                ] * 1,
                p_detach=[self.error_model_defaults.err_p_detach] * 1,
                dye_beta=[self.error_model_defaults.err_dye_beta] * n_channels,
                dye_sigma=[self.error_model_defaults.err_dye_sigma] *
                n_channels,
                dye_gain=[self.error_model_defaults.err_dye_gain] * n_channels,
                dye_vpd=[self.error_model_defaults.err_dye_vpd] * n_channels,
                p_bleach_per_cycle=[
                    self.error_model_defaults.err_p_bleach_per_cycle
                ] * n_channels,
                p_non_fluorescent=[
                    self.error_model_defaults.err_p_non_fluorescent
                ] * n_channels,
            )

            for param in params:
                if param[0].startswith("err_"):
                    parts = param[0].split(":")
                    err_set[parts[0][4:]][int(parts[1])] = param[1]
                    # The 4: removes the "err_"

            yield protease, label_set, err_set
コード例 #2
0
    def run_parameter_permutator(self, use_lognormal_model=True):
        """
        Generate permutations of all the variable parameters
        Defaults all arguments to self.*
        Gracefully handles lack of protease.
        """

        proteases = utils.non_none(self.get("protease"), [None])
        proteases = [("protease", p) for p in proteases]

        label_sets = self.label_set_permutate()
        label_sets = [("label_set", s) for s in label_sets]

        if len(proteases) == 0:
            proteases = [("protease", None)]

        err_sets = self.error_set_permutate()

        combined = [proteases, label_sets] + err_sets

        # Schemes is a list of schemes, where each scheme is a tuple containing:
        # - A Label set, in the form of Tuple['label_set', Tuple[str, ...]]
        # - A protease, in the form of Tuple['protease', str]

        # Build scheme set from protease and label set args
        schemes = list(itertools.product(*combined))

        # Add in directly specified schemes
        schemes += [(("protease", scheme.protease), ("label_set",
                                                     scheme.label_set))
                    for scheme in self.scheme_set_permutate()]

        for params in schemes:
            protease = utils.filt_first(params, lambda i: i[0] == "protease")
            protease = protease[1]
            label_set = utils.filt_first(params, lambda i: i[0] == "label_set")
            label_set = label_set[1]

            # Given that the label_set is now known, the error model can be setup
            n_channels = len(label_set)
            err_set = self.default_err_set(n_channels, use_lognormal_model)

            for param in params:
                if param[0].startswith("err_"):
                    parts = param[0].split(":")
                    err_set[parts[0][4:]][int(
                        parts[1])] = param[1]  # The 4: removes the "err_"

            yield protease, label_set, err_set
コード例 #3
0
ファイル: zest_utils.py プロジェクト: manastech/plaster
 def it_raises_if_none_found():
     with zest.raises(ValueError):
         assert utils.non_none(None, None, raise_if_all_none=ValueError("fail!"))
コード例 #4
0
ファイル: zest_utils.py プロジェクト: manastech/plaster
 def it_returns_non_none():
     assert utils.non_none(1, 2) == 1
     assert utils.non_none(None, 1, 2) == 1
     assert utils.non_none(None, None) is None