Beispiel #1
0
void CHPQuantificationFileBufferWriter::FlushBuffer()
{
	if(m_BufferSize > 0) {
		for (int target=0; target<m_CHPFileNames->size(); target++)
		{
			CalvinCHPFileUpdater updater;
			updater.OpenCHPFile((*m_CHPFileNames)[target].c_str());
			updater.UpdateExpressionQuantificationBuffer(m_TargetQuantificationRowIndexes[target], m_TargetQuantificationBuffers[target]);
			updater.CloseCHPFile();
			m_TargetQuantificationRowIndexes[target] += m_TargetQuantificationBuffers[target].size();
			m_TargetQuantificationBuffers[target].clear();
		}
	}
	m_BufferSize = 0;
}
void CHPMultiDataFileBufferWriter::FlushBuffer()
{
	if(m_BufferSize > 0)
	{
		MultiDataType segmentTypes[] = {
			SegmentCNMultiDataType,
			SegmentLOHMultiDataType,
			SegmentCNNeutralLOHMultiDataType,
			SegmentNormalDiploidMultiDataType,
			SegmentMosaicismMultiDataType,
			SegmentNoCallMultiDataType,
			SegmentGenotypeConcordanceMultiDataType,
			SegmentGenotypeDiscordanceMultiDataType,
			SegmentCNLossLOHConcordanceMultiDataType,
			SegmentCNNeutralLOHConcordanceMultiDataType,
			SegmentHeteroUPDMultiDataType,
			SegmentIsoUPDMultiDataType,
			SegmentDenovoCopyNumberMultiDataType,
			SegmentHemizygousParentOfOriginMultiDataType
		};
		int nSegmentTypes = sizeof(segmentTypes) / sizeof(MultiDataType);

		for (int target = 0; target < (int)chpFileNames->size(); target++)
		{
			CalvinCHPFileUpdater updater;
			updater.OpenCHPFile((*chpFileNames)[target].c_str());
            MultiDataType dataType;

            dataType = GenotypeMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateMultiDataGenotypeEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = CopyNumberMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateMultiDataCopyNumberEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = CytoMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateMultiDataCytoRegionEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = ExpressionMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateMultiDataExpressionEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = CopyNumberVariationMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateMultiDataCopyNumberVariationRegionEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = DmetBiAllelicMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateDmetBiAllelicEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = DmetMultiAllelicMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateDmetMultiAllelicEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = DmetCopyNumberMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateDmetCopyNumberEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = ChromosomeSummaryMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateChromosomeSummaryEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

			dataType = CytoGenotypeCallMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateMultiDataCytoGenotypeEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

			for (int iseg=0; iseg<nSegmentTypes; iseg++)
			{
				dataType = segmentTypes[iseg];
				if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
				{
					updater.UpdateChromosomeSegmentEntryBuffer(dataType,
						rowIndexes[dataType][target],
						dataBufferSz[dataType],
						dataBuffers[dataType][target]);
					rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
					ClearBuffer(dataBuffers[dataType][target]);
				}
			}

            dataType = FamilialSegmentOverlapsMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
                updater.UpdateFamilialSegmentOverlapEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = FamilialSamplesMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
                updater.UpdateFamilialSampleEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = AllelePeaksMultiDataType;
			if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateMultiDataAllelePeaksEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

            dataType = MarkerABSignalsMultiDataType;
				if (dataBuffers.find(dataType) != dataBuffers.end() && dataBuffers[dataType][target].size() > 0)
			{
				updater.UpdateMultiDataMarkerABSignalsEntryBuffer(dataType,
                    rowIndexes[dataType][target],
                    dataBufferSz[dataType],
                    dataBuffers[dataType][target]);
				rowIndexes[dataType][target] += (int) dataBuffers[dataType][target].size();
                ClearBuffer(dataBuffers[dataType][target]);
			}

			updater.CloseCHPFile();
		}
	}
	m_BufferSize = 0;
}