agglovar.bed.col ================ .. py:module:: agglovar.bed.col .. autoapi-nested-parse:: Utilities for managing columns. Classes ------- .. autoapisummary:: agglovar.bed.col.CoordCol agglovar.bed.col.CoordColExpr Functions --------- .. autoapisummary:: agglovar.bed.col.get_coord_cols agglovar.bed.col.standardize Module Contents --------------- .. py:class:: CoordCol Bases: :py:obj:`collections.abc.Iterable`\ [\ :py:obj:`str`\ ], :py:obj:`collections.abc.Container`\ [\ :py:obj:`str`\ ] Represents coordinate columns to use. :ivar chrom: Chromosome column name. :ivar pos: Position column name. :ivar end: End column name. .. py:method:: __contains__(o: Optional[Any]) Test whether ``o`` is one of the coordinate column names. .. py:method:: __iter__() Iterate over chrom, pos, and end column names. .. py:method:: __repr__() Return a string representation. .. py:method:: exprs(alias: Optional[Self | str | tuple[str, str, str]] = None, suffix: str = None) -> CoordColExpr Get column expressions. :param alias: Alias to these columns. :param suffix: Suffix to add to the column names. :return: A tuple of column expressions. .. py:attribute:: chrom :type: str .. py:attribute:: end :type: str .. py:attribute:: pos :type: str .. py:class:: CoordColExpr Bases: :py:obj:`collections.abc.Iterable`\ [\ :py:obj:`polars.Expr`\ ] Represents coordinate column expressions. :ivar chrom: Chromosome column expression. :ivar pos: Position column expression. :ivar end: End column expression. .. py:method:: __iter__() Iterate over chrom, pos, and end expressions. .. py:method:: __repr__() Return a string representation. .. py:method:: col_names() Get the resulting column name for each column expression. :return: Column names. .. py:attribute:: chrom :type: polars.Expr .. py:property:: chrom_name :type: str Output column name of the chromosome expression. .. py:attribute:: end :type: polars.Expr .. py:property:: end_name :type: str Output column name of the end expression. .. py:attribute:: pos :type: polars.Expr .. py:property:: pos_name :type: str Output column name of the pos expression. .. py:function:: get_coord_cols(col_names: Optional[CoordCol | str | collections.abc.Iterable[str]] = None) -> CoordCol Get columns representing coordinates. Columns may have different names, such as "chrom", "pos", "end" for references or "qry_id", "qry_pos", and "qry_end" for queries. Returns a tuple of three expressions to be used in Polars selects, one for each of these three columns, to select the correct column from the input table and alias them to "chrom", "pos", and "end" with a set suffix. :param col_names: Column names. Can be an iterable of three strings, or a keyword in "ref" or "qry". None is equivalent to "ref". :return: An object with column names. .. py:function:: standardize(col: str) -> str Standardize column names. Standard column names are lower-case with alphanumeric, underscore, and dot characters only. Leading and trailing whitespace is stripped, and runs of spaces are replaced with a single underscore. All other characters are removed. :param col: Column name. :return: Standard column names.