Skip to content

Commit

Permalink
merge pandas tests with initialize, replace biocgenerics with biocutils
Browse files Browse the repository at this point in the history
  • Loading branch information
jkanche committed Nov 17, 2023
1 parent 8da8ee8 commit cb7ffa8
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 103 deletions.
6 changes: 3 additions & 3 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,10 @@ rank = gr.rank()

## Combine `GenomicRanges` objects by rows

Use the `combine` generic from [biocgenerics](https://github.com/BiocPy/generics) to concatenate multiple GenomicRanges objects.
Use the `combine` generic from [biocutils](https://github.com/BiocPy/generics) to concatenate multiple GenomicRanges objects.

```python
from biocgenerics.combine import combine
from biocutils.combine import combine
combined_gr = combine(gr, gr1, gr2, ...)
```

Expand Down Expand Up @@ -524,7 +524,7 @@ grlb = GenomicRangesList(ranges=[b, a], names=["b", "c"])
grlc = grla.combine(grlb)

# or use the combine generic
from biocgenerics.combine import combine
from biocutils.combine import combine
cgrl = combine(grla, grlb)
```

Expand Down
31 changes: 31 additions & 0 deletions tests/test_gr_initialize.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,34 @@ def test_from_pandas():
assert len(g_src) == 1
assert g_src.names is not None
assert g_src.strand is not None


def test__from_pandas_should_fail():
with pytest.raises(Exception):
df_gr = pd.DataFrame(
{
"starts": range(100, 110),
"ends": range(110, 120),
"strand": ["-", "+", "+", "*", "*", "+", "+", "+", "-", "-"],
"score": range(0, 10),
"GC": [random() for _ in range(10)],
}
)

GenomicRanges.from_pandas(df_gr)


# def test_gr_empty():
# gr = GenomicRanges(number_of_rows=100)

# assert gr is not None
# assert isinstance(gr, GenomicRanges)
# assert len(gr) == 100
# assert gr.shape == (100, 0)

# gre = GenomicRanges.empty()

# assert gre is not None
# assert isinstance(gre, GenomicRanges)
# assert len(gre) == 0
# assert gre.shape == (0, 0)
97 changes: 0 additions & 97 deletions tests/test_gr_initialize_pandas.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/test_grl_methods.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import pandas as pd
from genomicranges import GenomicRanges, GenomicRangesList
from biocgenerics.combine import combine
from biocutils.combine import combine
from biocframe import BiocFrame
from random import random
import genomicranges
Expand Down
4 changes: 2 additions & 2 deletions tests/test_names_generic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pandas as pd
from genomicranges import GenomicRanges
from biocgenerics.rownames import rownames
from biocgenerics.colnames import colnames
from biocutils.rownames import rownames
from biocutils.colnames import colnames
from random import random
import genomicranges

Expand Down

0 comments on commit cb7ffa8

Please sign in to comment.