def init(self): if self.db.DoesTableExist(self.THERMODYNAMICS_TABLE_NAME): logging.info('Reading thermodynamic data from database') reader = self.db.DictReader(self.THERMODYNAMICS_TABLE_NAME) PsuedoisomerTableThermodynamics._FromDictReader( reader, self, label=None, name="Unified Group Contribution", warn_for_conflicting_refs=False) conservation_rows = [] for row in self.db.DictReader(self.CONSERVATIONS_TABLE_NAME): sparse = dict((int(cid), coeff) for (cid, coeff) in json.loads(row['json']).iteritems()) msg = row['msg'] conservation_rows.append((msg, sparse)) logging.info('Reading conservation matrix data from database') all_cids = sorted(self.kegg.get_all_cids()) cid_dict = dict((cid, i) for (i, cid) in enumerate(all_cids)) self.P_L_tot = np.matrix(np.zeros((len(conservation_rows), len(all_cids)))) for i, (msg, sparse) in enumerate(conservation_rows): for cid, coeff in sparse.iteritems(): if cid not in cid_dict: raise Exception("ERROR: C%05d is not found in KEGG but appears in our database" % cid) self.P_L_tot[i, cid_dict[cid]] = float(coeff) else: self.LoadGroups(True) self.LoadObservations(True) self.LoadGroupVectors(True) self.LoadData(True) self.EstimateKeggCids()
def setUp(self): fake_csv_file = StringIO(CSV_DATA) csv_reader = csv.DictReader(fake_csv_file) self.fake_thermo_csv = PsuedoisomerTableThermodynamics() self.fake_thermo_csv = PsuedoisomerTableThermodynamics._FromDictReader( csv_reader, self.fake_thermo_csv, warn_for_conflicting_refs=False) db = SqliteDatabase(PUBLIC_DB_FNAME) db_reader = db.DictReader('fake_pseudoisomers') self.fake_thermo_db = PsuedoisomerTableThermodynamics() self.fake_thermo_db = PsuedoisomerTableThermodynamics._FromDictReader( db_reader, self.fake_thermo_db, warn_for_conflicting_refs=False)
def init(self): self.LoadGroups(True) self.LoadObservations(True) self.LoadGroupVectors(True) if self.db.DoesTableExist(self.CONTRIBUTION_TABLE_NAME): self.LoadContributionsFromDB() else: self.Train() self.EstimateKeggCids() reader = self.db.DictReader(self.THERMODYNAMICS_TABLE_NAME) PsuedoisomerTableThermodynamics._FromDictReader( reader, self, label=None, name="Group Contribution", warn_for_conflicting_refs=False)
def init(self): self.LoadGroups(True) self.LoadObservations(True) self.LoadGroupVectors(True) if self.db.DoesTableExist(self.CONTRIBUTION_TABLE_NAME): self.LoadContributionsFromDB() else: self.Train() self.EstimateKeggCids() reader = self.db.DictReader(self.THERMODYNAMICS_TABLE_NAME) PsuedoisomerTableThermodynamics._FromDictReader( reader, self, label=None, name="Group Contribution", warn_for_conflicting_refs=False)
def init(self): if self.db.DoesTableExist(self.THERMODYNAMICS_TABLE_NAME): logging.info('Reading thermodynamic data from database') reader = self.db.DictReader(self.THERMODYNAMICS_TABLE_NAME) PsuedoisomerTableThermodynamics._FromDictReader( reader, self, label=None, name="Unified Group Contribution", warn_for_conflicting_refs=False) conservation_rows = [] for row in self.db.DictReader(self.CONSERVATIONS_TABLE_NAME): sparse = dict( (int(cid), coeff) for (cid, coeff) in json.loads(row['json']).iteritems()) msg = row['msg'] conservation_rows.append((msg, sparse)) logging.info('Reading conservation matrix data from database') all_cids = sorted(self.kegg.get_all_cids()) cid_dict = dict((cid, i) for (i, cid) in enumerate(all_cids)) self.P_L_tot = np.matrix( np.zeros((len(conservation_rows), len(all_cids)))) for i, (msg, sparse) in enumerate(conservation_rows): for cid, coeff in sparse.iteritems(): if cid not in cid_dict: raise Exception( "ERROR: C%05d is not found in KEGG but appears in our database" % cid) self.P_L_tot[i, cid_dict[cid]] = float(coeff) else: self.LoadGroups(True) self.LoadObservations(True) self.LoadGroupVectors(True) self.LoadData(True) self.EstimateKeggCids()