Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create python-package.yml #17

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build and test Python package
on:
push:
pull_request:
branches: [ "master" ]
jobs:
build:

runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install package
run: |
python -m pip install --upgrade pip
pip install pytest
pip install .
- name: Test with pytest
run: |
pytest
59 changes: 23 additions & 36 deletions tests/test_all.py
Original file line number Diff line number Diff line change
@@ -1,46 +1,42 @@

import sys
import gemmapy
import pytest

api = gemmapy.GemmaPy()

out = False
if len(sys.argv)>1 and sys.argv[1].startswith("out"): out = True

# test 8x getDataset... functions
for f in [s for s in dir(api) if s.startswith('get_dataset')]:
print('testing %s...' % f, end='')
@pytest.mark.parametrize('f', [s for s in dir(api) if s.startswith('get_dataset')])
def test_get_dataset_functions(f):
func = getattr(api,f)
if not f.endswith('_by_ids'):
res = func('GSE46416')
if f == 'get_datasets':
args = tuple()
elif f.endswith('_for_genes'):
args = ['GSE46416'], ['BRCA1']
elif f.endswith('_by_ids'):
args = ['GSE46416'],
else:
res = func(['GSE46416'])
print('ok')
if out: print(str(res)[:2000])

args = 'GSE46416',
res = func(*args)

# test 2x former getDataset... functions
for f in ['get_dataset_differential_expression_analyses','get_differential_expression_values']:
# if f.endswith('_values'): continue
print('testing %s...' % f, end='')
def test_get_differential_expression_values():
f = 'get_differential_expression_values'
func = getattr(api,f)
res = func('GSE46416')
print('ok')
if out: print(str(res)[:2000])

# test 4x getGene... functions
for f in [s for s in dir(api) if s.startswith('get_gene')]:
print('testing %s...' % f, end='')
@pytest.mark.parametrize('f', [s for s in dir(api) if s.startswith('get_gene')])
def test_get_gene_functions(f):
func = getattr(api,f)
if not f.endswith('_genes'):
res = func('DYRK1A')
else:
res = func(['DYRK1A'])
print('ok')
if out: print(str(res)[:2000])

# test 5x getPlatform... functions
for f in [s for s in dir(api) if s.startswith('get_platform')]:
print('testing %s...' % f, end='')
@pytest.mark.parametrize('f', [s for s in dir(api) if s.startswith('get_platform')])
def test_get_platform_functions(f):
func = getattr(api,f)
if f == 'get_platform_element':
res = func("GPL1355", ["AFFX_Rat_beta-actin_M_at"])
Expand All @@ -50,30 +46,21 @@
res = func(["GPL1355"])
else:
res = func("GPL1355")
print('ok')
if out: print(str(res)[:2000])


# test 2x search... functions
for f in [s for s in dir(api) if s.startswith('search')]:
print('testing %s...' % f, end='')
@pytest.mark.parametrize('f', [s for s in dir(api) if s.startswith('search')])
def test_search_functions(f):
func = getattr(api,f)
if f == 'search_annotations':
res = func(['traumatic'])
elif f == 'search_datasets':
res = func(['bipolar'],'human')
else:
continue
print('ok')
if out: print(str(res)[:2000])

# test 2x get_tax... functions
for f in ['get_taxa','get_taxon_datasets']:
print('testing %s...' % f, end='')
@pytest.mark.parametrize('f', ['get_taxa','get_taxon_datasets'])
def test_get_taxa_functions(f):
func = getattr(api,f)
if f.endswith('_datasets'):
res = func('worm')
res = func('human')
else:
res = func()
print('ok')
if out: print(str(res)[:2000])
7 changes: 4 additions & 3 deletions tests/test_one.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import gemmapy

api = gemmapy.GemmaPy()
res = api.get_platforms_by_ids(['GPL96'])
print(res)
def test_one():
api = gemmapy.GemmaPy()
res = api.get_platforms_by_ids(['GPL96'])
print(res)
6 changes: 3 additions & 3 deletions tests/test_tut.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import gemmapy
import pandas
import numpy as np

api_instance = gemmapy.GemmaPy()

print("Downloading expression data\nEx1")
Expand Down Expand Up @@ -29,8 +32,6 @@

# -----
print("\nDifferential expression analyses\nEx1")
import pandas
import numpy as np
de = api_instance.get_differential_expression_values('GSE46416', readableContrasts=True)
de = de[0]
# Classify probes for plotting
Expand Down Expand Up @@ -58,7 +59,6 @@

# -----
print("\nPlatform Annotations\nEx1")
import pandas
api_response = api_instance.get_platform_annotations('GPL96')
with pandas.option_context('display.max_rows', None, 'display.max_columns', None): print(api_response[:6])

Expand Down
Loading