Exemplo n.º 1
0
    def test_create(self):
        """Correctly creates the rows in the DB for the reference"""
        # Check that the returned object has the correct id
        obs = Reference.create(self.name, self.version, self.seqs_fp,
                               self.tax_fp, self.tree_fp)
        self.assertEqual(obs.id, 2)

        # Check that the information on the database is correct
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.reference WHERE reference_id=2")
        exp = [[2, self.name, self.version, 15, 16, 17]]
        self.assertEqual(obs, exp)

        # Check that the filepaths have been correctly added to the DB
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.filepath WHERE filepath_id=15 or "
            "filepath_id=16 or filepath_id=17")
        exp_seq = join(
            self.db_dir,
            "%s_%s_%s" % (self.name, self.version, basename(self.seqs_fp)))
        exp_tax = join(
            self.db_dir,
            "%s_%s_%s" % (self.name, self.version, basename(self.tax_fp)))
        exp_tree = join(
            self.db_dir,
            "%s_%s_%s" % (self.name, self.version, basename(self.tree_fp)))
        exp = [[15, exp_seq, 9, '0', 1], [16, exp_tax, 10, '0', 1],
               [17, exp_tree, 11, '0', 1]]
        self.assertEqual(obs, exp)
Exemplo n.º 2
0
    def test_create(self):
        """Correctly creates the rows in the DB for the reference"""
        # Check that the returned object has the correct id
        obs = Reference.create(self.name, self.version, self.seqs_fp,
                               self.tax_fp, self.tree_fp)
        self.assertEqual(obs.id, 2)

        # Check that the information on the database is correct
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.reference WHERE reference_id=2")
        exp = [[2, self.name, self.version, 19, 20, 21]]
        self.assertEqual(obs, exp)

        # Check that the filepaths have been correctly added to the DB
        obs = self.conn_handler.execute_fetchall(
            "SELECT * FROM qiita.filepath WHERE filepath_id=19 or "
            "filepath_id=20 or filepath_id=21")
        exp_seq = "%s_%s_%s" % (self.name, self.version,
                                basename(self.seqs_fp))
        exp_tax = "%s_%s_%s" % (self.name, self.version,
                                basename(self.tax_fp))
        exp_tree = "%s_%s_%s" % (self.name, self.version,
                                 basename(self.tree_fp))
        exp = [[19, exp_seq, 10, '0', 1, 6],
               [20, exp_tax, 11, '0', 1, 6],
               [21, exp_tree, 12, '0', 1, 6]]
        self.assertEqual(obs, exp)
Exemplo n.º 3
0
    def test_purge_filepaths_null_cols(self):
        # For more details about the source of the issue that motivates this
        # test: http://www.depesz.com/2008/08/13/nulls-vs-not-in/
        # In the current set up, the only place where we can actually have a
        # null value in a filepath id is in the reference table. Add a new
        # reference without tree and taxonomy:
        fd, seqs_fp = mkstemp(suffix="_seqs.fna")
        close(fd)
        ref = Reference.create("null_db", "13_2", seqs_fp)
        self.files_to_remove.append(ref.sequence_fp)

        self._common_purge_filpeaths_test()
Exemplo n.º 4
0
    def test_purge_filepaths_null_cols(self):
        # For more details about the source of the issue that motivates this
        # test: http://www.depesz.com/2008/08/13/nulls-vs-not-in/
        # In the current set up, the only place where we can actually have a
        # null value in a filepath id is in the reference table. Add a new
        # reference without tree and taxonomy:
        fd, seqs_fp = mkstemp(suffix="_seqs.fna")
        close(fd)
        ref = Reference.create("null_db", "13_2", seqs_fp)
        self.files_to_remove.append(ref.sequence_fp)

        self._common_purge_filpeaths_test()