Example #1
0
    def create(self, meta_values={}):
        self.db = db.DB(self.db_path, t.profile_db_version, new_database=True)

        for key in meta_values:
            self.db.set_meta_value(key, meta_values[key])

        self.db.set_meta_value('creation_date', time.time())

        # creating empty default tables
        self.db.create_table(t.profile_table_name, t.profile_table_structure,
                             t.profile_table_types)

        self.disconnect()

        self.run.info('Profile database',
                      'A new database, %s, has been created.' % (self.db_path),
                      quiet=self.quiet)
Example #2
0
    def init(self):
        if os.path.exists(self.db_path):
            self.db = db.DB(self.db_path, t.profile_db_version)
            meta_table = self.db.get_table_as_dict('self')
            self.meta = dict([(k, meta_table[k]['value']) for k in meta_table])
            stats_table = self.db.get_table_as_dict('stats')
            self.stats = dict([(k, int(stats_table[k]['value']))
                               for k in stats_table])

            self.run.info('tRNA Profile database',
                          'An existing database, %s, has been initiated.' %
                          self.db_path,
                          quiet=self.quiet)
            self.run.info('Sample name',
                          self.meta['sample_name'],
                          quiet=self.quiet)
        else:
            self.db = None