Exemplo n.º 1
0
    def summarize(self):
        """Summarize the activities of this :class:`Adapter`.
        """
        total_front = sum(self.lengths_front.values())
        total_back = sum(self.lengths_back.values())

        stats = MergingDict(adapter_class=self.__class__.__name__,
                            total_front=total_front,
                            total_back=total_back,
                            total=total_front + total_back,
                            match_probabilities=Const(
                                self.random_match_probabilities()))

        where = self.where
        assert (where in (ANYWHERE, LINKED)
                or (where in (BACK, SUFFIX) and total_front == 0)
                or (where in (FRONT, PREFIX) and total_back == 0))

        stats["where"] = where_int_to_dict(where)
        stats["sequence"] = Const(self.sequence)
        stats["max_error_rate"] = Const(self.max_error_rate)
        if where in (ANYWHERE, FRONT, PREFIX):
            stats["lengths_front"] = self.lengths_front
            stats["errors_front"] = self.errors_front
        if where in (ANYWHERE, BACK, SUFFIX):
            stats["lengths_back"] = self.lengths_back
            stats["errors_back"] = self.errors_back
        if where in (BACK, SUFFIX):
            stats["adjacent_bases"] = self.adjacent_bases

        return stats
Exemplo n.º 2
0
    def summarize(self):
        """Returns the summary dict for this adapter.
        """
        total_front = sum(self.front_adapter.lengths_front.values())
        total_back = sum(self.back_adapter.lengths_back.values())

        stats = MergingDict(total_front=total_front,
                            total_back=total_back,
                            total=total_front + total_back)

        where = self.where
        assert (where in (ANYWHERE, LINKED)
                or (where in (BACK, SUFFIX) and total_front == 0)
                or (where in (FRONT, PREFIX) and total_back == 0))

        stats["where"] = where_int_to_dict(where)
        stats["front_sequence"] = Const(self.front_adapter.sequence)
        stats["front_match_probabilities"] = Const(
            self.front_adapter.random_match_probabilities())
        stats["back_sequence"] = Const(self.back_adapter.sequence)
        stats["back_match_probabilities"] = Const(
            self.back_adapter.random_match_probabilities())
        stats["front_max_error_rate"] = Const(
            self.front_adapter.max_error_rate)
        stats["back_max_error_rate"] = Const(self.back_adapter.max_error_rate)
        stats["front_lengths_front"] = self.front_adapter.lengths_front
        stats["front_lengths_back"] = self.front_adapter.lengths_back
        stats["back_lengths_front"] = self.back_adapter.lengths_front
        stats["back_lengths_back"] = self.back_adapter.lengths_back
        # have to clone these nested dicts and set them
        # up with a custom merge function
        stats["front_errors_front"] = self.front_adapter.errors_front
        stats["front_errors_back"] = self.front_adapter.errors_back
        stats["back_errors_front"] = self.back_adapter.errors_front
        stats["back_errors_back"] = self.back_adapter.errors_back

        return stats
Exemplo n.º 3
0
 def asdict(self):
     """Returns AdapterType fields in a dict.
     """
     return dict(name=self.name, desc=self.desc, flags=Const(self.flags))