コード例 #1
0
ファイル: main.cpp プロジェクト: codereader/DarkRadiant
	unsigned int getSize()
	{
		unsigned int totalSize = 0;

		// Start with the size of the contents 
		// (don't use seek as we don't know if the client still wants to write stuff)
		totalSize += static_cast<unsigned int>(contents.size());

		if (!subChunks.empty())
		{
			// Sum up the size of the subchunks
			for (Chunk& chunk : subChunks)
			{
				totalSize += 4; // ID (4 bytes)
				totalSize += chunk.chunkSizeBytes; // Subchunk Size Info (can be 4 or 2 bytes)

				// While the child chunk size itself doesn't include padding, we need to respect
				// it when calculating the size of this parent chunk
				unsigned int childChunkSize = chunk.getSize();
				totalSize += childChunkSize + (childChunkSize % 2); // add 1 padding byte if odd
			}
		}
		else
		{
			totalSize += rawData.size();
		}

		return totalSize;
	}
コード例 #2
0
void MSDigestSearch::printProteinCoverage ( ostream& os, const CharVector& aaCovered ) const
{
	int protLen = aaCovered.size ();
	if ( protLen ) {
		int coverCount = 0;
		for ( int m = 0; m < protLen ; m++ ) {
			if ( aaCovered [m] > 0 ) coverCount++;
		}
		os << "The&nbsp;matched&nbsp;peptides&nbsp;cover&nbsp;<b>" << 100 * coverCount / protLen << "%</b>";
		os << "&nbsp;";
		os << "(" << coverCount << "/" << protLen << "&nbsp;AA's)&nbsp;of&nbsp;the&nbsp;protein.";
		os << "<p />";
	}
}
コード例 #3
0
void SQLiteAATable::insert ()
{
	v1 [3] = "";
	v1 [4] = "1";
	v1 [5] = "0";
	CharVector cv = AAInfo::getInfo ().getAminoAcids ();
	for ( StringVectorSizeType i = 0 ; i < cv.size () ; i++ ) {
		char c = cv [i];
		v1 [0] = AAInfo::getInfo ().getLongName ( c );

		v1 [1] = "one_letter_code";
		v1 [2] = string ( 1, c );
		insertTable ( tableName, n1, v1 );

		v1 [1] = "formula";
		v1 [2] = AAInfo::getInfo ().getElementalString ( c );
		insertTable ( tableName, n1, v1 );

		v1 [1] = "dw_substituent_a";
		string subA = AAInfo::getInfo ().getSubstituentA ( c );
		if ( subA != "0" ) {
			v1 [2] = subA;
			insertTable ( tableName, n1, v1 );
		}

		v1 [1] = "dw_substituent_b";
		string subB = AAInfo::getInfo ().getSubstituentB ( c );
		if ( subB != "0" ) {
			v1 [2] = subB;
			insertTable ( tableName, n1, v1 );
		}

		v1 [1] = "pk_c_term";
		string ctpk = AAInfo::convert_pk ( AAInfo::getInfo ().getCTermPK ( c ) );
		if ( ctpk != "n/a" ) {
			v1 [2] = ctpk;
			insertTable ( tableName, n1, v1 );
		}

		v1 [1] = "pk_n_term";
		string ntpk = AAInfo::convert_pk ( AAInfo::getInfo ().getNTermPK ( c ) );
		if ( ntpk != "n/a" ) {
			v1 [2] = ntpk;
			insertTable ( tableName, n1, v1 );
		}

		v1 [1] = "pk_acidic_sc";
		string ascpk = AAInfo::convert_pk ( AAInfo::getInfo ().getAcidicSCPK ( c ) );
		if ( ascpk != "n/a" ) {
			v1 [2] = ascpk;
			insertTable ( tableName, n1, v1 );
		}

		v1 [1] = "pk_basic_sc";
		string bscpk = AAInfo::convert_pk ( AAInfo::getInfo ().getBasicSCPK ( c ) );
		if ( bscpk != "n/a" ) {
			v1 [2] =  bscpk;
			insertTable ( tableName, n1, v1 );
		}
	}
}
コード例 #4
0
ファイル: main.cpp プロジェクト: codereader/DarkRadiant
void parseFromStream(CharVector& buffer, int level, Chunk& parsedChunk)
{
	VectorBuffer<char> tempBuf(buffer);
	std::istream stream(&tempBuf);

	if (parsedChunk.id == "SURF")
	{
		std::string surfName = parseString0(stream);
		std::string parentName = parseString0(stream);

		addStringToContents(parsedChunk.contents, surfName);
		addStringToContents(parsedChunk.contents, parentName);
	}

	if (parsedChunk.id == "IMAP")
	{
		std::string ordinal = parseString0(stream);
		addStringToContents(parsedChunk.contents, ordinal);
	}

	while (!stream.eof())
	{
		// Read header
		Chunk chunk;

		char id[5];
		stream.read(id, 4);
		id[4] = '\0';

		chunk.id = id;

		if (stream.eof()) break;

		if (parsedChunk.id == "SURF" || parsedChunk.id == "BLOK" ||
			parsedChunk.id == "IMAP" || parsedChunk.id == "TMAP")
		{
			uint16_t size;
			stream.read((char*)&size, 2);
			size = reverse(size);
			chunk.size = size;
			chunk.chunkSizeBytes = 2;
		}
		else
		{
			uint32_t size;
			stream.read((char*)&size, 4);
			size = reverse(size);
			chunk.size = size;
			chunk.chunkSizeBytes = 4;
		}

		assert(!stream.fail());

		//std::string indent(level * 2, ' ');
		//std::cout << indent << id << " with size " << chunk.size << " bytes" << std::endl;

		// Check size restrictions
		assert(4 + chunk.chunkSizeBytes + chunk.size <= buffer.size());

		uint32_t dataSize = chunk.size;

		if (chunk.id == "FORM")
		{
			// LWO doesn't have the correct size?
			if (dataSize + 4 + 4 != buffer.size())
			{
				std::cout << "ERROR: FORM Size Value + 8 Bytes is not the same as the file size." << std::endl;
				assert(false);
			}

			// Read the LWO2 tag
			char lwo2[5];
			stream.read(lwo2, 4);
			lwo2[4] = '\0';

			assert(std::string(lwo2) == "LWO2");

			chunk.contents.push_back('L');
			chunk.contents.push_back('W');
			chunk.contents.push_back('O');
			chunk.contents.push_back('2');

			dataSize -= 4;
		}

		assert(!stream.fail());

		chunk.rawData.resize(dataSize);
		stream.read(&chunk.rawData.front(), dataSize);

#if 0
		if (chunk.id == "COLR")
		{
			uint32_t colr1Raw = *((uint32_t*)&chunk.rawData[0]);
			colr1Raw = reverse(colr1Raw);
			float colr1 = *((float*)&colr1Raw);
			std::cout << colr1;
		}
#endif

		assert(!stream.fail());

		// Fill bit if size is odd
		if (dataSize % 2 == 1)
		{
			char temp;
			stream.read(&temp, 1);
			assert(temp == '\0');
			assert(!stream.fail());
		}

		parsedChunk.subChunks.push_back(chunk);
	}

	// Try to parse the subchunks
	for (Chunk& chunk : parsedChunk.subChunks)
	{
		if (chunk.id == "FORM" || chunk.id == "SURF" || chunk.id == "BLOK" ||
			chunk.id == "IMAP" || chunk.id == "TMAP")
		{
			parseFromStream(chunk.rawData, level + 1, chunk);
		}
	}
}
コード例 #5
0
ファイル: midi_vector.hpp プロジェクト: 0rel/sequencer64
 virtual std::size_t size () const
 {
     return m_char_vector.size();
 }