Beispiel #1
0
def _get_df(self, n, sort):

    half_entries = int(n / 2)

    if len(self) <= n:
        df = self.df.astype(object)
    else:
        if self.stranded:
            top = _get_stranded_f(self, half_entries, "head", sort)
            bottom = _get_stranded_f(self, half_entries, "tail", sort)
        else:
            top = _get_unstranded_f(self, half_entries, "head", sort)
            bottom = _get_unstranded_f(self, half_entries, "tail", sort)

        middle = top.head(1)
        # dot_dot_line.loc[:, :] = "..."
        df = pd.concat([top, middle, bottom]).astype(object)

    return df
Beispiel #2
0
def _get_df(self, n, sort):

    half_entries = int(n / 2)

    if len(self) <= n:
        df = self.df.astype(object)
        if sort:
            df = df.sort_values(sort_cols)
    else:
        if self.stranded:
            top = _get_stranded_f(self, half_entries, "head", sort)
            bottom = _get_stranded_f(self, half_entries, "tail", sort)
        else:
            top = _get_unstranded_f(self, half_entries, "head", sort)
            bottom = _get_unstranded_f(self, half_entries, "tail", sort)

        middle = top.head(1)
        # dot_dot_line.loc[:, :] = "..."
        df = pd.concat([top, middle, bottom]).astype(object)

    # df = df.reset_index(drop=True)
    # df = df.reindex(index=natsort.order_by_index(df.index, natsort.index_natsorted(zip(df.Chromosome))))

    return df
Beispiel #3
0
        _columns_dtypes = {}
        _columns_dtypes["- Position -"] = "Multiple types"
        for k, v in columns_dtypes.items():
            _columns_dtypes[k] = v
        columns_dtypes = _columns_dtypes

    df = df.astype(object).reset_index(drop=True)
    if len(self) > n:
        middle = int(n / 2)
        df.loc[middle, :] = "..."

    str_repr, hidden_columns = grow_string_representation(df, columns_dtypes)

    str_repr = add_text_to_str_repr(self, str_repr, hidden_columns, sort)

    return str_repr


if __name__ == "__main__":

    from pyranges.tostring2 import _get_stranded_f, _get_unstranded_f
    from pyranges.tostring2 import tostring
    import pyranges as pr
    gr = pr.data.chipseq()
    df = gr.df
    _get_stranded_f(gr, 2, "head")
    _get_unstranded_f(gr.unstrand(), 6, "tail")

    tostring(gr)