Skip to content

Cook2020DataReader

Cook2020DataReader

Bases: ConnectomeDataset

Reader of data from Cook et al. 2020 - The connectome of the Caenorhabditis elegans pharynx

Returns:

Type Description
Cook2020DataReader

The initialized Cook et al 2020 pharyngeal connectome reader

Source code in cect/readers/Cook2020DataReader.py
 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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
class Cook2020DataReader(ConnectomeDataset):
    """
    Reader of data from Cook et al. 2020 - The connectome of the Caenorhabditis elegans pharynx

    Returns:
        (Cook2020DataReader): The initialized Cook et al 2020 pharyngeal connectome reader
    """

    def __init__(self):
        ConnectomeDataset.__init__(self)

        cells, neuron_conns = self.read_data()
        for conn in neuron_conns:
            self.add_connection_info(
                conn,
                check_overwritten_connections=False,
                append_existing_connections=True,
                fail_on_any_repeated_connection=False,
            )

        print_("\n*********************** Validation Info ************************")
        print(self.validation_info)
        print_("****************************************************************")

    def read_data(self):
        """
        Returns:
            (tuple[list, list]): List of cells (str) and list of connections (``ConnectionInfo``) which have been read in
        """
        cells = []
        conns = []

        with open(filename, "r") as f:
            reader = csv.DictReader(f)
            print_("Opened file: " + filename)

            for row in reader:
                pre = str.strip(row["Source"])
                if is_potential_muscle(pre):
                    pre = convert_to_preferred_muscle_name(pre)
                post = str.strip(row["Target"])
                if is_potential_muscle(post):
                    post = convert_to_preferred_muscle_name(post)
                if is_marginal_epithelial_gland_cell(post):
                    post = convert_to_preferred_phar_cell_name(post)
                num = float(row["Weight"])
                syntype = str.strip(row["Type"])

                if syntype == "Electrical":
                    syntype = ELECTRICAL_SYN_TYPE
                else:
                    syntype = CHEMICAL_SYN_TYPE

                synclass = (
                    GENERIC_ELEC_SYN_CLASS
                    if syntype == ELECTRICAL_SYN_TYPE
                    else GENERIC_CHEM_SYN_CLASS
                )

                conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
                # Add post -> pre conn for gap junction connections
                if syntype == ELECTRICAL_SYN_TYPE:
                    conns.append(ConnectionInfo(post, pre, num, syntype, synclass))

                if pre not in cells:
                    cells.append(pre)
                if post not in cells:
                    cells.append(post)

        with open(filename2, "r") as f:
            reader = csv.DictReader(f)
            print_("Opened file: " + filename)

            for row in reader:
                pre = str.strip(row["Source"])
                if is_potential_muscle(pre):
                    pre = convert_to_preferred_muscle_name(pre)
                if is_marginal_epithelial_gland_cell(pre):
                    pre = convert_to_preferred_phar_cell_name(pre)
                post = str.strip(row["Target"])

                if is_potential_muscle(post):
                    post = convert_to_preferred_muscle_name(post)
                if is_marginal_epithelial_gland_cell(post):
                    post = convert_to_preferred_phar_cell_name(post)

                num = float(row["Weight"])

                syntype = ELECTRICAL_SYN_TYPE
                synclass = GENERIC_ELEC_SYN_CLASS

                conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
                # Add post -> pre conn for gap junction connections
                conns.append(ConnectionInfo(post, pre, num, syntype, synclass))

                if pre not in cells:
                    cells.append(pre)
                if post not in cells:
                    cells.append(post)

        return cells, conns

    def read_muscle_data(self):
        return self._read_muscle_data()

read_data()

Returns:

Type Description
tuple[list, list]

List of cells (str) and list of connections (ConnectionInfo) which have been read in

Source code in cect/readers/Cook2020DataReader.py
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
def read_data(self):
    """
    Returns:
        (tuple[list, list]): List of cells (str) and list of connections (``ConnectionInfo``) which have been read in
    """
    cells = []
    conns = []

    with open(filename, "r") as f:
        reader = csv.DictReader(f)
        print_("Opened file: " + filename)

        for row in reader:
            pre = str.strip(row["Source"])
            if is_potential_muscle(pre):
                pre = convert_to_preferred_muscle_name(pre)
            post = str.strip(row["Target"])
            if is_potential_muscle(post):
                post = convert_to_preferred_muscle_name(post)
            if is_marginal_epithelial_gland_cell(post):
                post = convert_to_preferred_phar_cell_name(post)
            num = float(row["Weight"])
            syntype = str.strip(row["Type"])

            if syntype == "Electrical":
                syntype = ELECTRICAL_SYN_TYPE
            else:
                syntype = CHEMICAL_SYN_TYPE

            synclass = (
                GENERIC_ELEC_SYN_CLASS
                if syntype == ELECTRICAL_SYN_TYPE
                else GENERIC_CHEM_SYN_CLASS
            )

            conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
            # Add post -> pre conn for gap junction connections
            if syntype == ELECTRICAL_SYN_TYPE:
                conns.append(ConnectionInfo(post, pre, num, syntype, synclass))

            if pre not in cells:
                cells.append(pre)
            if post not in cells:
                cells.append(post)

    with open(filename2, "r") as f:
        reader = csv.DictReader(f)
        print_("Opened file: " + filename)

        for row in reader:
            pre = str.strip(row["Source"])
            if is_potential_muscle(pre):
                pre = convert_to_preferred_muscle_name(pre)
            if is_marginal_epithelial_gland_cell(pre):
                pre = convert_to_preferred_phar_cell_name(pre)
            post = str.strip(row["Target"])

            if is_potential_muscle(post):
                post = convert_to_preferred_muscle_name(post)
            if is_marginal_epithelial_gland_cell(post):
                post = convert_to_preferred_phar_cell_name(post)

            num = float(row["Weight"])

            syntype = ELECTRICAL_SYN_TYPE
            synclass = GENERIC_ELEC_SYN_CLASS

            conns.append(ConnectionInfo(pre, post, num, syntype, synclass))
            # Add post -> pre conn for gap junction connections
            conns.append(ConnectionInfo(post, pre, num, syntype, synclass))

            if pre not in cells:
                cells.append(pre)
            if post not in cells:
                cells.append(post)

    return cells, conns