Beispiel #1
0
    def test1(self):

        outfiles = taxonomy.get_ncbi_tax_data(dest_dir=outputdir)
        names_data, nodes_data = taxonomy.read_bacterial_taxonomy(primary_only=False, **outfiles)

        dbname = complete_test_db

        if not os.access(dbname, os.F_OK):
            log.warning('creating %s' % dbname)
            dbname = taxonomy.create_bacterial_taxonomy_db(
                names_data=names_data,
                nodes_data=nodes_data,
                dbname=dbname,
                dest_dir=outputdir
                )
            self.assertTrue(os.access(dbname, os.F_OK))
        else:
            log.info('%s exists, skipping this test' % dbname)
Beispiel #2
0
    def testCreateBacterialTaxonomyDb02(self):

        outfiles = taxonomy.get_ncbi_tax_data(dest_dir=outputdir)
        names_data, nodes_data = taxonomy.read_bacterial_taxonomy(primary_only=False, **outfiles)

        dbname = taxonomy.create_bacterial_taxonomy_db(
            names_data=itertools.islice(names_data, 0, 1000),
            nodes_data=itertools.islice(nodes_data, 0, 1000),
            dbname=self.funcname+'.db',
            dest_dir=outputdir
            )

        self.assertTrue(os.access(dbname, os.F_OK))

        con = sqlite.connect(dbname)
        synonyms = con.cursor().execute('select count(*) from names where is_primary = 0').fetchone()[0]

        # nodes.source should be zero by default
        sources = con.cursor().execute('select source_id from nodes').fetchall()
        self.assertEqual( set(x[0] for x in sources), set([1]) )
Beispiel #3
0
    def testCreateBacterialTaxonomyDb01(self):

        outfiles = taxonomy.get_ncbi_tax_data(dest_dir=outputdir)
        names_data, nodes_data = taxonomy.read_bacterial_taxonomy(**outfiles)

        dbname = taxonomy.create_bacterial_taxonomy_db(
            names_data=itertools.islice(names_data, 0, 1000),
            nodes_data=itertools.islice(nodes_data, 0, 1000),
            dbname=self.funcname+'.db',
            dest_dir=outputdir
            )

        self.assertTrue(os.access(dbname, os.F_OK))

        con = sqlite.connect(dbname)
        synonyms = con.cursor().execute('select count(*) from names where is_primary = 0').fetchone()[0]
        self.assertEqual(synonyms, 0)

        ranks = con.cursor().execute('select rank from nodes group by rank').fetchall()
        ## rank names should not contain whitespace
        self.assertEqual(ranks, [('_'.join(x[0].split()),) for x in ranks])