Esempio n. 1
0
def test_internalize_conidia_0(macrophage_list: MacrophageCellList,
                               grid: RectangularGrid,
                               fungus_list: FungusCellList):
    m_det = 0

    point = Point(x=35, y=35, z=35)
    macrophage_list.append(MacrophageCellData.create_cell(point=point))
    fungus_list.append(
        FungusCellData.create_cell(point=point,
                                   status=FungusCellData.Status.RESTING))

    vox = grid.get_voxel(macrophage_list[0]['point'])

    assert len(fungus_list.get_cells_in_voxel(vox)) == 1

    f_index = int(fungus_list.get_cells_in_voxel(vox))  # 0
    assert f_index == 0

    fungus_list[f_index]['form'] = FungusCellData.Form.CONIDIA
    fungus_list[f_index]['status'] = FungusCellData.Status.RESTING

    macrophage_list.internalize_conidia(m_det, 50, 1, grid, fungus_list)

    assert grid.get_voxel(fungus_list[f_index]['point']) == vox
    assert fungus_list.cell_data['internalized'][f_index]
    assert macrophage_list.len_phagosome(0) == 1
    def internalize_conidia(self, m_det, max_spores, p_in, grid,
                            fungus: FungusCellList):
        for i in self.alive():
            cell = self[i]
            vox = grid.get_voxel(cell['point'])

            # Moore neighborhood, but order partially randomized. Closest to furthest order, but
            # the order of any set of points of equal distance is random
            neighborhood = list(
                itertools.product(tuple(range(-1 * m_det, m_det + 1)),
                                  repeat=3))
            shuffle(neighborhood)
            neighborhood = sorted(neighborhood,
                                  key=lambda v: v[0]**2 + v[1]**2 + v[2]**2)

            for dx, dy, dz in neighborhood:
                zi = vox.z + dz
                yj = vox.y + dy
                xk = vox.x + dx
                if grid.is_valid_voxel(Voxel(x=xk, y=yj, z=zi)):
                    index_arr = fungus.get_cells_in_voxel(
                        Voxel(x=xk, y=yj, z=zi))
                    for index in index_arr:
                        if (fungus[index]['form']
                                == FungusCellData.Form.CONIDIA
                                and not fungus[index]['internalized']
                                and p_in > rg.random()):
                            fungus[index]['internalized'] = True
                            self.append_to_phagosome(i, index, max_spores)
    def produce_cytokines(self, m_det, m_n, grid, fungus: FungusCellList,
                          cyto):
        for i in self.alive():
            vox = grid.get_voxel(self[i]['point'])

            hyphae_count = 0

            # Moore neighborhood
            neighborhood = tuple(
                itertools.product(tuple(range(-1 * m_det, m_det + 1)),
                                  repeat=3))

            for dx, dy, dz in neighborhood:
                zi = vox.z + dz
                yj = vox.y + dy
                xk = vox.x + dx
                if grid.is_valid_voxel(Voxel(x=xk, y=yj, z=zi)):
                    index_arr = fungus.get_cells_in_voxel(
                        Voxel(x=xk, y=yj, z=zi))
                    for index in index_arr:
                        if fungus[index]['form'] == FungusCellData.Form.HYPHAE:
                            hyphae_count += 1

            cyto[vox.z, vox.y,
                 vox.x] = cyto[vox.z, vox.y, vox.x] + m_n * hyphae_count
    def damage_hyphae(self, n_det, n_kill, time, health, grid, fungus: FungusCellList, iron):
        for i in self.alive(self.cell_data['granule_count'] > 0):
            cell = self[i]
            vox = grid.get_voxel(cell['point'])

            # Moore neighborhood, but order partially randomized. Closest to furthest order, but
            # the order of any set of points of equal distance is random
            neighborhood = list(itertools.product(tuple(range(-1 * n_det, n_det + 1)), repeat=3))
            shuffle(neighborhood)
            neighborhood = sorted(neighborhood, key=lambda v: v[0] ** 2 + v[1] ** 2 + v[2] ** 2)

            for dx, dy, dz in neighborhood:
                zi = vox.z + dz
                yj = vox.y + dy
                xk = vox.x + dx
                if grid.is_valid_voxel(Voxel(x=xk, y=yj, z=zi)):
                    index_arr = fungus.get_cells_in_voxel(Voxel(x=xk, y=yj, z=zi))
                    if len(index_arr) > 0:
                        iron[zi, yj, xk] = 0
                    for index in index_arr:
                        if (
                            fungus[index]['form'] == FungusCellData.Form.HYPHAE
                            and cell['granule_count'] > 0
                        ):
                            fungus[index]['health'] -= health * (time / n_kill)
                            cell['granule_count'] -= 1
                            cell['status'] = NeutrophilCellData.Status.GRANULATING
                        elif cell['granule_count'] == 0:
                            cell['status'] = NeutrophilCellData.Status.NONGRANULATING
                            break
def test_internalize_conidia_none(
    populated_epithelium: EpitheliumCellList,
    grid: RectangularGrid,
    fungus_list: FungusCellList,
):
    cell = populated_epithelium[0]
    vox = grid.get_voxel(cell['point'])
    assert len(fungus_list.get_cells_in_voxel(vox)) == 0

    populated_epithelium.internalize_conidia(0, 10, 1, grid, fungus_list)

    assert populated_epithelium.len_phagosome(0) == 0
    for v in cell['phagosome']:
        assert v == -1
Esempio n. 6
0
def test_internalize_conidia_none(
    populated_macrophage: MacrophageCellList,
    grid: RectangularGrid,
    populated_fungus: FungusCellList,
):
    m_det = 0

    cell = populated_macrophage[0]
    vox = grid.get_voxel(cell['point'])
    assert len(populated_fungus.get_cells_in_voxel(vox)) == 1

    populated_macrophage.internalize_conidia(m_det, 50, 1, grid,
                                             populated_fungus)

    assert populated_macrophage.len_phagosome(0) == 0
    for v in cell['phagosome']:
        assert v == -1