Exemple #1
0
void addStringToContents(CharVector& contents, const std::string& str)
{
	std::size_t bytesWritten = 0;

	for (std::size_t i = 0; i < str.length(); ++i)
	{
		contents.push_back(str[i]);
		++bytesWritten;
	}

	contents.push_back('\0');
	++bytesWritten;

	if (bytesWritten % 2 == 1)
	{
		contents.push_back('\0');
		++bytesWritten;
	}
}
void init_fasta_enzyme_function ( const string& enzyme )
{
	static bool called = false;
	if ( called ) return;
	called = true;
	static DigestTable& digestTable = DigestTable::instance ();

	if ( enzyme == "No enzyme" ) {
		ErrorHandler::genError ()->error ( "No enzyme not valid option for this program." );
		return;
	}
	StringVector enzymeNameTable;
	cnbr_digest = false;
	StringSizeType start = 0;
	StringSizeType end = 0;
	for ( ; ; ) {
		end = enzyme.find_first_of ( "/", start );
		string enzymeName = enzyme.substr ( start, end-start );
		if ( enzymeName == "CNBr" ) cnbr_digest = true;
		enzymeNameTable.push_back ( enzymeName );
		if ( end == string::npos ) break;
		start = end + 1;
	}
	numDigests = enzymeNameTable.size ();

	for ( int i = 0 ; i < numDigests ; i++ ) {
		string br_aas = digestTable.getBreakMask (enzymeNameTable[i]);
		break_aas_array.push_back ( br_aas );
		break_mask_array.push_back ( string_to_mask ( br_aas ) );

		string exclude_aas = digestTable.getExcludeMask (enzymeNameTable[i]);
		exclude_aas_array.push_back ( exclude_aas );
		if ( exclude_aas != "-" ) exclude_mask_array.push_back ( string_to_mask ( exclude_aas ) );
		else exclude_mask_array.push_back ( 0 );

		digestSpecificityArray.push_back ( digestTable.getSpecificity (enzymeNameTable[i]) );
	}	
	if ( numDigests == 1 ) {
		break_mask = break_mask_array [0];
		break_aas = break_aas_array [0];
		exclude_mask = exclude_mask_array [0];
		digestSpecificity = digestSpecificityArray [0];
		if ( digestSpecificity == 'C' ) enzyme_fragmenter = calc_fasta_c_term_fragments;
		else enzyme_fragmenter = calc_fasta_n_term_fragments;
	}
	else {
		int i;
		for ( i = 1 ; i < numDigests ; i++ ) {
			if ( digestSpecificityArray [i] != digestSpecificityArray [0] ) break;
		}
		if ( i == numDigests ) digestSpecificity = digestSpecificityArray [0];	/* All digest specificities must be the same for digestSpecificity to be set */

		enzyme_fragmenter = calc_fasta_multi_digest_fragments;
	}
}
Exemple #3
0
 virtual void put (midibyte b)
 {
     m_char_vector.push_back(b);
 }