void TestFileGenerator::WriteOutGenericDATDataFileNoGrid() { GenericDataHeader gdh; AddStandardGenericDataHeader(gdh); // Fill the DataGroupHeader DataGroupHeader dch; dch.SetName(L"First Data Cube"); // Fill the DataSetHeader DataSetHeader dph; dph.SetName(L"acquired data"); ParameterNameValueType nvt; nvt.SetName(L"Scanner"); nvt.SetValueText(L"M10"); dph.AddNameValParam(nvt); nvt.SetName(L"Pixel Size"); nvt.SetValueFloat(0.051f); dph.AddNameValParam(nvt); dph.AddColumn(UShortColumn(L"Pixel")); int32_t rows = 100; dph.SetRowCnt(rows); dch.AddDataSetHdr(dph); // Set the FileHeader FileHeader fh; fh.SetFilename("test.file.data_dat"); fh.SetGenericDataHdr(gdh); fh.AddDataGroupHdr(dch); // Create the generic file writer GenericFileWriter gfWriter(&fh); gfWriter.WriteHeader(); DataGroupWriterIt dcwBegin, dcwEnd; gfWriter.GetDataGroupWriters(dcwBegin, dcwEnd); DataGroupWriter d = *dcwBegin; dcwBegin->WriteHeader(); DataSetWriterIt dpwBegin, dpwEnd; dcwBegin->GetDataSetWriters(dpwBegin, dpwEnd); dpwBegin->WriteHeader(); // Write out the data for( int32_t i=0; i < rows; ++i ) { u_int16_t value = (u_int16_t)(i*10+i); dpwBegin->Write(value); } dpwBegin->UpdateNextDataSetOffset(); dcwBegin->Close(); }
void CHPData::SetEntryCount(int32_t ln, int32_t maxln, bool hasCompData) { maxProbeSetName = maxln; DataSetHeader dpHdr; dpHdr.SetRowCnt(ln); AddColumns(dpHdr, hasCompData); DataGroupHeader* dcHdr = &genericData.Header().GetDataGroup(0); dcHdr->AddDataSetHdr(dpHdr); }
void CHPQuantificationData::SetEntryCount(int32_t ln, int32_t maxln) { firstColumnType = ASCIICharColType; maxProbeSetName = maxln; ParameterNameValueType param; DataGroupHeader* dcHdr = &genericData.Header().GetDataGroup(0); DataSetHeader dpHdr; dpHdr.SetRowCnt(ln); dpHdr.SetName(QUANTIFICATION_QUANTIFICATION_NAME); AddColumns(dpHdr, false); dcHdr->AddDataSetHdr(dpHdr); }
void CHPData::SetOrigCnt(int32_t ln) { DataSetHeader dpHdr; dpHdr.SetRowCnt(ln); dpHdr.SetName(CHP_RESEQ_ORIG_CALL_GROUP); //position - int dpHdr.AddIntColumn(PositionColName); //call - byte dpHdr.AddByteColumn(OriginalCallColName); DataGroupHeader* dcHdr = &genericData.Header().GetDataGroup(3); dcHdr->AddDataSetHdr(dpHdr); }
void FileHeaderTest::FindDataGroupHeaderByNameTest() { // Create DataGroupHeaders DataGroupHeader d; d.SetName(L"Default"); header->AddDataGroupHdr(d); const DataGroupHeader* dch = header->FindDataGroupHeader(L"none"); CPPUNIT_ASSERT(0 == dch); dch = header->FindDataGroupHeader(L"default"); CPPUNIT_ASSERT(0 == dch); dch = header->FindDataGroupHeader(L"Default"); CPPUNIT_ASSERT(0 != dch); CPPUNIT_ASSERT(dch->GetName() == L"Default"); }
void CHPData::SetForceCnt(int32_t ln) { DataSetHeader dpHdr; dpHdr.SetRowCnt(ln); dpHdr.SetName(CHP_RESEQ_FORCE_CALL_GROUP); //position - int dpHdr.AddIntColumn(PositionColName); //call - byte dpHdr.AddByteColumn(ForceCallColName); //reason - byte dpHdr.AddByteColumn(ReasonColName); DataGroupHeader* dcHdr = &genericData.Header().GetDataGroup(2); dcHdr->AddDataSetHdr(dpHdr); }
/* * Reads the DataGroup name from the file. */ void DataGroupHeaderReader::ReadDataGroupName(std::ifstream& fileStream, DataGroupHeader& dch) { //DEBUG //u_int32_t z = fileStream.tellg(); dch.SetName(FileInput::ReadString16(fileStream)); }
/* * Reads the file position of the first DataSet in the DataGroup. */ void DataGroupHeaderReader::ReadFirstDataSetFilePos(std::ifstream& fileStream, DataGroupHeader& dch) { //DEBUG //u_int32_t z = fileStream.tellg(); dch.SetDataSetPos(FileInput::ReadUInt32(fileStream)); }
void CHPData::SetBackgroundZoneCnt(int32_t ln) { DataSetHeader dpHdr; dpHdr.SetRowCnt(ln); dpHdr.SetName(CHP_BG_ZONE_GROUP); //center X coord - float dpHdr.AddFloatColumn(CenterXColName); //center Y coord - float dpHdr.AddFloatColumn(CenterYColName); //background - float dpHdr.AddFloatColumn(BackgroundColName); //smoothing factor - float dpHdr.AddFloatColumn(SmoothFactorColName); DataGroupHeader* dcHdr = &genericData.Header().GetDataGroup(1); dcHdr->AddDataSetHdr(dpHdr); }
/* * Read the DataGroupHeader and all DataSetHeaders associated with this DataGroupHeader from the file. */ u_int32_t DataGroupHeaderReader::Read(std::ifstream& fileStream, DataGroupHeader& dch) { u_int32_t dataSetCnt = ReadHeader(fileStream, dch); // Read the DataSets DataSetHeaderReader dphReader; dphReader.ReadAll(fileStream, dch, dataSetCnt); return dch.GetNextGroupPos(); }
/* * Read the DataGroupHeader and all DataSetHeaders associated with this DataGroupHeader from the file. */ u_int32_t DataGroupHeaderReader::Read(std::ifstream& fileStream, DataGroupHeader& grpHdr) { ReadDataGroupStartFilePos(fileStream, grpHdr); u_int32_t dataSetCnt = ReadHeader(fileStream, grpHdr); // Read the DataSets DataSetHeaderReader dphReader; dphReader.ReadAll(fileStream, grpHdr, dataSetCnt); return grpHdr.GetNextGroupPos(); }
void CHPMultiDataData::SetEntryCount(MultiDataType dataType, int32_t ln, int32_t maxln, const std::vector<ColumnInfo> &columns, const std::wstring &groupName) { DataSetInfo info; info.maxName = maxln; info.metricColumns = columns; info.entries = NULL; info.dataType = dataType; info.dataSetIndex = (int)dataSetInfo.size(); dataSetInfo[dataType] = info; DataSetHeader dsHdr; dsHdr.SetRowCnt(ln); dsHdr.SetName(MultiDataDataSetNames[(int)dataType]); AddColumns(info, dsHdr); if (groupName.empty() == true) dataTypeGroupNames[dataType] = MULTI_DATA_NAME; else dataTypeGroupNames[dataType] = groupName; DataGroupHeader* dgHdr = GetDataGroupHeader(dataTypeGroupNames[dataType]); dgHdr->AddDataSetHdr(dsHdr); }
void CHPMultiDataData::SetEntryCount(MultiDataType dataType, int32_t ln, int segmentTypeMax, int referenceSegmentIDMax, int familialSegmentIDMax, const std::wstring &groupName) { DataSetInfo info; info.maxSegmentType = segmentTypeMax; info.maxReferenceSegmentID = referenceSegmentIDMax; info.maxFamilialSegmentID = familialSegmentIDMax; info.entries = NULL; info.dataType = dataType; info.dataSetIndex = (int)dataSetInfo.size(); dataSetInfo[dataType] = info; DataSetHeader dsHdr; dsHdr.SetRowCnt(ln); dsHdr.SetName(MultiDataDataSetNames[(int)dataType]); AddColumns(info, dsHdr); if (groupName.empty() == true) dataTypeGroupNames[dataType] = MULTI_DATA_NAME; else dataTypeGroupNames[dataType] = groupName; DataGroupHeader* dgHdr = GetDataGroupHeader(dataTypeGroupNames[dataType]); dgHdr->AddDataSetHdr(dsHdr); }
/* * Read the file position of the start of the DataSet. */ void DataGroupHeaderReader::ReadDataGroupStartFilePos(std::ifstream& fileStream, DataGroupHeader& grpHdr) { grpHdr.SetHeaderStartFilePos(fileStream.tellg()); }
int32_t CHPQuantificationData::GetEntryCount() { DataGroupHeader* dcHdr = &genericData.Header().GetDataGroup(0); DataSetHeader dpHdr = dcHdr->GetDataSet(0); return dpHdr.GetRowCnt(); }
void TestFileGenerator::WriteOutGenericDATDataFileWithGrid() { GenericDataHeader gdh; AddStandardGenericDataHeader(gdh); // Fill the DataGroupHeader DataGroupHeader dch; dch.SetName(L""); // unnamed DataGroup // Fill the pixel intensity DataSetHeader DataSetHeader dphPixel; dphPixel.SetName(L"acquired data"); ParameterNameValueType nvt; nvt.SetName(L"Scanner"); nvt.SetValueText(L"M10"); dphPixel.AddNameValParam(nvt); nvt.SetName(L"Pixel Size"); nvt.SetValueFloat(0.051f); dphPixel.AddNameValParam(nvt); dphPixel.AddColumn(UShortColumn(L"Pixel")); int32_t rows = 1000; dphPixel.SetRowCnt(rows); dch.AddDataSetHdr(dphPixel); // Fill the grid DataSetHeader DataSetHeader dphGrid; dphGrid.SetName(L"grid position"); nvt.SetName(L"GhostGrids"); nvt.SetValueText(L"True"); dphGrid.AddNameValParam(nvt); nvt.SetName(L"Pixel Size"); nvt.SetValueFloat(0.051f); dphGrid.AddNameValParam(nvt); dphGrid.AddColumn(FloatColumn(L"Upper left x")); dphGrid.AddColumn(FloatColumn(L"Upper left y")); dphGrid.AddColumn(FloatColumn(L"Upper right x")); dphGrid.AddColumn(FloatColumn(L"Upper right y")); dphGrid.AddColumn(FloatColumn(L"Lower right x")); dphGrid.AddColumn(FloatColumn(L"Lower right y")); dphGrid.AddColumn(FloatColumn(L"Lower left x")); dphGrid.AddColumn(FloatColumn(L"Lower left y")); int32_t grids = 5; // first is the global grid with 4 subgrids dphGrid.SetRowCnt(grids); dch.AddDataSetHdr(dphGrid); // Set the FileHeader FileHeader fh; fh.SetFilename("test.file.data_dat_with_grid"); fh.SetGenericDataHdr(gdh); fh.AddDataGroupHdr(dch); // Create the generic file writer GenericFileWriter gfWriter(&fh); gfWriter.WriteHeader(); DataGroupWriterIt dcwBegin, dcwEnd; gfWriter.GetDataGroupWriters(dcwBegin, dcwEnd); DataGroupWriter d = *dcwBegin; dcwBegin->WriteHeader(); DataSetWriterIt dpwBegin, dpwEnd; dcwBegin->GetDataSetWriters(dpwBegin, dpwEnd); // Write out the pixel DataSet dpwBegin->WriteHeader(); for( int32_t i=0; i < rows; ++i ) { u_int16_t value = (u_int16_t)(i*10+i); dpwBegin->Write(value); } dpwBegin->UpdateNextDataSetOffset(); ++dpwBegin; // Write out the grid DataSet dpwBegin->WriteHeader(); for( int32_t i=0; i < grids; ++i ) { for (int32_t corner = 0; corner < 4; ++corner) { float value = (float)(i*100 + corner); dpwBegin->Write(value); dpwBegin->Write(value); } } dpwBegin->UpdateNextDataSetOffset(); dcwBegin->Close(); }
int32_t CHPData::GetOrigCnt() { DataGroupHeader* dcHdr = &genericData.Header().GetDataGroup(3); DataSetHeader dpHdr = dcHdr->GetDataSet(0); return dpHdr.GetRowCnt(); }
void TestFileGenerator::WriteOutGenericDataFileWithAllColumnTypes() { GenericDataHeader gdh; AddStandardGenericDataHeader(gdh); // Fill the DataGroupHeader DataGroupHeader dch; dch.SetName(L"default"); // default DataGroup // Fill the all types DataSetHeader DataSetHeader dphAT; dphAT.SetName(L"all types"); ParameterNameValueType nvt; nvt.SetName(L"How many types"); nvt.SetValueText(L"All types"); dphAT.AddNameValParam(nvt); nvt.SetName(L"Powered by"); nvt.SetValueText(L"Affymetrix"); dphAT.AddNameValParam(nvt); dphAT.AddColumn(ByteColumn(L"Byte type")); dphAT.AddColumn(UByteColumn(L"UByte type")); dphAT.AddColumn(ASCIIColumn(L"ASCII type", 10)); dphAT.AddColumn(ShortColumn(L"Short type")); dphAT.AddColumn(UShortColumn(L"UShort type")); dphAT.AddColumn(IntColumn(L"Int type")); dphAT.AddColumn(UIntColumn(L"UInt type")); dphAT.AddColumn(UnicodeColumn(L"Unicode type", 15)); dphAT.AddColumn(FloatColumn(L"Float type")); int32_t rows = 2; dphAT.SetRowCnt(rows); dch.AddDataSetHdr(dphAT); // Set the FileHeader FileHeader fh; fh.SetFilename("test.file.data_all_column_types"); fh.SetGenericDataHdr(gdh); fh.AddDataGroupHdr(dch); // Create the generic file writer GenericFileWriter gfWriter(&fh); gfWriter.WriteHeader(); DataGroupWriterIt dcwBegin, dcwEnd; gfWriter.GetDataGroupWriters(dcwBegin, dcwEnd); DataGroupWriter d = *dcwBegin; dcwBegin->WriteHeader(); DataSetWriterIt dpwBegin, dpwEnd; dcwBegin->GetDataSetWriters(dpwBegin, dpwEnd); // Write out the all types DataSet dpwBegin->WriteHeader(); for( int32_t row = 0; row < rows; ++row ) { char str[10]; wchar_t wstr[15]; int8_t b = 1+10*row; u_int8_t ub = 2+10*row; sprintf(str, "%d", 3+10*row); int16_t s = 4+10*row; u_int16_t us = 5+10*row; int32_t i = 6+10*row; u_int32_t ui = 7+10*row; FormatString1(wstr, 15, L"%d", 8+10*row); float f = 9+10*row; dpwBegin->Write(b); // btye dpwBegin->Write(ub); // unsigned byte dpwBegin->Write(str, 10); // ACSII string dpwBegin->Write(s); // short dpwBegin->Write(us); // unsigned short dpwBegin->Write(i); // int dpwBegin->Write(ui); // unsigned int dpwBegin->Write(wstr, 15); // Unicode string dpwBegin->Write(f); // float } dpwBegin->UpdateNextDataSetOffset(); dcwBegin->Close(); }
int32_t CHPData::GetBackgroundZoneCnt() { DataGroupHeader* dcHdr = &genericData.Header().GetDataGroup(1); DataSetHeader dpHdr = dcHdr->GetDataSet(0); return dpHdr.GetRowCnt(); }