Skip to content

Cells

get_SIM_class(cell)

PROVISIONAL method to return whether a cell is Sensory/Interneuron/Motorneuron (or Other)

Parameters:

Name Type Description Default
cell str

which cell to assess

required

Returns:

Name Type Description
str

whether a cell is Sensory/Interneuron/Motorneuron (or Other)

Source code in cect/Cells.py
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
def get_SIM_class(cell: str):
    """
    PROVISIONAL method to return whether a cell is Sensory/Interneuron/Motorneuron (or Other)

    Parameters:
        cell: which cell to assess

    Returns:
        str: whether a cell is Sensory/Interneuron/Motorneuron (or Other)
    """

    pharyngeal_polymodal_to_class_motor = [
        "MI",
        "NSML",
        "NSMR",
        "MCL",
        "MCR",
    ]
    pharyngeal_polymodal_to_class_sensory = [
        "NSML",
        "NSMR",
    ]

    if cell in SENSORY_NEURONS_COOK + pharyngeal_polymodal_to_class_sensory:
        return "Sensory"
    elif cell in MOTORNEURONS_COOK + pharyngeal_polymodal_to_class_motor:
        return "Motorneuron"
    elif cell in INTERNEURONS_COOK:
        return "Interneuron"
    else:
        if len(cell) == 3:
            if get_SIM_class("%sL" % cell) == get_SIM_class("%sR" % cell):
                return get_SIM_class("%sL" % cell)
        return "Other"

get_cell_notes(cell)

Get a short description of the cell, mainly cell type

Parameters:

Name Type Description Default
cell str

Name of the cell

required

Returns:

Name Type Description
str

Description of the cell type

Source code in cect/Cells.py
46
47
48
49
50
51
52
53
54
55
56
57
def get_cell_notes(cell: str):
    """Get a short description of the cell, mainly cell type

    Args:
        cell (str): Name of the cell

    Returns:
        str: Description of the cell type
    """
    desc = cell_notes[cell] if cell in cell_notes else "???"
    desc = desc[0].upper() + desc[1:]
    return desc

get_contralateral_neuron(cell)

Gets the contralateral neuron for a given neuron, based on Kim et al. 2024: https://doi.org/10.1101/2024.10.03.616419

Parameters:

Name Type Description Default
cell _type_

description

required

Raises:

Type Description
Exception

description

Returns:

Name Type Description
_type_

description

Source code in cect/Cells.py
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
def get_contralateral_neuron(cell: str):
    """Gets the contralateral neuron for a given neuron, based on Kim et al. 2024: https://doi.org/10.1101/2024.10.03.616419

    Args:
        cell (_type_): _description_

    Raises:
        Exception: _description_

    Returns:
        _type_: _description_
    """
    if not is_any_neuron(cell):
        raise Exception("Not yet implemented/tested for non neuronal cells")
    if is_bilateral_left(cell):
        return cell[:-1] + "R"
    if is_bilateral_right(cell):
        return cell[:-1] + "L"
    else:
        return cell

get_primary_classification()

Get the primary classification of the cells, based on https://www.wormatlas.org/colorcode.htm

Returns:

Name Type Description
dict

Dict of cells vs classification/group from https://www.wormatlas.org/colorcode.htm

