inst/unitTests/test_synapseQuery.R

### Unit test synapseQuery
### 
### Author: Nicole Deflaux <nicole.deflaux@sagebase.org>
################################################################################
#
#.setUp <- function() {
#   ## Override getURL to not actually make a remote call
#  myGetURL <- function (url, ..., .opts = list(), write = basicTextGatherer(), 
#    curl = getCurlHandle(), async = length(url) > 1, .encoding = integer()) {
#    sampleResponse <- '{"results":[{"dataset.name":"MSKCC Prostate Cancer","dataset.releaseDate":1221350400000,"dataset.hasClinicalData":true,"dataset.version":"1.0.0","dataset.last_modified_date":[1236297600000],"dataset.hasExpressionData":true,"dataset.citation":["Integrative genomic profiling of human prostate cancer. Taylor BS et al., Cancer Cell. 2010 Jul 13;18(1):11-22.  "],"dataset.description":"Genetic and epigenetic alterations ...","dataset.creationDate":1302568102316,"dataset.number_of_downloads":[32],"dataset.hasGeneticData":true,"dataset.Posting_Restriction":["unspecified"],"dataset.id":"0","dataset.number_of_followers":[7],"dataset.Tissue_Tumor":["Prostate"],"dataset.creator":"Charles Sawyers","dataset.Species":["Human"],"dataset.Institution":["Memorial Sloan Kettering Cancer Center"],"dataset.Disease":["Cancer"],"dataset.curator":["Matt Furia"],"dataset.Type":["GCD"],"dataset.Internal_Name":["Prostate cancer-MSKCC"],"dataset.pubmed_id":[20579941],"dataset.QC_statistician":["Solly Sieberts"],"dataset.Number_of_Samples":[261],"dataset.status":"Current"},{"dataset.name":"Mouse Model of Diet-Induced Atherosclerosis","dataset.releaseDate":1280966400000,"dataset.hasClinicalData":true,"dataset.version":"1.0.0","dataset.last_modified_date":[1290384000000],"dataset.hasExpressionData":true,"dataset.citation":["Genetic loci determining bone density in mice with diet-induced atherosclerosis.  Drake TA, Schadt E, Hannani K, Kabo JM, Krass K, Colinayo V, Greaser LE 3rd, Goldin J, Lusis AJ. Physiol Genomics. 2001 Apr 27;5(4):205-15. PMID: 11328966   Genetics of gene expression surveyed in maize, mouse and man. Schadt EE, Monks SA, Drake TA, Lusis AJ, Che N, Colinayo V, Ruff TG, Milligan SB, Lamb JR, Cavet G, Linsley PS, Mao M, Stoughton RB, Friend SH. Nature. 2003 Mar 20;422(6929):297-302.PMID: 12646919 "],"dataset.description":"111 female F2 progeny of a ...","dataset.creationDate":1302568103260,"dataset.number_of_downloads":[60],"dataset.hasGeneticData":true,"dataset.Posting_Restriction":["No Restriction"],"dataset.id":"1","dataset.number_of_followers":[101],"dataset.Tissue_Tumor":["Liver"],"dataset.creator":"Jake Lusis","dataset.Species":["Mouse"],"dataset.Institution":["UCLA"],"dataset.Disease":["Metabolic Disease"],"dataset.curator":["Matt Furia"],"dataset.Type":["GCD"],"dataset.Internal_Name":["BxD"],"dataset.pubmed_id":[18406497],"dataset.QC_statistician":["Solly Sieberts"],"dataset.Number_of_Samples":[111],"dataset.status":"Current"},{"dataset.name":"Mouse Model of Sexually Dimorphic Atherosclerotic Traits","dataset.releaseDate":1252454400000,"dataset.hasClinicalData":true,"dataset.version":"1.0.0","dataset.last_modified_date":[1315699200000],"dataset.hasExpressionData":true,"dataset.citation":["Integrating genetic and network analysis to characterize genes related to mouse weight. Ghazalpour, A., et al., PLoS Genet, 2006. 2(8): p. e130.  Dosage compensation is less effective in birds than in mammals. Itoh, Y., et al., J Biol, 2007. 6(1): p. 2.  Elucidating the murine brain transcriptional network in a segregating mouse population to identify core functional modules for obesity and diabetes.  Lum, P.Y., et al., J Neurochem, 2006. 97 Suppl 1: p. 50-62.  Identification of Abcc6 as the major causal gene for dystrophic cardiac calcification in mice through integrative genomics. Meng, H., et al. Proc Natl Acad Sci U S A, 2007. 104(11): p. 4530-5.  Mapping the genetic architecture of gene expression in human liver. Schadt, E.E., et al.,  PLoS Biol, 2008. 6(5): p. e107.  Elucidating the role of gonadal hormones in sexually dimorphic gene coexpression networks.  van Nas, A., et al., Endocrinology, 2009. 150(3): p. 1235-49.  Identification of pathways for atherosclerosis in mice: integration of quantitative trait locus analysis and global gene expression data. Wang, S.S., et al., Circ Res, 2007. 101(3): p. e11-30.  Tissue-specific expression and regulation of sexually dimorphic genes in mice. Yang, X., et al., Genome Res, 2006. 16(8): p. 995-1004. "],"dataset.description":"C57BL/6J and C3H/HeJ inbred mouse strains ...","dataset.creationDate":1302568103777,"dataset.number_of_downloads":[24],"dataset.hasGeneticData":true,"dataset.Posting_Restriction":["No Restriction"],"dataset.id":"2","dataset.number_of_followers":[93],"dataset.Tissue_Tumor":["Muscle","Liver","Brain","Adipose"],"dataset.creator":"Jake Lusis","dataset.Species":["Mouse"],"dataset.Institution":["UCLA"],"dataset.Disease":["CVD"],"dataset.curator":["Matt Furia"],"dataset.Type":["GCD"],"dataset.Internal_Name":["BxH ApoE"],"dataset.pubmed_id":[19147482],"dataset.QC_statistician":["Solly Sieberts"],"dataset.Number_of_Samples":[334],"dataset.status":"Current"},{"dataset.name":"Human Liver Cohort","dataset.releaseDate":1240099200000,"dataset.hasClinicalData":true,"dataset.version":"1.0.0","dataset.last_modified_date":[1307404800000],"dataset.hasExpressionData":true,"dataset.citation":["Mapping the genetic architecture of gene expression in human liver. Eric E. Schadt, Cliona Molony, Eugene Chudin, Ke Hao, Xia Yang, Pek Y. Lum, Andrew Kasarskis, Bin Zhang, Susanna Wang, Christine Suver, Jun Zhu, Joshua Millstein, Solveig Sieberts, John Lamb, Debraj GuhaThakurta, Jonathan Derry, John D. Storey, Iliana Avila-Campillo, Mark J. Kruger, Jason M. Johnson, Carol A. Rohl, Atila van Nas, Margarete Mehrabian, Thomas A. Drake, Aldons J. Lusis, Ryan C. Smith, F. Peter Guengerich, Stephen C. Strom, Erin Schuetz, Thomas H. Rushmore, Roger Ulrich. PLoS Biol, 2008. 6(5): p. e107. PMID: 18462017 \\t \\t Systematic Genetic and Genomic Analysis of Cytochrome P450 Enzyme Activities in Human Liver. Xia Yang, Bin Zhang, Cliona Molony, Eugene Chudin, Ke Hao, Jun Zhu, Christine Suver, Hua Zhong, F. Peter Guengerich, Stephen C. Strom, Erin Schuetz, Thomas H. Rushmore, Roger G. Ulrich, J. Greg Slatter, Eric E. Schadt, Andrew Kasarskis, Pek Yee Lum. Genome Res. 2010 Aug;20(8):1020-36.   "],"dataset.description":"The Human Liver Cohort ...","dataset.creationDate":1302568104386,"dataset.number_of_downloads":[57],"dataset.hasGeneticData":false,"dataset.Posting_Restriction":["Link to data source"],"dataset.id":"3","dataset.number_of_followers":[31],"dataset.Tissue_Tumor":["Liver"],"dataset.creator":"Fred Guengrich/Steve Strom/ Erin Schuetz","dataset.Species":["Human"],"dataset.Institution":["Vanderbilt University/ University of Pittsburg/ StJudes Hospital"],"dataset.Disease":["CVD"],"dataset.curator":["Matt Furia"],"dataset.Type":["GCD"],"dataset.Internal_Name":["Deliver"],"dataset.pubmed_id":[16258887],"dataset.QC_statistician":["Solly Sieberts"],"dataset.Number_of_Samples":[517],"dataset.status":"Current"},{"dataset.name":"Heterogeneous Stock Mice","dataset.releaseDate":1306627200000,"dataset.hasClinicalData":true,"dataset.version":"1.0.0","dataset.last_modified_date":[1312329600000],"dataset.hasExpressionData":true,"dataset.citation":["Genome-wide genetic association of complex traits in heterogeneous stock mice. Valdar W, Solberg LC, Gauguier D, Burnett S, Klenerman P, Cookson WO, Taylor MS, Rawlins JN, Mott R, Flint J. Nat Genet. 2006 Aug;38(8):879-87.   A resource for the simultaneous high-resolution mapping of multiple quantitative trait loci in rats: the NIH heterogeneous stock. Johannesson M, Lopez-Aumatell R, Stridh P, Diez M, Tuncel J, Blazquez G, Martinez-Membrives E, Canete T, Vicens-Costa E, Graham D, Copley RR, Hernandez-Pliego P, Beyeen AD, Ockinger J, Fernandez-Santamaria C, Gulko PS, Brenner M, Tobena A, Guitart-Masip M, Gimenez-Llort L, Dominiczak A, Holmdahl R, Gauguier D, Olsson T, Mott R, Valdar W, Redei EE, Fernandez-Teruel A, Flint J. Genome Res. 2009 Jan;19(1):150-8.   High resolution mapping of expression QTLs in heterogeneous stock mice in multiple tissues. Huang GJ, Shifman S, Valdar W, Johannesson M, Yalcin B, Taylor MS, Taylor JM, Mott R, Flint J. Genome Res. 2009 Jun;19(6):1133-40.   http://mus.well.ox.ac.uk/mouse/HS/ "],"dataset.description":"This dataset contains data on several hundred heterogeneous stock mice derived from ...","dataset.creationDate":1302568104937,"dataset.number_of_downloads":[17],"dataset.hasGeneticData":true,"dataset.Posting_Restriction":["unspecified"],"dataset.id":"4","dataset.number_of_followers":[84],"dataset.Tissue_Tumor":["Hippocampus","Lung","Liver"],"dataset.creator":"Flint/Mott","dataset.Species":["Mouse"],"dataset.Institution":["Oxford"],"dataset.Disease":["Multiple"],"dataset.curator":["Matt Furia"],"dataset.Type":["GCD"],"dataset.Internal_Name":["Flint_Hsmice"],"dataset.pubmed_id":[16898139],"dataset.QC_statistician":["Solly Sieberts"],"dataset.Number_of_Samples":[1900],"dataset.status":"Current"},{"dataset.name":"Cancer Cell line Panel","dataset.releaseDate":1229731200000,"dataset.hasClinicalData":true,"dataset.version":"1.0.0","dataset.last_modified_date":[1257724800000],"dataset.hasExpressionData":true,"dataset.citation":["This data set was generated and is provided for public use by GlaxoSmithKline.  https://cabig.nci.nih.gov/caArray_GSKdata/ "],"dataset.description":"GlaxoSmithKline (GSK) has released the genomic profiling data for over 300 cancer cell lines via ...","dataset.creationDate":1302568105441,"dataset.number_of_downloads":[70],"dataset.hasGeneticData":true,"dataset.Posting_Restriction":["unspecified"],"dataset.id":"5","dataset.number_of_followers":[51],"dataset.Tissue_Tumor":["Cell Line"],"dataset.creator":"Richard Wooster","dataset.Species":["Human"],"dataset.Institution":["GlaxoSmithKline (GSK)"],"dataset.Disease":["Cancer"],"dataset.curator":["Matt Furia"],"dataset.Type":["GCD"],"dataset.Internal_Name":["GSK_Cell_Lines"],"dataset.pubmed_id":[20290476],"dataset.QC_statistician":["Solly Sieberts"],"dataset.Number_of_Samples":[649],"dataset.status":"Current"},{"dataset.name":"Harvard Brain Tissue Resource Center","dataset.releaseDate":1248652800000,"dataset.hasClinicalData":true,"dataset.version":"1.0.0","dataset.last_modified_date":[1307491200000],"dataset.hasExpressionData":true,"dataset.citation":["Not yet published. "],"dataset.description":"This study aims at identifying functional variation in the human genome ...","dataset.creationDate":1302568105893,"dataset.number_of_downloads":[26],"dataset.hasGeneticData":true,"dataset.Posting_Restriction":["unspecified"],"dataset.id":"6","dataset.number_of_followers":[23],"dataset.Tissue_Tumor":["Brain visual cortex","Brain cerebellum","Brain prefrontal cortex"],"dataset.creator":"Francine Benes/ Eric Schadt","dataset.Species":["Human"],"dataset.Institution":["Harvard Brain Tissue Resource Center/ Merck Research Laboratories"],"dataset.Disease":["Neurological Disease"],"dataset.curator":["Matt Furia"],"dataset.Type":["GCD"],"dataset.Internal_Name":["HBTRC"],"dataset.pubmed_id":[24584100],"dataset.QC_statistician":["Solly Sieberts"],"dataset.Number_of_Samples":[803],"dataset.status":"Current"},{"dataset.name":"Mouse Model of Blood Pressure","dataset.releaseDate":1248739200000,"dataset.hasClinicalData":true,"dataset.version":"1.0.0","dataset.last_modified_date":[1288051200000],"dataset.hasExpressionData":true,"dataset.citation":["Identification of genes and networks driving  cardiovascular and metabolic phenotypes in a mouse F2 intercross.  Derry JM, Zhong H, Molony C, MacNeil D, Guhathakurta D, Zhang B, Mudgett J, Small K, El Fertak L, Guimond A, Selloum M, Zhao W, Champy MF, Monassier L, Vogt  T, Cully D, Kasarskis A, Schadt EE.  PLoS One. 2010  Dec 14;5(12):e14319. PubMed PMID: 21179467; PubMed Central PMCID: PMC3001864.   "],"dataset.description":"An F2 population of was derived from a C57BL/6J x A/J cross (B6AF2) and traits were measured in 340 male and female progeny ...","dataset.creationDate":1302568106365,"dataset.number_of_downloads":[56],"dataset.hasGeneticData":true,"dataset.Posting_Restriction":["Embargo"],"dataset.id":"7","dataset.number_of_followers":[13],"dataset.Tissue_Tumor":["Kidney cortex","Liver","Kidney medulla","Adipose"],"dataset.creator":"Eric Schadt","dataset.Species":["Mouse"],"dataset.Institution":["Merck Research Laboratories"],"dataset.Disease":["CVD"],"dataset.curator":["Matt Furia"],"dataset.Type":["GCD"],"dataset.Internal_Name":["MCI BxA"],"dataset.pubmed_id":[21098809],"dataset.QC_statistician":["Solly Sieberts"],"dataset.Number_of_Samples":[350],"dataset.status":"Current"},{"dataset.name":"LFN-Kronos-PHASE I","dataset.releaseDate":1249776000000,"dataset.hasClinicalData":true,"dataset.version":"1.0.0","dataset.last_modified_date":[1287446400000],"dataset.hasExpressionData":true,"dataset.citation":["Genetic control of human brain transcript expression in Alzheimer disease.  Webster JA, Gibbs JR, Clarke J, Ray M, Zhang W, Holmans P, Rohrer K, Zhao A, Marlowe L, Kaleem M, McCorquodale DS 3rd, Cuello C, Leung D, Bryden L, Nath P, Zismann VL, Joshipura K, Huentelman MJ, Hu-Lince D, Coon KD, Craig DW, Pearson JV; NACC-Neuropathology Group, Heward CB, Reiman EM, Stephan D, Hardy J, Myers AJ. Am J Hum Genet. 2009 Apr;84(4):445-58. PMID: 19361613 "],"dataset.description":"This dataset surveys the relationship between the human brain transcriptome and genome ...","dataset.creationDate":1302568106860,"dataset.number_of_downloads":[28],"dataset.hasGeneticData":true,"dataset.Posting_Restriction":["unspecified"],"dataset.id":"8","dataset.number_of_followers":[59],"dataset.Tissue_Tumor":["Brain Cerebellum","Brain Parietal Cortex","Brain Temporal Cortex","Brain Frontal Cortex"],"dataset.creator":"Amanda Myers","dataset.Species":["Human"],"dataset.Institution":["University of Miami"],"dataset.Disease":["Alzheimers"],"dataset.curator":["Matt Furia"],"dataset.Type":["GCD"],"dataset.Internal_Name":["Myers_AD_PhaseI"],"dataset.pubmed_id":[21240362],"dataset.QC_statistician":["Solly Sieberts"],"dataset.Number_of_Samples":[364],"dataset.status":"Current"},{"dataset.name":"Mouse Model of Diet-Induced BreastCancer","dataset.releaseDate":1214092800000,"dataset.hasClinicalData":true,"dataset.version":"1.0.0","dataset.last_modified_date":[1216339200000],"dataset.hasExpressionData":true,"dataset.citation":["Dietary fat-dependent transcriptional architecture and copy number alterations associated with modifiers of mammary cancer metastasis. Ryan R. Gordon, Michele La Merrill, Kent W. Hunter, Peter Sørensen, David W. Threadgill and Daniel Pomp. Clinical and Experimental Metastasis; 27 (5), 279-293  Genotype X diet interactions in mice predisposed to mammary cancer: II. Tumors and metastasis. Gordon RR, Hunter KW, La Merrill M, Sørensen P, Threadgill DW, Pomp D. Mamm Genome. 2008 Mar;19(3):179-89. Epub 2008 Feb 21.  Genotype X diet interactions in mice predisposed to mammary cancer. I. Body weight and fat. Gordon RR, Hunter KW, Sørensen P, Pomp D. Mamm Genome. 2008 Mar;19(3):163-78. Epub 2008 Feb 20. "],"dataset.description":"Breast cancer is a complex disease ...","dataset.creationDate":1302568107328,"dataset.number_of_downloads":[57],"dataset.hasGeneticData":true,"dataset.Posting_Restriction":["unspecified"],"dataset.id":"9","dataset.number_of_followers":[103],"dataset.Tissue_Tumor":["Breast"],"dataset.creator":"Gordon/Pomp","dataset.Species":["Mouse"],"dataset.Institution":["UNC"],"dataset.Disease":["Cancer"],"dataset.curator":["Matt Furia"],"dataset.Type":["GCD"],"dataset.Internal_Name":["Pomp/Gordon_BreastCancer"],"dataset.pubmed_id":[15813129],"dataset.QC_statistician":["Solly Sieberts"],"dataset.Number_of_Samples":[131],"dataset.status":"Current"}],"totalNumberOfResults":123}'
#    return(sampleResponse)
#  }
#  
#  ## Override .checkCurlResponse with a do-nothing function
#  myCheckCurlResponse <- function(object,response) {}
#  
#  ## unload package namespaces so their functions can be overridden
#  unloadNamespace("synapseClient")
#  unloadNamespace("RCurl")
#  assignInNamespace("getURL", myGetURL, "RCurl")
#  assignInNamespace(".checkCurlResponse", myCheckCurlResponse, "synapseClient")
#  attachNamespace("synapseClient")
#  
#  synapseClient:::sessionToken("thisIsAFakeToken")
#}
#.tearDown <- function() {
#  unloadNamespace("synapseClient")
#  unloadNamespace("RCurl")
#  attachNamespace("synapseClient")
#}
#
#
#unitTestInvalidParameters <- function() {
#  checkException(synapseQuery(list(limit=20, offset=1)))
#}
#
### TODO there is a bug here, this is hitting the remote repository service
#unitTestJsonCorretlyParsed <- function() {
#  ## Since we have stubbed out the remote call to the service, all we
#  ## are really checking here is that synapseQuery is parsing
#  ## the JSON into the object we expect
#  datasets <- synapseQuery(query='select * from dataset')
#  
#  ## We should get back 10 datasets
#  checkEquals(nrow(datasets), 10)
#  
#  ## With 26 properties
#  ##checkEquals(ncol(datasets), 26)
#  
#  ## The fields returned by this service API may change over time, but
#  ## there are a few we should always expect to receive
#  checkTrue("dataset.id" %in% names(datasets))
#  checkTrue("dataset.name" %in% names(datasets))
#  ##checkTrue("dataset.version" %in% names(datasets))
#  checkTrue("dataset.status" %in% names(datasets))
#  ##checkTrue("dataset.Species" %in% names(datasets))
#}
#
Sage-Bionetworks/rSynapseClientRewrite documentation built on May 9, 2019, 7:06 p.m.