Exemplo n.º 1
0
bool ProNovoConfig::getResidueElementalComposition(string & sAtomicCompositionTable)
{
	sAtomicCompositionTable = "";

	map<string, string> mapResidueTable;
	if( ! getConfigMasterKeyValue("[Peptide_Identification]Residue", mapResidueTable) )
	{
		cerr << "Error: cannot retrieve Elemental composition of amino acid residues." << endl;
		return false;
	}

	map<string, string>::iterator iter;

	for (iter = mapResidueTable.begin(); iter != mapResidueTable.end(); ++iter) 
	{
		sAtomicCompositionTable.append( iter->first );
		sAtomicCompositionTable.append( ",\t" );
		sAtomicCompositionTable.append( iter->second );
		sAtomicCompositionTable.append( "\n" );
	}
	replaceDelimitor( sAtomicCompositionTable, ',', '\t' );
	return true;
}
Exemplo n.º 2
0
bool ProRataConfig::getResidueAtomicComposition(residueMap & mIsotopologue)
{
	mIsotopologue.clear();

	// Creat a TinyXML document for ProRataConfig.XML
	TiXmlDocument txdConfigFile;

	// Try loading the file.
	if ( ! ( txdConfigFile.LoadFile( sFilename.c_str() ) ) )
	{
		cout << "ERROR! Loading Configuration file" << endl;
		return false;
	}	

	/*
	 * move the node pointer to RESIDUE_ATOMIC_COMPOSITION
	 * if failed, return an empty map
	 */
	TiXmlNode * txnTemp = NULL;

	txnTemp = txdConfigFile.FirstChild( "CONFIG" );
	if ( ! txnTemp )
		return false;
	
	txnTemp = txnTemp->FirstChild( "SIC_EXTRACTION" );
	if ( ! txnTemp )
		return false;
	
	txnTemp = txnTemp->FirstChild( "RESIDUE_ATOMIC_COMPOSITION" );
	if ( ! txnTemp )
		return false;

	// a node pointer to a ISOTOPOLOGUE element
	TiXmlNode * txnTable = NULL;
	
	// a element pointer for retrieving the attribute of the ISOTOPOLOGUE element
	TiXmlElement * txeElement = NULL;

	// a text pointer for retrieving the text inside ISOTOPOLOGUE element
	TiXmlText * txsText = NULL;
		
	/*
	 * the node type can any one of the following:
	 * enum NodeType
	 * {
	 * 	DOCUMENT,
	 * 	ELEMENT,
	 * 	COMMENT,
	 * 	UNKNOWN,
	 * 	TEXT,
	 * 	DECLARATION,
	 * 	TYPECOUNT
	 * };
	 * 
	*/
	
	// loop thru all ISOTOPOLOGUE elements	
	for( txnTemp = txnTemp->FirstChild( "ISOTOPOLOGUE" ); txnTemp; txnTemp = txnTemp->NextSibling( "ISOTOPOLOGUE" )  )
	{
		// the string for holding the text inside
		string sTable = "";

		/*
		 * loop thru all the text nodes inside ISOTOPOLOGUE;
		 * the text nodes can be separated by the comment nodes or other
		 * cast the node to a text node, only if it is of type TEXT, which equals 4
		 * then concatenate all the text
		 */
		for( txnTable = txnTemp->FirstChild("R"); txnTable; txnTable = txnTable->NextSibling("R") )
		{
			txsText =  txnTable->FirstChild()->ToText();
			sTable.append( txsText->Value() );
			sTable.append( "\n" );
				
			/*
			// get the type of the node
			if( txnTable->Type() == 4 )
			{
				// cast the node to a TEXT node
				txsText = txnTable->ToText();
				// get the value of the TEXT node and append it to sTable
				sTable.append( txnTable->Value() );
			}
			*/
		}
		replaceDelimitor( sTable, ',', '\t' );

		// points txeElement to the ISOTOPOLOGUE element 
		txeElement = txnTemp->ToElement();
		if( txeElement )
		{
			// get the "name" Attribute of the element
			string sName = txeElement->Attribute( "name" );
			// save the sName-sTable pair to the return value
			mIsotopologue[ sName ] = sTable;
		}
		
	}
			
	return true;

}
Exemplo n.º 3
0
bool ProRataConfig::getAtomIsotopicComposition( char cAtom, 
		vector<double> & vdAtomicMass,  
		vector<double> & vdNaturalComposition,
		vector<double> & vdEnrichedComposition)
{

	// clear the input vectors
	vdAtomicMass.clear();
	vdNaturalComposition.clear();
	vdEnrichedComposition.clear();

	// Creat a TinyXML document for ProRataConfig.XML
	TiXmlDocument txdConfigFile;

	// Try loading the file.
	if ( ! ( txdConfigFile.LoadFile( sFilename.c_str() ) ) )
	{
		cout << "ERROR! Loading Configuration file" << endl;
		return false;
	}

	string sData;
	istringstream issStream;
	double dValue;
	string sAtom = "X";
	sAtom[0] = cAtom;
	
	// creat the path to the MASS_DA element of the input sAtom
	vector<string> vsTagList;
	vsTagList.push_back( "CONFIG" );
	vsTagList.push_back( "SIC_EXTRACTION" );
	vsTagList.push_back( "ATOM_ISOTOPIC_COMPOSITION" );
	vsTagList.push_back( sAtom );
	vsTagList.push_back( "MASS_DA" );

	// get the text inside and extract the value
	sData = getValue( txdConfigFile, vsTagList );
	replaceDelimitor( sData, ',', '\t' );
	// clear end of file state 
	issStream.clear();
	// re-set the string associated with issStream
	issStream.str( sData );
	while( !( issStream.eof() ) )
	{
		issStream >> dValue;
		vdAtomicMass.push_back( dValue );
	}

	// move to the NATURAL element
	vsTagList.pop_back();
	vsTagList.push_back( "NATURAL" );
	sData = getValue( txdConfigFile, vsTagList );
	replaceDelimitor( sData, ',', '\t' );
	issStream.clear();
	issStream.str( sData );
	while( !( issStream.eof() ) )
	{
		issStream >> dValue;
		vdNaturalComposition.push_back( dValue );
	}
	
	// move to the ENRICHED element
	vsTagList.pop_back();
	vsTagList.push_back( "ENRICHED" );
	sData = getValue( txdConfigFile, vsTagList );
	replaceDelimitor( sData, ',', '\t' );
	issStream.clear();
	issStream.str( sData );
	while( !( issStream.eof() ) )
	{
		issStream >> dValue;
		vdEnrichedComposition.push_back( dValue );
	}

	return true;
}
Exemplo n.º 4
0
bool ProNovoConfig::getAtomIsotopicComposition( char cAtom,
		vector<double> & vdAtomicMass,
		vector<double> & vdComposition)
{

	// clear the input vectors
	vdAtomicMass.clear();
	vdComposition.clear();

	string sData;
	istringstream issStream;
	double dValue;
	string sAtom = "X";
	sAtom[0] = cAtom;

	map<string, string> mapElementMasses;
	if( ! getConfigMasterKeyValue("[Peptide_Identification]Element_Masses", mapElementMasses) )
	{
		cerr << "Error: cannot retrieve Element Masses." << endl;
		return false;
	}

	map<string, string> mapElementPercent;
	if( ! getConfigMasterKeyValue("[Peptide_Identification]Element_Percent", mapElementPercent) )
	{
		cerr << "Error: cannot retrieve Element Percent." << endl;
		return false;
	}

	map<string, string>::iterator iterMass = mapElementMasses.find(sAtom);
	if( iterMass == mapElementMasses.end() )
	{
		cerr << "Error: cannot find element masses for element " << sAtom << endl;
		return false;
	}
	sData = iterMass->second;
	replaceDelimitor( sData, ',', '\t' );
	// clear end of file state
	issStream.clear();
	// re-set the string associated with issStream
	issStream.str( sData );
	while( !( issStream.eof() ) )
	{
		issStream >> dValue;
		vdAtomicMass.push_back( dValue );
	}


	map<string, string>::iterator iterPercent = mapElementPercent.find(sAtom);
	if( iterPercent == mapElementPercent.end() )
	{
		cerr << "Error: cannot find element percent for element " << sAtom << endl;
		return false;
	}
	sData = iterPercent->second;
	replaceDelimitor( sData, ',', '\t' );
	// clear end of file state
	issStream.clear();
	// re-set the string associated with issStream
	issStream.str( sData );
	while( !( issStream.eof() ) )
	{
		issStream >> dValue;
		vdComposition.push_back( dValue );
	}

	return true;
}