Source code in cect/Cells.py
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
def get_primary_classification():
    """Get the primary classification of the cells, based on https://www.wormatlas.org/colorcode.htm

    Returns:
        dict: Dict of cells vs classification/group from https://www.wormatlas.org/colorcode.htm
    """

    classification = {}

    for sex in WA_COLORS:
        for cell_class in WA_COLORS[sex]:
            for cell_type in WA_COLORS[sex][cell_class]:
                print_(" - %s/%s/%s" % (sex, cell_class, cell_type))

                if cell_type == "body wall muscle":
                    for cell in BODY_WALL_MUSCLE_NAMES + UNSPECIFIED_BODY_WALL_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "vulval muscle":
                    for cell in VULVAL_MUSCLE_NAMES:
                        classification[cell] = cell_type
                elif cell_type == "uterine muscle":
                    for cell in UTERINE_MUSCLE_NAMES:
                        classification[cell] = cell_type
                elif cell_type == "interneuron":
                    for cell in (
                        INTERNEURONS_COOK
                        + MALE_HEAD_INTERNEURONS
                        + MALE_NON_HEAD_INTERNEURONS
                    ):
                        classification[cell] = cell_type
                elif cell_type == "motor neuron":
                    for cell in MOTORNEURONS_COOK:
                        classification[cell] = cell_type
                elif cell_type == "sensory neuron":
                    for cell in (
                        SENSORY_NEURONS_COOK
                        + MALE_HEAD_SENSORY_NEURONS
                        + MALE_NON_HEAD_SENSORY_NEURONS
                    ):
                        classification[cell] = cell_type
                elif cell_type == "odd numbered pharyngeal muscle":
                    for cell in ODD_PHARYNGEAL_MUSCLE_NAMES:
                        classification[cell] = cell_type
                elif cell_type == "even numbered pharyngeal muscle":
                    for cell in EVEN_PHARYNGEAL_MUSCLE_NAMES:
                        classification[cell] = cell_type
                elif cell_type == "polymodal neuron":
                    for cell in PHARYNGEAL_POLYMODAL_NEURONS:
                        classification[cell] = cell_type
                elif cell_type == "marginal cells (mc) of the pharynx":
                    for cell in PHARYNGEAL_MARGINAL_CELLS:
                        classification[cell] = cell_type
                elif cell_type == "pharyngeal epithelium":
                    for cell in PHARYNGEAL_EPITHELIUM + PHARYNGEAL_GLIAL_CELL:
                        classification[cell] = cell_type  # TODO: check!
                elif cell_type == "basement membrane":
                    for cell in PHARYNGEAL_BASEMENT_MEMBRANE:
                        classification[cell] = cell_type  # TODO: check!
                elif cell_type == "neuron with unknown function":
                    for cell in UNKNOWN_FUNCTION_NEURONS:
                        classification[cell] = cell_type
                elif cell_type == "sheath cell other than amphid sheath and phasmid":
                    for cell in CEPSH_CELLS:
                        classification[cell] = cell_type
                elif cell_type == "excretory cell":
                    for cell in EXCRETORY_CELL:
                        classification[cell] = cell_type
                elif cell_type == "sphincter and anal depressor muscle":
                    for cell in ANAL_SPHINCTER_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "gland cell":
                    for cell in EXCRETORY_GLAND:
                        classification[cell] = cell_type
                elif cell_type == "head mesodermal cell":
                    for cell in HEAD_MESODERMAL_CELL:
                        classification[cell] = cell_type
                elif cell_type == "hypodermis":
                    for cell in HYPODERMIS:
                        classification[cell] = cell_type
                elif cell_type == "intestinal cells":
                    for cell in INTESTINE:
                        classification[cell] = cell_type
                elif cell_type == "intestinal muscle":
                    for cell in INTESTINAL_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "GLR cell":
                    for cell in GLR_CELLS:
                        classification[cell] = cell_type
                elif cell_type == "diagonal muscles":
                    for cell in MALE_DIAGONAL_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "posterior outer longitudinal muscles":
                    for cell in MALE_POSTERIOR_OUTER_LONGITUDINAL_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "anterior inner longitudinal muscles":
                    for cell in MALE_ANTERIOR_INNER_LONGITUDINAL_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "posterior inner longitudinal muscles":
                    for cell in MALE_POSTERIOR_INNER_LONGITUDINAL_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "caudal inner longitudinal muscles":
                    for cell in MALE_CAUDAL_LONGITUDINAL_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "spicule retractor muscles":
                    for cell in (
                        MALE_VENTRAL_SPICULE_RETRACTOR + MALE_DORSAL_SPICULE_RETRACTOR
                    ):
                        classification[cell] = cell_type
                elif cell_type == "spicule protractor muscles":
                    for cell in (
                        MALE_VENTRAL_SPICULE_PROTRACTOR + MALE_DORSAL_SPICULE_PROTRACTOR
                    ):
                        classification[cell] = cell_type
                elif cell_type == "gubernacular retractor muscles":
                    for cell in MALE_GUBERNACULAR_RETRACTOR_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "gubernacular erector muscles":
                    for cell in MALE_GUBERNACULAR_ERECTOR_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "anterior oblique muscles":
                    for cell in MALE_ANTERIOR_OBLIQUE_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "posterior oblique muscles":
                    for cell in MALE_POSTERIOR_OBLIQUE_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "vas deferens":
                    for cell in GONAD_CELL_MALE:
                        classification[cell] = cell_type
                elif cell_type == "proctodeum":
                    for cell in PROCTODEUM_CELL_MALE:
                        classification[cell] = cell_type
                elif cell_type == "diagonal muscles":
                    for cell in MALE_DIAGONAL_MUSCLES:
                        classification[cell] = cell_type
                elif cell_type == "ray structural cell":
                    for cell in MALE_RAY_STRUCTURAL_CELLS:
                        classification[cell] = cell_type
                elif cell_type in [
                    "General code for neuronal tissue if subtype is unspecified",
                    "vulval epithelium",
                    "germline",
                    "DTC and somatic gonad",
                    "embryo",
                    "uterus",
                    "spermatheca",
                    "spermatheca-uterine valve",
                    "excretory pore cell",
                    "duct cell",
                    "excretory duct",
                    "seam cell",
                    "socket cell, XXX cells",
                    "amphid sheath and phasmid sheath",
                    "pharyngeal-intestinal valve, intestinal rectal valve",
                    "arcade cell",
                    "rectal epithelium (U, F, K, K', Y, B)",
                    "rectal gland, pharyngeal glands",
                    "pseudocoelomic space",
                    "coeloemocyte",
                    "anterior outer longitudinal muscles",
                    "seminal vesicle",
                    "sheath cell (spicules, hook or post-cloacal sensilla)",
                    "socket cell (spicules, hook or post-cloacal sensilla)",
                ]:
                    print_(
                        "No synaptic connnections to cells of type %s..?" % cell_type
                    )
                else:
                    raise Exception("Cell type %s not handled" % cell_type)
    for cell in ALL_PREFERRED_CELL_NAMES:
        assert cell in classification

    return classification

is_known_cell(cell)

Is this string the name of one of the known cells?

Parameters:

Name Type Description Default
cell str

Cell name

required

Returns:

Name Type Description
bool

Whether this is a known cell name

Source code in cect/Cells.py
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
def is_known_cell(cell: str):
    """Is this string the name of one of the known cells?

    Args:
        cell (str): Cell name

    Returns:
        bool: Whether this is a known cell name
    """
    return cell in ALL_PREFERRED_CELL_NAMES

remove_leading_index_zero(cell)

Returns neuron name with an index without leading zero. E.g. VB01 -> VB1.

Source code in cect/Cells.py
1926
1927
1928
1929
1930
1931
1932
1933
1934
def remove_leading_index_zero(cell: str):
    """
    Returns neuron name with an index without leading zero. E.g. VB01 -> VB1.
    """
    if cell[:2] in ["DA", "AS", "DD", "DB", "VA", "VB", "VC", "VD"] and cell[
        -2:
    ].startswith("0"):
        return "%s%s" % (cell[:-2], cell[-1:])
    return cell