Skip to content

ConnectomeReader

ConnectionInfo

Holds information on a single connection between a pre_cell and post_cell - the number of connections, the syntype and synclass

Source code in cect/ConnectomeReader.py
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
class ConnectionInfo:
    """Holds information on a single connection between a `pre_cell` and `post_cell` - the `number` of connections, the `syntype` and `synclass`"""

    def __init__(
        self, pre_cell: str, post_cell: str, number: float, syntype: str, synclass: str
    ):
        self.pre_cell = pre_cell
        self.post_cell = post_cell
        self.number = number
        self.syntype = syntype
        self.synclass = synclass

    def to_dict(self):
        return {
            "pre_cell": self.pre_cell,
            "post_cell": self.post_cell,
            "number": float(self.number),
            "syntype": self.syntype,
            "synclass": self.synclass,
        }

    def __str__(self):
        return "Connection from %s to %s (%s times, type: %s, neurotransmitter: %s)" % (
            self.pre_cell,
            self.post_cell,
            int(self.number) if int(self.number) == self.number else self.number,
            self.syntype,
            self.synclass,
        )

    def short(self):
        return "Connection from %s to %s (%s)" % (
            self.pre_cell,
            self.post_cell,
            self.syntype,
        )

    def __eq__(self, other):
        return (
            other.pre_cell == self.pre_cell
            and other.post_cell == self.post_cell
            and other.number == self.number
            and other.syntype == self.syntype
            and other.synclass == self.synclass
        )

    def __lt__(self, other):
        if other.pre_cell + other.post_cell > self.pre_cell + self.post_cell:
            return True
        else:
            return False

    def __repr__(self):
        return self.__str__()