void
ProgramOptions::validate() const
{
	SetString missing;
	 
	for (OptionGroupMap::const_iterator it = groups.begin();
		it != groups.end();
		++it){
			findMissingOptions(it->second, missing);
			 
	}
	Size sz = missing.size();
	if (sz  > 0 )
	{
		String buffer;
		std::stringstream ss(buffer);
		Size index = 0;
		for (SetString::const_iterator it = missing.begin(); it != missing.end(); ++it){
			ss << *it;
			if (index + 1 < sz)
				ss << ",";
			++index;
		}

		THROW_MSG(CoreText::instance().missingOption(ss.str()));
	}

}
void LinkInfo::addUserMod ( const ParameterList* params, int num, SetString& uniqLabels )
{
	string sNum = gen_itoa ( num );
	string label = params->getStringValue ( "mod_" + sNum + "_label", "" );
	if ( !label.empty () ) {
		string comp = params->getStringValue ( "mod_" + sNum + "_composition", "" );
		if ( !comp.empty () ) {
			string aaMod = params->getStringValue ( "aa_modified_" + sNum, "" );
			pair <SetStringIterator, bool> flag = uniqLabels.insert ( label+aaMod );
			if ( !flag.second ) {
				ErrorHandler::genError ()->error ( "Mod Labels need to be unique.\n" );
			}
			if ( aaMod == "Protein N-term" )
				userMod.push_back ( new Usermod ( label, comp, 'n', "n" ) );
			else if ( aaMod == "Protein C-term" )
				userMod.push_back ( new Usermod ( label, comp, 'c', "c" ) );
			else
				userMod.push_back ( new Usermod ( label, comp, 'e', aaMod ) );
			userLabels.push_back ( label );
			userFormulae.push_back ( comp );
			userAAs.push_back ( aaMod );
		}
		else
			ErrorHandler::genError ()->error ( "No elemental composition specified for Mod " + sNum + " Label.\n" );
	}
}
void SQLiteModifications::insert ()
{
	StringVector namesList;
	StringVector specificityList;
	StringVector elementalFormulaStrList;
	StringVector typeList;
	Usermod::getAllUsermodInfo ( namesList, specificityList, elementalFormulaStrList, typeList );
	MapStringToInt modTypes;
	int modTypeIdx = 0;
	v1 [3] = "";
	v1 [4] = "1";
	v1 [5] = "0";
	SetString ss;
	for ( int i = 0 ; i < namesList.size () ; i++ ) {
		PairSetStringIteratorBool flag = ss.insert ( namesList [i] );
		if ( flag.second ) {
			v1 [0] = namesList [i];
			v1 [1] = "formula";
			v1 [2] = elementalFormulaStrList [i];

			insertTable ( tableName, n1, v1 );
		}
	}
}
void
ProgramOptions::findMissingOptions(const OptionGroup& group, SetString& missing) const
{
	 
	for (OptionMap::const_iterator it = group.getOptions().begin(); 
		it != group.getOptions().end();
		++it)
	{
		if (it->second.isMandatory() && !isOptionDefined (it->first)){
			missing.insert(it->second.getName());
		}
	}

	for (OptionGroupMap::const_iterator git = group.getGroups().begin();
		git != group.getGroups().end();
		++git)
	{
		findMissingOptions(git->second, missing);
	}
}