def total_crossing_probability(self,
                                   steps=None,
                                   method="wham",
                                   force=False):
        """Return the total crossing probability using `method`

        Parameters
        ----------
        steps : iterable of :class:`.MCStep`
            cycles to be analyzed
        method : "wham" (later: or "mbar" or "tram")
            approach to use to combine the histograms
        force : bool (False)
            if true, cached results are overwritten
        """

        if method == "wham":
            run_ensembles = False
            for ens in self.ensembles:
                try:
                    hist = self.histograms['max_lambda'][ens]
                except KeyError:
                    run_ensembles = True
            if run_ensembles or force:
                if steps is None:
                    raise RuntimeError(
                        "Unable to build histograms without steps source")
                self.all_statistics(steps, force=True)

            df = histograms_to_pandas_dataframe(
                self.histograms['max_lambda'].values(),
                fcn="reverse_cumulative").sort_index(axis=1)
            # if lambdas not set, returns None and WHAM uses fallback
            lambdas = self.interfaces.lambdas
            wham = WHAM(interfaces=lambdas)
            # wham.load_from_dataframe(df)
            # wham.clean_leading_ones()
            tcp = wham.wham_bam_histogram(df).to_dict()
        elif method == "mbar":
            pass
        else:
            raise ValueError(
                "Only supported methods are 'wham' and 'mbar'.  " +
                "Whereas 'mbar' is not yet implemented!")

        self.tcp = LookupFunction(tcp.keys(), tcp.values())
        return self.tcp
Beispiel #2
0
    def total_crossing_probability(self, steps=None, method="wham", force=False):
        """Return the total crossing probability using `method`

        Parameters
        ----------
        steps : iterable of :class:`.MCStep`
            cycles to be analyzed
        method : "wham" (later: or "mbar" or "tram")
            approach to use to combine the histograms
        force : bool (False)
            if true, cached results are overwritten
        """

        if method == "wham":
            run_ensembles = False
            for ens in self.ensembles:
                try:
                    hist = self.histograms['max_lambda'][ens]
                except KeyError:
                    run_ensembles = True
            if run_ensembles or force:
                if steps is None:
                    raise RuntimeError("Unable to build histograms without steps source")
                self.all_statistics(steps, force=True)

            df = histograms_to_pandas_dataframe(
                self.histograms['max_lambda'].values(),
                fcn="reverse_cumulative"
            ).sort_index(axis=1)
            # if lambdas not set, returns None and WHAM uses fallback
            lambdas = self.interfaces.lambdas
            wham = WHAM(interfaces=lambdas)
            # wham.load_from_dataframe(df)
            # wham.clean_leading_ones()
            tcp = wham.wham_bam_histogram(df).to_dict()
        elif method == "mbar":
            pass
        else:
            raise ValueError("Only supported methods are 'wham' and 'mbar'.  "
                             + "Whereas 'mbar' is not yet implemented!")

        self.tcp = LookupFunction(tcp.keys(), tcp.values())
        return self.tcp