示例#1
0
 def testBasics(self):
     rsquareds = DBLoaders.loadKeyedDataSetFromDB(self.db_filename, "genes", "gene", "R2")
     genenames = DBLoaders.loadKeyedDataSetFromDB(self.db_filename, "genes", "gene", "genename")
     snpcount = DBLoaders.loadKeyedDataSetFromDB(self.db_filename, "genes", "gene", "snp_count")
     self.assertEqual(self.db_filename, rsquareds.name)
     idx = 0
     for gene in self.genes:
         self.assertEqual(gene.rsq, rsquareds.values_by_key[gene.gene], "RSquared for %s" % (gene.gene))
         self.assertEqual(gene.genename, genenames.values_by_key[gene.gene], "Genename for %s (%s, %s)" % (gene.gene, gene.genename,genenames.values_by_key[gene.gene]))
         self.assertEqual(gene.snp_count, snpcount.values_by_key[gene.gene], "Snp Count for %s (%s, %s)" % (gene.gene, gene.snp_count, snpcount.values_by_key[gene.gene]))
         idx += 1
示例#2
0
 def testExceptions(self):
     with self.assertRaises(Exceptions.BadFilename) as fnexcpt:
         badfilename = DBLoaders.loadKeyedDataSetFromDB("bad_filename", "genes", "gene", "R2")
     self.assertEqual("Invalid filename: bad_filename", fnexcpt.exception.msg)
     with self.assertRaises(Exceptions.InvalidDbFormat) as fnexcpt:
         badtablename = DBLoaders.loadKeyedDataSetFromDB(self.db_filename, "tissues", "gene", "R2")
     self.assertEqual("\t'no such table: %s'"% ("tissues"), fnexcpt.exception.msg.split("\n")[1])
     with self.assertRaises(Exceptions.InvalidDbFormat) as fnexcpt:
         badcolone = DBLoaders.loadKeyedDataSetFromDB(self.db_filename, "genes", "tissue", "R2")
     self.assertEqual("\t'no such column: %s'"% ("tissue"), fnexcpt.exception.msg.split("\n")[1])
     with self.assertRaises(Exceptions.InvalidDbFormat) as fnexcpt:
         badcoltwo = DBLoaders.loadKeyedDataSetFromDB(self.db_filename, "genes", "gene", "R1")
     self.assertEqual("\t'no such column: %s'"% ("R1"), fnexcpt.exception.msg.split("\n")[1])
示例#3
0
 def testCovariances(self):
     covariances, valid_keys = DBLoaders.loadCovarianceMatrix(self.db_filename, None)
     self.assertEqual(len(self.cv_valid_keys), len(valid_keys))
     self.assertTrue(numpy.array_equal(self.covariances, covariances))
示例#4
0
 def testVariance(self):
     variances = DBLoaders.loadVariancesFromDB(self.db_filename)
     self.assertEqual(len(self.variances), len(variances.values_by_key))
     for var in self.variances:
         self.assertAlmostEqual(var.var, variances.values_by_key[var.rsid], 0.01)