Ejemplo n.º 1
0
    def test_schema_is_sane(self):
        dropdb()
        createdb()
        self.assertFalse(schema_is_sane())
        createtable(tables[0][0])
        self.assertFalse(schema_is_sane())

        for tablename, _ in tables[1:]:
            createtable(tablename)

        self.assertTrue(schema_is_sane())
Ejemplo n.º 2
0
 def test_create_database(self):
     dropdb()
     create_database()
     self.assertTrue(database_connectivity())
     self.assertTrue(database_exists())
     self.assertTrue(schema_is_sane())
     self.assertFalse(schema_has_data())
Ejemplo n.º 3
0
            except:
                continue
            sample_id = filename.rstrip('.fastq.gz').strip('seqs_')
            insert_fastq_sample(cur, sample_id, fq_url)


if __name__ == '__main__':
    import sys

    if not database_connectivity():
        sys.stderr.write("Cannot connect to the database\n")
        sys.exit(1)
    if not database_exists():
        sys.stderr.write('Database does not exist\n')
        sys.exit(1)
    if not schema_is_sane():
        sys.stderr.write('Schema does not appear to be sane\n')
        sys.exit(1)

    c = connect(user=agr.admin_db_user, host=agr.db_host,
                password=agr.admin_db_password, dbname=agr.db_name)
    c.set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT)
    cur = c.cursor()

    if biom_unchanged(cur):
        # data are the same, no change
        sys.exit(0)

    do_biom_update(cur)
    do_fq_update(cur)
    update_biom_sha(cur)