How to use the bioframe.ops._verify_columns function in bioframe

To help you get started, we’ve selected a few bioframe examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mirnylab / bioframe / bioframe / genomeops.py View on Github external
pd.DataFrame(chromsizes).reset_index().rename(columns={"index": ck1})
        )
    elif isinstance(chromsizes, pd.DataFrame):
        df_chroms = chromsizes.copy()
    else:
        raise ValueError("unknown input type for chromsizes")

    if isinstance(midpoints, dict):
        df_mids = pd.DataFrame.from_dict(midpoints, orient="index", columns=[sk2])
        df_mids.reset_index(inplace=True)
        df_mids.rename(columns={"index": ck2}, inplace=True)
    elif isinstance(midpoints, pd.DataFrame):
        df_mids = midpoints.copy()

    ops._verify_columns(df_mids, [ck2, sk2])
    ops._verify_columns(df_chroms, [ck1, sk1])

    df_chroms["start"] = 0
    df_chroms["end"] = df_chroms[sk1].values

    df_chromarms = ops.split(
        df_chroms,
        df_mids,
        add_names=True,
        cols=(ck1, "start", "end"),
        cols_points=(ck2, sk2),
        suffixes=suffixes,
    )
    df_chromarms["name"].replace("[\:\[].*?[\)\_]", "", regex=True, inplace=True)
    df_chromarms.drop(columns=["index_2", "length"], inplace=True)
    return df_chromarms
github mirnylab / bioframe / bioframe / genomeops.py View on Github external
df_chroms = (
            pd.DataFrame(chromsizes).reset_index().rename(columns={"index": ck1})
        )
    elif isinstance(chromsizes, pd.DataFrame):
        df_chroms = chromsizes.copy()
    else:
        raise ValueError("unknown input type for chromsizes")

    if isinstance(midpoints, dict):
        df_mids = pd.DataFrame.from_dict(midpoints, orient="index", columns=[sk2])
        df_mids.reset_index(inplace=True)
        df_mids.rename(columns={"index": ck2}, inplace=True)
    elif isinstance(midpoints, pd.DataFrame):
        df_mids = midpoints.copy()

    ops._verify_columns(df_mids, [ck2, sk2])
    ops._verify_columns(df_chroms, [ck1, sk1])

    df_chroms["start"] = 0
    df_chroms["end"] = df_chroms[sk1].values

    df_chromarms = ops.split(
        df_chroms,
        df_mids,
        add_names=True,
        cols=(ck1, "start", "end"),
        cols_points=(ck2, sk2),
        suffixes=suffixes,
    )
    df_chromarms["name"].replace("[\:\[].*?[\)\_]", "", regex=True, inplace=True)
    df_chromarms.drop(columns=["index_2", "length"], inplace=True)
    return df_chromarms