def test_mongo(self): self.assertIsInstance(Sample.mongo(), pymongo.collection.Collection) cursor=Sample.mongo().find() warn("cursor: got %d records" % cursor.count()) self.assertTrue(cursor.count() > 1) record=cursor.next() self.assertTrue('geo_id' in record) self.assertTrue('_id' in record)
def test_exp_data(self): sample = Sample('GSM15718').populate() # GSM15718 comes from GSE994 (id_type, data) = sample.expression_data('probe') self.assertEqual(id_type, 'probe') self.assertEqual(len(data), 22215) self.assertEqual(data['200003_s_at'], 2483.300) self.assertEqual(data['1438_at'], 78.500) self.assertEqual(data['200707_at'], 159.800) self.assertEqual(data['200773_x_at'], 2505.100) self.assertEqual(data['200981_x_at'], 2842.700) self.assertEqual(data['91682_at'], 65.000)
def test_exp_data(self): sample=Sample('GSM15718').populate() # GSM15718 comes from GSE994 (id_type,data)=sample.expression_data('probe') self.assertEqual(id_type, 'probe') self.assertEqual(len(data), 22215) self.assertEqual(data['200003_s_at'], 2483.300) self.assertEqual(data['1438_at'], 78.500) self.assertEqual(data['200707_at'], 159.800) self.assertEqual(data['200773_x_at'], 2505.100) self.assertEqual(data['200981_x_at'], 2842.700) self.assertEqual(data['91682_at'], 65.000)
def test_init_geo_id(self): geo_id='GSM30429' s1=Sample(geo_id); self.assertIs(s1.geo_id, geo_id) self.assertFalse(hasattr(s1, 'dataset_ids')) self.assertFalse(hasattr(s1, 'subset_ids')) self.assertFalse(hasattr(s1, 'series_ids')) s1.populate() self.assertTrue(hasattr(s1, 'dataset_ids')) self.assertTrue(hasattr(s1, 'subset_ids')) self.assertTrue(hasattr(s1, 'series_ids'))
def test_init_geo_id(self): geo_id = 'GSM30429' s1 = Sample(geo_id) self.assertIs(s1.geo_id, geo_id) self.assertFalse(hasattr(s1, 'dataset_ids')) self.assertFalse(hasattr(s1, 'subset_ids')) self.assertFalse(hasattr(s1, 'series_ids')) s1.populate() self.assertTrue(hasattr(s1, 'dataset_ids')) self.assertTrue(hasattr(s1, 'subset_ids')) self.assertTrue(hasattr(s1, 'series_ids'))
def test_all_ids_with_pheno(self): phenos=[ "normal", "adenocarcinoma", "squamous cell carcinoma", "asthma", "chronic obstructive pulmonary disease", "large cell lung carcinoma" ] for pheno in phenos: ids=Sample.all_ids_with_pheno(pheno) self.assertIsInstance(ids, list) warn("got %d '%s' samples" % (len(ids), pheno)) self.assertTrue(len(ids) > 0) ids_with_data=[x for x in ids if os.access(Sample.data_path_of(geo_id=x), os.R_OK)] warn("got %d '%s' samples with data" % (len(ids_with_data), pheno))
def test_all_ids_with_pheno(self): phenos = [ "normal", "adenocarcinoma", "squamous cell carcinoma", "asthma", "chronic obstructive pulmonary disease", "large cell lung carcinoma" ] for pheno in phenos: ids = Sample.all_ids_with_pheno(pheno) self.assertIsInstance(ids, list) warn("got %d '%s' samples" % (len(ids), pheno)) self.assertTrue(len(ids) > 0) ids_with_data = [ x for x in ids if os.access(Sample.data_path_of(geo_id=x), os.R_OK) ] warn("got %d '%s' samples with data" % (len(ids_with_data), pheno))
def test_all_ids_with_data(self): ids=Sample.all_ids_with_data(id_type='probe') warn("len(ids)=%d" % (len(ids))) self.assertTrue(len(ids) > 1000)
def test_all_with_data_gene(self): samples = Sample.all_with_data(id_type='gene') warn("got %d 'gene' samples" % (len(samples))) self.assertTrue(len(samples) > 100)
def test_all_with_data_probe(self): samples = Sample.all_with_data(id_type='probe', ids_only=True) warn("got %d 'probe' samples" % (len(samples))) self.assertTrue(len(samples) > 100)
def test_all_with_data_gene(self): samples=Sample.all_with_data(id_type='gene') warn("got %d 'gene' samples" % (len(samples))) self.assertTrue(len(samples)>100)
def test_all_with_data_probe(self): samples=Sample.all_with_data(id_type='probe', ids_only=True) warn("got %d 'probe' samples" % (len(samples))) self.assertTrue(len(samples)>100)
def test_init_dict(self): geo_id = 'GSM30429' s1 = Sample({'geo_id': geo_id, 'name': 'fred'}) self.assertEqual(s1.geo_id, geo_id) self.assertEqual(s1.name, 'fred')