Ejemplo n.º 1
0
bool read_record(Driver* driver, string record){
    if (record == CONTINUE)
        return true;
    if (isallspace(record))
        return false;
    istringstream is(record, ios::in);
    string line;
    int i = 0;
    do{
        ++i;
        line = line.substr(0, line.find(COMMENT));
        if (!line.empty() && !isallspace(line)){
            char tag = line[0];
            string line2 = line.substr(1);
            try{
                switch(tag){
                    case OBJTAG:
                        if (driver->target.empty())
                            read_objective(driver, line2);
                        break;
                    case ARGTAG:
                        if (driver->arg.empty())
                            driver->set_args(line2);
                        break;
                    //case EXTTAG:
                    //    driver->set_externals(line2, true);//externalise the list provided in line2
                    //    break;
                    //case INTTAG:
                    //    driver->set_externals(line2, false);//internalise the list provided in line2
                    //    break;
                    case EXTTAG://w/ simply set externals with '\'
                        driver->set_externals_gfa(line2);
                        break;
                    case VMAXTAG:
                        driver->lp->setVMax(str2double(line2));
                        break;
//                    case TTAG:
//                        if (driver->thermo) ((ThermoLP*)driver->lp)->setTemperature(T0 + str2double(line2));
//                        break;
                    default:
                        try{
                            read_constraint(driver, line, tag);
                        }
                        catch(exception &e){;}
                }
            }
            catch(exception &e) {
                throw runtime_error(string("error in line ") + num2str(i) + ": " + e.what());
            }
        }
    }
    while(getline(is, line, NEWLINE));
    return true;
}
Ejemplo n.º 2
0
//w/gni/ read record for Gene nutrient interaction(gni)
bool read_record_gni(Driver* driver, Model* model, string record){
    if (record == CONTINUE)
        return true;
    if (isallspace(record))
        return false;
    istringstream is(record, ios::in);
    string line;
    int i = 0;
    do{
        ++i;
        line = line.substr(0, line.find(COMMENT));
        if (!line.empty() && !isallspace(line)){
            char tag = line[0];
            string line2 = line.substr(1);
            try{
                switch(tag){
                    case OBJTAG:
                        if (driver->target.empty()) throw runtime_error("please specify a biomass reaction!");
                        driver->gni->set_nts(line2, driver->externals, driver->model);
//                        driver->gni->map_nt_reac(model);
                        break;
                    case DOLTAG:
                        driver->gni->set_ntsp(line2);
                        break;
                    case ARGTAG:
                        if (driver->arg.empty())
                            driver->set_args(line.substr(1));
                        break;
//                    case EXTTAG:
//                        driver->set_externals(line2, true);//externalise the list provided in line2
//                        break;
//                    case INTTAG:
//                        driver->set_externals(line2, false);//internalise the list provided in line2
//                        break;
                    case EXTTAG:
                        driver->set_externals_gfa(line2);
                        break;
                    default:
                        try{
                            read_constraint_mod(driver, line, tag);
                        }
                        catch(exception &e){;}
                }
            }
            catch(exception &e) {
                throw runtime_error(string("error in line ") + num2str(i) + ": " + e.what());
            }
        }
    }
    while(getline(is, line, NEWLINE));
    return true;
}
Ejemplo n.º 3
0
static list_t *m_search_para(
		motion_arg const *a, list_t *l,
		int *pn, const void *ctx)
{
	/* while in space, find non-space */
	for(; l && (!l->line || isallspace(l->line, l->len_line));
			l = list_advance_y(l, a->dir, pn, NULL));

	/* while in non-space, find space */
	for(; l && (l->line && !isallspace(l->line, l->len_line));
			l = list_advance_y(l, a->dir, pn, NULL));

	return l;
}