Skip to content

Commit

Permalink
remove old tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oganm committed May 23, 2024
1 parent e527f23 commit 9ad44e2
Showing 1 changed file with 1 addition and 106 deletions.
107 changes: 1 addition & 106 deletions gemmapy/gemmapy_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -1765,109 +1765,4 @@ def get_child_terms(self,terms:List[str])->List[str]:
# update_results currenty unimplemented and not really essential


# Tests
if __name__ == '__main__':
# dv temp
import http.client
http.client.HTTPConnection.debuglevel = 0 # put 5 to debug

import sys
from pprint import pprint

api_instance = GemmaPy()

def get_dataset_annotations_test():
print('Testing get_dataset_annotations function:')
api_response = api_instance.get_dataset_annotations("GSE46416")
pprint(api_response.data)
print('')

def search_datasets_test():
print('Testing search_datasets function:')
api_response = api_instance.search_datasets(["bipolar"], taxon="human", limit=100)
for d in api_response.data:
if d.geeq is not None and d.geeq.batch_corrected:
print(d.short_name, d.name, d.bio_assay_count)
print('')

def get_datasets_by_ids_test():
print('Testing get_datasets_by_ids function:')
api_response = api_instance.get_datasets_by_ids(["GSE46416"])
for d in api_response.data:
print(d.short_name, d.name, d.id, d.description)
print('')

def search_annotations_test():
print('Testing search_annotations function:')
api_response = api_instance.search_annotations(["GSE46416"])
print(api_response.data)

def get_dataset_object_test():
print('Testing get_dataset_object function:')
adata = api_instance.get_dataset_object("GSE46416")
print(adata)
print('\nUnstructured Info:')
for l in adata.uns: print('%s: %s' % (l, adata.uns[l]))
print('')
print('Observation metadata:')
print(adata.obs.iloc[1:10])
print('')
print('Vars metadata:')
print(adata.var.iloc[1:10])
print('')
print('Data:')
print(adata.X)
print('')

print('Subsetting the Experiment\nDisease levels')
print(adata.var['disease'].unique())
print('\nSubset: patients during manic phase and controls')
manic=adata[:,(adata.var['disease'] == 'reference_subject_role') |
(adata.var['disease'] == 'bipolar_disorder_|_manic_phase_|')].copy()
print(manic)
print(manic.var)

def get_result_sets_test():
print('Testing get_result_sets function:')
df = api_instance.get_result_sets('GSE6711')
print(df)
df2 = api_instance.get_result_set(485406)
print(df2)

def get_differential_expression_values_test():
de = api_instance.get_differential_expression_values('GSE46416')
de['diffexpr'] = 'No' # add extra column
#de['diffexpr'][(de['contrast_bipolar disorder, manic phase_logFoldChange']>1.0) &
# (de['contrast_bipolar disorder, manic phase_pvalue']<0.05)] = 'Up'
de.loc[(de['contrast_bipolar disorder, manic phase_logFoldChange'] > 1.0) &
(de['contrast_bipolar disorder, manic phase_pvalue'] < 0.05),'diffexpr'] = 'Up'
de.loc[(de['contrast_bipolar disorder, manic phase_logFoldChange'] < -1.0) &
(de['contrast_bipolar disorder, manic phase_pvalue'] < 0.05),'diffexpr'] = 'Down'
de_up = de[de['diffexpr']=='Up']
de_up = de_up[['Probe','GeneSymbol', 'contrast_bipolar disorder, manic phase_pvalue',
'contrast_bipolar disorder, manic phase_logFoldChange']].sort_values(
'contrast_bipolar disorder, manic phase_pvalue')
print('Upregulated probes')
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
print(de_up[:10])

de_dn = de[de['diffexpr']=='Down']
de_dn = de_dn[['Probe','GeneSymbol', 'contrast_bipolar disorder, manic phase_pvalue',
'contrast_bipolar disorder, manic phase_logFoldChange']].sort_values(
'contrast_bipolar disorder, manic phase_pvalue')
print('\nDownregulated probes')
with pd.option_context('display.max_rows', None, 'display.max_columns', None):
print(de_dn[:10])

def get_platform_annotations_test():
print('Testing get_platform_annotations function')
df = api_instance.get_platform_annotations('GPL96')
print(df)

if len(sys.argv) > 1:
fname = sys.argv[1]
dict = vars()
if fname in dict:
#print("Calling",fname)
func = dict[fname]
func()

0 comments on commit 9ad44e2

Please sign in to comment.