void CHPQuantificationDataTest::test_AlgParams() { ParameterNameValueTypeList params; ParameterNameValueType param; CHPQuantificationData data; param.SetName(L"n1"); param.SetValueText(L"v1"); params.push_back(param); param.SetName(L"n2"); param.SetValueText(L"v2"); params.push_back(param); data.AddAlgParams(params); ParameterNameValueTypeList params_out = data.GetAlgParams(); CPPUNIT_ASSERT(params_out.size() == 2); ParameterNameValueTypeList::iterator it = params_out.begin(); param = *it; CPPUNIT_ASSERT(param.GetName() == L"n1"); CPPUNIT_ASSERT(param.GetValueText() == L"v1"); ++it; param = *it; CPPUNIT_ASSERT(param.GetName() == L"n2"); CPPUNIT_ASSERT(param.GetValueText() == L"v2"); }
void TestFileGenerator::AddStandardGenericDataHeader(GenericDataHeader& gdh) { // Fill the GenericDataHeader. gdh.SetFileTypeId(SCAN_ACQUISITION_DATA_TYPE); gdh.SetFileId("test-dat-guid"); gdh.SetFileCreationTime(L"2004-07-04T11:12:13Z"); gdh.SetLocale(L"en-US"); ParameterNameValueType nvt; nvt.SetName(ARRAY_TYPE_PARAM_NAME); nvt.SetValueText(L"Hg-U133A"); gdh.AddNameValParam(nvt); nvt.SetName(ARRAY_BARCODE_PARAM_NAME); nvt.SetValueText(L"Barcode"); gdh.AddNameValParam(nvt); nvt.SetName(L"Parameter1"); nvt.SetValueText(L"Value1"); gdh.AddNameValParam(nvt); GenericDataHeader gdhParent; gdhParent.SetFileTypeId(ARRAY_TYPE_IDENTIFIER); gdhParent.SetFileId("test-array-guid"); gdhParent.SetFileCreationTime(L"2004-07-01T13:14:15Z"); gdhParent.SetLocale(L"en-US"); nvt.SetName(ARRAY_TYPE_PARAM_NAME); nvt.SetValueText(L"Hg-U133A"); gdhParent.AddNameValParam(nvt); nvt.SetName(ARRAY_LOT_PARAM_NAME); nvt.SetValueText(L"Thanks alot"); gdhParent.AddNameValParam(nvt); gdh.AddParent(gdhParent); }
void CHPMultiDataDataTest::test_SumParams() { ParameterNameValueTypeList params; ParameterNameValueType param; CHPMultiDataData data; param.SetName(L"n1"); param.SetValueText(L"v1"); params.push_back(param); param.SetName(L"n2"); param.SetValueText(L"v2"); params.push_back(param); data.AddSummaryParams(params); ParameterNameValueTypeList params_out = data.GetSummaryParams(); CPPUNIT_ASSERT(params_out.size() == 2); ParameterNameValueTypeList::iterator it = params_out.begin(); param = *it; CPPUNIT_ASSERT(param.GetName() == L"n1"); CPPUNIT_ASSERT(param.GetValueText() == L"v1"); ++it; param = *it; CPPUNIT_ASSERT(param.GetName() == L"n2"); CPPUNIT_ASSERT(param.GetValueText() == L"v2"); }
/* * Save the program information to the AGCC file. */ void MAS5CHPUtils::StoreProgramInfo() { ParameterNameValueType p; p.SetName(PROGRAM_NAME); p.SetValueText(programName); cc_data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(p); p.SetName(PROGRAM_ID); p.SetValueText(programId); cc_data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(p); p.SetName(PROGRAM_COMPANY); p.SetValueText(programCompany); cc_data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(p); }
void DataGroupHeaderTest::FindDataSetHeaderTest() { // Create DataSetHeaders DataSetHeader dph1; dph1.SetName(L"pixel intensity"); ParameterNameValueType param; param.SetName(L"Scanner"); param.SetValueText(L"M10"); dph1.AddNameValParam(param); dph1.AddUShortColumn(L""); dph1.SetRowCnt(1); DataSetHeader dph2; dph2.SetName(L"grid coordinates"); param.SetName(L"Corner Pattern"); param.SetValueText(L"Checkerboard"); dph2.AddNameValParam(param); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.AddUShortColumn(L""); dph2.SetRowCnt(1); header->AddDataSetHdr(dph1); header->AddDataSetHdr(dph2); const DataSetHeader* dph = header->FindDataSetHeader(L"none"); CPPUNIT_ASSERT(0 == dph); dph = header->FindDataSetHeader(dph1.GetName()); CPPUNIT_ASSERT(0 != dph); CPPUNIT_ASSERT(dph->GetName() == dph1.GetName()); dph = header->FindDataSetHeader(dph2.GetName()); CPPUNIT_ASSERT(0 != dph); CPPUNIT_ASSERT(dph->GetName() == dph2.GetName()); }
void TestFileGenerator::WriteSmallCelFileWithAPartialDatHeaderTest() { CelFileData data("small_cel_file_partial_datheader"); // Write ParameterNameValueType nvt; GenericDataHeader datHdr; datHdr.SetFileId(AffymetrixGuid::GenerateNewGuid()); datHdr.SetFileTypeId("affymetrix-calvin-scan-acquisition"); datHdr.SetFileCreationTime(L"2004-07-01T13:14:15Z"); nvt.SetName(L"affymetrix-partial-dat-header"); std::wstring datHeaderString = L" small_cel_file_partial_datheader:CLS=25 RWS=25 XIN=1 YIN=1 VE=0 0 05/19/05 02:45:59 ScannerID: ScannerTyp \x14 \x14 Hg-Small.1sq \x14 \x14 \x14 \x14 \x14 570 \x14 45.200001 \x14 0.340000 \x14 1.0900 \x14 3"; nvt.SetValueText(datHeaderString); datHdr.AddNameValParam(nvt); nvt.SetName(L"affymetrix-max-pixel-intensity"); nvt.SetValueUInt16(46001); datHdr.AddNameValParam(nvt); nvt.SetName(L"affymetrix-min-pixel-intensity"); nvt.SetValueUInt16(1); datHdr.AddNameValParam(nvt); // Add DAT GenericDataHeader as parent. data.GetFileHeader()->GetGenericDataHdr()->AddParent(datHdr); WriteRemaingSmallCelFileWithGridParameters(data); }
void CHPQuantificationData::SetWStringToGenericHdr(const std::wstring& name, const std::wstring value, int32_t reserve) { ParameterNameValueType paramType; paramType.SetName(name); paramType.SetValueText(value, reserve); GenericDataHeader* hdr = genericData.Header().GetGenericDataHdr(); hdr->AddNameValParam(paramType); }
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(); }
bool DataSetHeader::FindNameValParam(const std::wstring& name, ParameterNameValueType& result) const { ParameterNameValueType t; t.SetName(name); t.SetValueText(L""); ParameterNameValueTypeConstIt found = FindNameValParam(t); if (found != nameValParams.end()) { result = *found; return true; } return false; }
void TestFileGenerator::WriteSmallDatFileWithReservedStringParameters() { int32_t rows = 4; int32_t cols = 5; int32_t pixelCount = rows*cols; DATData data("small_dat_file_with_reserved_string_parameters"); data.SetPixelCount(pixelCount); data.SetStatsCount(1); data.SetArrayType(L"Hg_small"); data.SetPixelSize(0.71f); data.SetScannerType(L"M10"); data.SetScannerID(L"main"); DateTime dt = DateTime::Parse(L"2005-12-25T11:12:13Z"); data.SetScanDate(dt); data.SetRows(rows); data.SetCols(cols); std::string arrayId = "smellsliketeenspirit"; data.SetArrayId(arrayId); ParameterNameValueType nvt; nvt.SetName(L"fixedlen"); nvt.SetValueText(L"twenty-five", 25); data.GetFileHeader()->GetGenericDataHdr()->AddNameValParam(nvt); DATFileWriter writer(data); Uint16Vector pixels; pixels.reserve(pixelCount); u_int16_t inten = 10; for (int32_t i=0; i<pixelCount; ++i, ++inten) { if (inten > 46000) { inten = 0; } pixels.push_back(inten); } Uint16Vector stats; stats.push_back(pixels[0]); // min stats.push_back(pixels[19]); // max writer.WriteStats(stats); writer.WritePixels(pixels); }
void TestFileGenerator::WriteSmallDatFileWithGridAndSubgridsAndParameters() { std::string filename = "small_DAT_file_with_subgrids_and_parameters"; WriteDatFile(filename, L"Hg-small", 4, 5, true); DATData data(filename); AddGridAndSubgrids(data, 2.5, 10); ParameterNameValueType nvt; nvt.SetName(L"Zip Code"); nvt.SetValueInt32(95051); data.AddGridAlignmentAlgorithmParameter(nvt); nvt.SetName(L"County"); nvt.SetValueText(L"Santa Clara"); data.AddGridAlignmentAlgorithmParameter(nvt); DATFileUpdater update(data); update.Update(); }
void TestFileGenerator::WriteSmallCelFileWithAFullDatHeaderTest() // Files converted from GCOS will have a full DatHeader { CelFileData data("small_cel_file_full_datheader"); // Write ParameterNameValueType nvt; GenericDataHeader datHdr; datHdr.SetFileId(AffymetrixGuid::GenerateNewGuid()); datHdr.SetFileTypeId("affymetrix-calvin-scan-acquisition"); datHdr.SetFileCreationTime(L"2004-07-01T13:14:15Z"); nvt.SetName(L"affymetrix-dat-header"); std::wstring datHeaderString = L"[45..56789] small_cel_file_full_datheader:CLS=25 RWS=25 XIN=1 YIN=1 VE=0 0 05/19/05 02:45:59 ScannerID: ScannerTyp \x14 \x14 Hg-Small.1sq \x14 \x14 \x14 \x14 \x14 570 \x14 45.200001 \x14 0.340000 \x14 1.0900 \x14 3"; nvt.SetValueText(datHeaderString); datHdr.AddNameValParam(nvt); // Add DAT GenericDataHeader as parent. data.GetFileHeader()->GetGenericDataHdr()->AddParent(datHdr); WriteRemaingSmallCelFileWithGridParameters(data); }
/** * Get set up for a run of reporting probesets. Often used to open file * streams and print headers to files etc. * * @param qMethod - Quantification method to be used. * @param layout - Where the probesets, probes, etc are on the chip. * * @return true if success, false otherwise. */ bool QuantMethodExprCCCHPReport::prepare(QuantMethod &qMethod, const IntensityMart &iMart) { QuantExprMethod *eMethod = dynamic_cast<QuantExprMethod *>(&qMethod); if (eMethod == NULL) { Err::errAbort("Can only use a QuantMethodExprReport with a QuantExprMethod."); } setupFileNames(iMart); int nfiles = m_CHPFileNames.size(); // Make sure our output directory exists. if (!Fs::isWriteableDir(m_Prefix.c_str()) && (Fs::mkdirPath(m_Prefix, false) != APT_OK)) { APT_ERR_ABORT("Can't make or write to directory: " + m_Prefix); } removeAllChps(); // Get CEL file GUIDs ///@todo This be computed by the engine and passed in via AnalysisInfo m_celGuids.resize(nfiles); std::string tmp_unc_name; for (int chip=0; chip<nfiles; chip++) { FusionCELData cel; try { tmp_unc_name=Fs::convertToUncPath(m_CELFileNames[chip]); cel.SetFileName(tmp_unc_name.c_str()); if (!cel.ReadHeader()) { Err::errAbort("Unable to read CEL file: "+FS_QUOTE_PATH(tmp_unc_name)); } GenericData *gdata = cel.GetGenericData(); if (gdata != NULL) { m_celGuids[chip] = gdata->Header().GetGenericDataHdr()->GetFileId(); } cel.Close(); } catch (...) { Err::errAbort("Unable to read CEL file " + tmp_unc_name); } } int maxProbeSetNameLength = 0; for (int i=0; i<m_Info.m_ProbesetNames.size(); i++) { int len = (int)strlen(m_Info.m_ProbesetNames.at(i)); if (m_Info.m_ProbesetDisplayNames.size() > 0 && m_Info.m_ProbesetDisplayNames.at(i) != NULL) len = (int)strlen(m_Info.m_ProbesetDisplayNames.at(i)); maxProbeSetNameLength = Max(maxProbeSetNameLength, len); } // Prepare headers for all CHP files. wstring algName = StringUtils::ConvertMBSToWCS(m_Info.m_AlgName); wstring algVersion = StringUtils::ConvertMBSToWCS(m_Info.m_AlgVersion); wstring chipType = StringUtils::ConvertMBSToWCS(m_Info.m_ChipType); // For each chip, precreate all probeset signal entries (default to 0.0). Verbose::out(1,"QuantMethodExprCCCHPReport: Creating temporary files for CHP output"); for (int chip=0; chip<nfiles; chip++) { try { ParameterNameValueType param; // Create tmp chp file std::string tmp_chp_name=m_CHPFileNames[chip] + ".tmp"; CHPQuantificationData *data = new CHPQuantificationData(tmp_chp_name); m_TmpChpFiles.push_back(tmp_chp_name); // set parent header FusionCELData cel; try { tmp_unc_name=Fs::convertToUncPath(m_CELFileNames[chip]); cel.SetFileName(tmp_unc_name.c_str()); if (!cel.ReadHeader()) { Err::errAbort("Unable to read CEL file: "+FS_QUOTE_PATH(tmp_unc_name)); } GenericData *gdata = cel.GetGenericData(); if (gdata != NULL) { data->GetFileHeader()->GetGenericDataHdr()->AddParent(*gdata->Header().GetGenericDataHdr()); } cel.Close(); } catch (...) { Err::errAbort("Unable to read CEL file: "+FS_QUOTE_PATH(tmp_unc_name)); } data->SetEntryCount(m_Info.m_NumProbeSets, maxProbeSetNameLength); data->SetAlgName(algName); data->SetAlgVersion(algVersion); data->SetArrayType(chipType); param.SetName(L"program-name"); param.SetValueText(StringUtils::ConvertMBSToWCS(m_Info.m_ProgramName)); data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param); param.SetName(L"program-version"); param.SetValueText(StringUtils::ConvertMBSToWCS(m_Info.m_ProgramVersion)); data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param); param.SetName(L"program-company"); param.SetValueText(StringUtils::ConvertMBSToWCS(m_Info.m_ProgramCompany)); data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param); // Add algorithm parameters to list. ParameterNameValueTypeList paramList; assert(m_Info.m_ParamNames.size() == m_Info.m_ParamValues.size()); for (int i=0; i<m_Info.m_ParamNames.size(); i++) { if (m_Info.m_ParamValues[i].length() > 0) { param.SetName(StringUtils::ConvertMBSToWCS(m_Info.m_ParamNames[i])); param.SetValueText(StringUtils::ConvertMBSToWCS(m_Info.m_ParamValues[i])); paramList.push_back(param); } } // Add list of all CEL GUIDs in batch ///@todo should this be computed by the engine and passed in via AnalysisInfo? string prefix = "apt-opt-"; for (int chip=0; chip<m_CHPFileNames.size(); chip++) { if (m_celGuids[chip].empty() == false) { string paramName = prefix + "cel-guid-" + ToStr(chip+1); param.SetName(StringUtils::ConvertMBSToWCS(paramName)); param.SetValueText(StringUtils::ConvertMBSToWCS(m_celGuids[chip])); paramList.push_back(param); } } data->AddAlgParams(paramList); // Add the run report parameters to the list ParameterNameValueTypeList summaryParamList; std::string blankStr(256, ' '); for (int source=0; source<m_ChipSummaries.size(); source++) { ChipSummary::metricDefVec_t metricDefs = m_ChipSummaries[source]->getMetricDefs(); for (int i = 0; i < metricDefs.size(); i++) { param.SetName(StringUtils::ConvertMBSToWCS(metricDefs[i].m_name)); if (metricDefs[i].m_type == ChipSummary::Metric::Double) { param.SetValueFloat(-1.0); } else if (metricDefs[i].m_type == ChipSummary::Metric::Integer) { param.SetValueInt32(-1); } else if (metricDefs[i].m_type == ChipSummary::Metric::String) { param.SetValueAscii(blankStr); } else { Err::errAbort("QuantMethodExprCCCHPReport: Unable to handle unknown type: " + ToStr(metricDefs[i].m_type) ); } summaryParamList.push_back(param); } } data->AddSummaryParams(summaryParamList); ProbeSetQuantificationData entry; CHPQuantificationFileWriter writer(*data); writer.SeekToDataSet(); // seek to data table location for (int index=0; index<m_Info.m_ProbesetNames.size(); index++) { if (m_Info.m_ProbesetDisplayNames.size() > 0 && m_Info.m_ProbesetDisplayNames[index] != NULL) entry.name = m_Info.m_ProbesetDisplayNames[index]; else entry.name = m_Info.m_ProbesetNames[index]; entry.quantification = 0.0f; writer.WriteEntry(entry); } delete data; } catch (...) { Err::errAbort("QuantMethodExprCHPReport::prepare() - Unable to write header and/or precreate signal entries to file: " + m_CHPFileNames[chip] + ".tmp"); } } // initialize expression signal buffer writer m_ExpressionQuantificationBufferWriter.Initialize(&m_TmpChpFiles); return true; }
void CalvinCHPMultiDataFileUpdaterTest::CreateReferenceFile2() { CHPMultiDataData data(TEST2_FILE); vector<ColumnInfo> cols; ParameterNameValueType nv; ByteColumn bcol(L"byte"); cols.push_back(bcol); UByteColumn ubcol(L"ubyte"); cols.push_back(ubcol); ShortColumn scol(L"short"); cols.push_back(scol); UShortColumn uscol(L"ushort"); cols.push_back(uscol); IntColumn icol(L"int"); cols.push_back(icol); UIntColumn uicol(L"uint"); cols.push_back(uicol); FloatColumn fcol(L"float"); cols.push_back(fcol); ASCIIColumn acol(L"ascii", 7); cols.push_back(acol); UnicodeColumn tcol(L"text", 10); cols.push_back(tcol); ProbeSetMultiDataGenotypeData e; data.SetEntryCount(GenotypeMultiDataType, 4, 10, cols); CHPMultiDataFileWriter *writer = new CHPMultiDataFileWriter(data); nv.SetName(L"byte"); nv.SetValueInt8(8); e.metrics.push_back(nv); nv.SetName(L"ubyte"); nv.SetValueUInt8(8); e.metrics.push_back(nv); nv.SetName(L"short"); nv.SetValueInt16(16); e.metrics.push_back(nv); nv.SetName(L"ushort"); nv.SetValueUInt16(16); e.metrics.push_back(nv); nv.SetName(L"int"); nv.SetValueInt32(32); e.metrics.push_back(nv); nv.SetName(L"uint"); nv.SetValueUInt32(32); e.metrics.push_back(nv); nv.SetName(L"float"); nv.SetValueFloat(44.0f); e.metrics.push_back(nv); nv.SetName(L"ascii"); nv.SetValueAscii("ascii"); e.metrics.push_back(nv); nv.SetName(L"text"); nv.SetValueText(L"text"); e.metrics.push_back(nv); writer->SeekToDataSet(GenotypeMultiDataType); e.name = "1"; e.call = 1; e.confidence = 10.0f; writer->WriteEntry(e); e.name = "2"; e.call = 2; e.confidence = 20.0f; writer->WriteEntry(e); e.name = "3"; e.call = 3; e.confidence = 30.0f; writer->WriteEntry(e); e.name = "4"; e.call = 4; e.confidence = 40.0f; writer->WriteEntry(e); delete writer; }
void CalvinCHPMultiDataFileUpdaterTest::CreateReferenceFile3() { CHPMultiDataData data(TEST3_FILE); vector<ColumnInfo> cols; ParameterNameValueType nv; ByteColumn bcol(L"byte"); cols.push_back(bcol); UByteColumn ubcol(L"ubyte"); cols.push_back(ubcol); ShortColumn scol(L"short"); cols.push_back(scol); UShortColumn uscol(L"ushort"); cols.push_back(uscol); IntColumn icol(L"int"); cols.push_back(icol); UIntColumn uicol(L"uint"); cols.push_back(uicol); FloatColumn fcol(L"float"); cols.push_back(fcol); ASCIIColumn acol(L"ascii", 7); cols.push_back(acol); UnicodeColumn tcol(L"text", 10); cols.push_back(tcol); ProbeSetMultiDataCopyNumberData e; ProbeSetMultiDataCytoRegionData c; data.SetEntryCount(CopyNumberMultiDataType, 4, 10, cols); data.SetEntryCount(CytoMultiDataType, 2, 10); CHPMultiDataFileWriter *writer = new CHPMultiDataFileWriter(data); nv.SetName(L"byte"); nv.SetValueInt8(8); e.metrics.push_back(nv); nv.SetName(L"ubyte"); nv.SetValueUInt8(8); e.metrics.push_back(nv); nv.SetName(L"short"); nv.SetValueInt16(16); e.metrics.push_back(nv); nv.SetName(L"ushort"); nv.SetValueUInt16(16); e.metrics.push_back(nv); nv.SetName(L"int"); nv.SetValueInt32(32); e.metrics.push_back(nv); nv.SetName(L"uint"); nv.SetValueUInt32(32); e.metrics.push_back(nv); nv.SetName(L"float"); nv.SetValueFloat(44.0f); e.metrics.push_back(nv); nv.SetName(L"ascii"); nv.SetValueAscii("ascii"); e.metrics.push_back(nv); nv.SetName(L"text"); nv.SetValueText(L"text"); e.metrics.push_back(nv); writer->SeekToDataSet(CopyNumberMultiDataType); e.name = "1"; e.chr = 1; e.position = 10; writer->WriteEntry(e); e.name = "2"; e.chr = 2; e.position = 20; writer->WriteEntry(e); e.name = "3"; e.chr = 3; e.position = 30; writer->WriteEntry(e); e.name = "4"; e.chr = 4; e.position = 40; writer->WriteEntry(e); writer->SeekToDataSet(CytoMultiDataType); c.name = "1"; c.chr= 1; c.startPosition = 1; c.stopPosition = 2; c.call = 1; c.confidenceScore = 10.0f; writer->WriteEntry(c); c.name = "2"; c.chr= 2; c.startPosition = 2; c.stopPosition = 3; c.call = 2; c.confidenceScore = 20.0f; writer->WriteEntry(c); delete writer; }
/*! Create a "quantification" CHP file with just the header information. The remainder of the file * will be created at a later time using the buffer writer technique. * The CHP file will contain only "quantification" results from an expression analysis. * @param execId The execution identifier. This identifier is used to identify the batch run that created the CHP files. * @param celFile The full path to the parent CEL file. The header of the CEL file is copied to the CHP file. * @param outFile The name of the output CHP file. * @param probeSetNames The probe set names. * @param algName The name of the algorithm used to create the results. * @param algVersion The algorithm version. * @param chipType the chip type, also known as the probe array type. * @param programName The name of the program used to create the CHP file. * @param programVersion The version of the program. * @param programCompany The company or institution who developed the CHP creating software. * @param paramNames A list of parameter names to store in the CHP file header. * @param paramValues A list of parameter values to store in the CHP file header. * @param sumNames A list of summary statistic names to store in the CHP file header. * @param sumValues A list of summary statistic values to store in the CHP file header. */ static void CreateFileWithHeader ( const string &execId, const string &celFile, const string &outFile, const list<string> &probeSetNames, const string &algName, const string &algVersion, const string &chipType, const string &programName, const string &programVersion, const string &programCompany, const vector<string>& paramNames, const vector<string>& paramValues, const vector<string>& sumNames, const vector<string>& sumValues ) { // Determine the max probe set name. int numEntries = (int) probeSetNames.size(); int maxProbeSetNameLength = 0; for (list<string>::const_iterator it=probeSetNames.begin(); it!=probeSetNames.end(); it++) { maxProbeSetNameLength = max(maxProbeSetNameLength, (int) it->length()); } // Create the data object CHPQuantificationData *data = new CHPQuantificationData(outFile); data->SetEntryCount(numEntries, maxProbeSetNameLength); data->SetAlgName(StringUtils::ConvertMBSToWCS(algName)); data->SetAlgVersion(StringUtils::ConvertMBSToWCS(algVersion)); data->SetArrayType(StringUtils::ConvertMBSToWCS(chipType)); // Store the CEL header if (celFile.length() > 0 && FileUtils::Exists(celFile.c_str()) == true) { FusionCELData cel; cel.SetFileName(celFile.c_str()); cel.ReadHeader(); GenericData *gdata = cel.GetGenericData(); if (gdata != NULL) data->GetFileHeader()->GetGenericDataHdr()->AddParent(*gdata->Header().GetGenericDataHdr()); cel.Close(); } // Add algorithm parameters to list. ParameterNameValueTypeList params; ParameterNameValueType param; if (programName.empty() == false) { param.SetName(L"program-name"); param.SetValueText(StringUtils::ConvertMBSToWCS(programName)); data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param); } if (programVersion.empty() == false) { param.SetName(L"program-version"); param.SetValueText(StringUtils::ConvertMBSToWCS(programVersion)); data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param); } if (programCompany.empty() == false) { param.SetName(L"program-company"); param.SetValueText(StringUtils::ConvertMBSToWCS(programCompany)); data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param); } int nparams = (int) paramNames.size(); param.SetName(L"exec-guid"); param.SetValueAscii(execId); params.push_back(param); for(int iparam=0; iparam<nparams; iparam++) { param.SetName(StringUtils::ConvertMBSToWCS(paramNames[iparam])); param.SetValueAscii(paramValues[iparam]); params.push_back(param); } if (params.empty() == false) data->AddAlgParams(params); params.clear(); nparams = (int) sumNames.size(); for(int iparam=0; iparam<nparams; iparam++) { param.SetName(StringUtils::ConvertMBSToWCS(sumNames[iparam])); param.SetValueAscii(sumValues[iparam]); params.push_back(param); } if (params.empty() == false) data->AddSummaryParams(params); // Creating the writer object will create the file with the header information. CHPQuantificationFileWriter writer(*data); // Write the probe set names. writer.SeekToDataSet(); ProbeSetQuantificationData entry; for (list<string>::const_iterator it=probeSetNames.begin(); it!=probeSetNames.end(); it++) { entry.name = *it; entry.quantification = 0.0f; writer.WriteEntry(entry); } }
void CHPQuantificationFileWriterTest::WriteTest() { ParameterNameValueTypeList params; ParameterNameValueType param; CHPQuantificationData data("CHP_quantification_file"); data.SetAlgName(L"sig"); data.SetAlgVersion(L"1.0"); data.SetArrayType(L"test3"); data.SetEntryCount(2, 10); param.SetName(L"an1"); param.SetValueText(L"av1"); params.push_back(param); data.AddAlgParams(params); params.clear(); param.SetName(L"sn1"); param.SetValueText(L"sv1"); params.push_back(param); data.AddSummaryParams(params); CHPQuantificationFileWriter *writer = new CHPQuantificationFileWriter(data); affymetrix_calvin_data::ProbeSetQuantificationData e; writer->SeekToDataSet(); e.name = "abc"; e.quantification = 10.0f; writer->WriteEntry(e); e.name = "xyz"; e.quantification = 20.0f; writer->WriteEntry(e); delete writer; CPPUNIT_ASSERT(1); CHPQuantificationData data2; CHPQuantificationFileReader reader; reader.SetFilename("CHP_quantification_file"); reader.Read(data2); CPPUNIT_ASSERT(data2.GetAlgName() == L"sig"); CPPUNIT_ASSERT(data2.GetAlgVersion() == L"1.0"); CPPUNIT_ASSERT(data2.GetArrayType() == L"test3"); CPPUNIT_ASSERT(data2.GetEntryCount() == 2); ParameterNameValueTypeList p = data2.GetAlgParams(); ParameterNameValueTypeList::iterator it = p.begin(); param = *it; CPPUNIT_ASSERT(param.GetName() == L"an1"); CPPUNIT_ASSERT(param.GetValueText() == L"av1"); p = data2.GetSummaryParams(); it = p.begin(); param = *it; CPPUNIT_ASSERT(param.GetName() == L"sn1"); CPPUNIT_ASSERT(param.GetValueText() == L"sv1"); data2.GetQuantificationEntry(0, e); CPPUNIT_ASSERT_DOUBLES_EQUAL(e.quantification, 10.0f, 0.0001f); CPPUNIT_ASSERT(e.name == "abc"); data2.GetQuantificationEntry(1, e); CPPUNIT_ASSERT_DOUBLES_EQUAL(e.quantification, 20.0f, 0.0001f); CPPUNIT_ASSERT(e.name == "xyz"); }
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(); }
/*! Create a "multi-data" CHP file with just the header information. The remainder of the file * will be created at a later time using the buffer writer technique. * The CHP file will contain only "genotyping" results. * @param execId The execution identifier. This identifier is used to identify the batch run that created the CHP files. * @param celFile The full path to the parent CEL file. The header of the CEL file is copied to the CHP file. * @param outFile The name of the output CHP file. * @param extraColNames The names of the extra data columns. Should not include probe set name, call and confidence columns. * @param extraColTypes The types (float, int, ubyte) of the extra columns. * @param numEntries The number of rows (entries) of results to store in the CHP file. * @param maxProbeSetNameLength The maximum length of the probe set names. * @param algName The name of the algorithm used to create the results. * @param algVersion The algorithm version. * @param chipType the chip type, also known as the probe array type. * @param programName The name of the program used to create the CHP file. * @param programVersion The version of the program. * @param programCompany The company or institution who developed the CHP creating software. * @param paramNames A list of parameter names to store in the CHP file header. * @param paramValues A list of parameter values to store in the CHP file header. * @param sumNames A list of summary statistic names to store in the CHP file header. * @param sumValues A list of summary statistic values to store in the CHP file header. */ static void CreateFileWithHeader ( const string &execId, const string &celFile, const string &outFile, const vector<string>& extraColNames, const vector<string>& extraColTypes, unsigned long numEntries, int maxProbeSetNameLength, const string &algName, const string &algVersion, const string &chipType, const string &programName, const string &programVersion, const string &programCompany, const vector<string>& paramNames, const vector<string>& paramValues, const vector<string>& sumNames, const vector<string>& sumValues, const vector<string>& extraNames, const vector<string>& extraValues ) { // Create the vector of extra columns. The sample code here supports only float, 32 bit integers and 8 bit unsigned integers. vector<ColumnInfo> extraColumns; int ncols = (int)extraColNames.size(); for (int icol=0; icol<ncols; icol++) { if (extraColTypes[icol] == "float") { FloatColumn fcol(StringUtils::ConvertMBSToWCS(extraColNames[icol])); extraColumns.push_back(fcol); } else if (extraColTypes[icol] == "int") { IntColumn intcol(StringUtils::ConvertMBSToWCS(extraColNames[icol])); extraColumns.push_back(intcol); } else if (extraColTypes[icol] == "ubyte") { UByteColumn ubcol(StringUtils::ConvertMBSToWCS(extraColNames[icol])); extraColumns.push_back(ubcol); } else { throw string("Unsupported column type: ") + extraColTypes[icol]; } } // Create the data object CHPMultiDataData *data = new CHPMultiDataData(outFile); data->SetEntryCount(GenotypeMultiDataType, numEntries, maxProbeSetNameLength, extraColumns); data->SetAlgName(StringUtils::ConvertMBSToWCS(algName)); data->SetAlgVersion(StringUtils::ConvertMBSToWCS(algVersion)); data->SetArrayType(StringUtils::ConvertMBSToWCS(chipType)); // Store the CEL header if (celFile.length() > 0 && FileUtils::Exists(celFile.c_str()) == true) { FusionCELData cel; cel.SetFileName(celFile.c_str()); cel.ReadHeader(); GenericData *gdata = cel.GetGenericData(); if (gdata != NULL) data->GetFileHeader()->GetGenericDataHdr()->AddParent(*gdata->Header().GetGenericDataHdr()); cel.Close(); } // Add algorithm parameters to list. ParameterNameValueTypeList params; ParameterNameValueType param; if (programName.empty() == false) { param.SetName(L"program-name"); param.SetValueText(StringUtils::ConvertMBSToWCS(programName)); data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param); } if (programVersion.empty() == false) { param.SetName(L"program-version"); param.SetValueText(StringUtils::ConvertMBSToWCS(programVersion)); data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param); } if (programCompany.empty() == false) { param.SetName(L"program-company"); param.SetValueText(StringUtils::ConvertMBSToWCS(programCompany)); data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param); } int nparams = (int) extraNames.size(); for(int iparam=0; iparam<nparams; iparam++) { param.SetName(StringUtils::ConvertMBSToWCS(extraNames[iparam])); param.SetValueAscii(extraValues[iparam]); data->GetGenericData().Header().GetGenericDataHdr()->AddNameValParam(param); } nparams = (int) paramNames.size(); param.SetName(L"exec-guid"); param.SetValueAscii(execId); params.push_back(param); for(int iparam=0; iparam<nparams; iparam++) { param.SetName(StringUtils::ConvertMBSToWCS(paramNames[iparam])); param.SetValueAscii(paramValues[iparam]); params.push_back(param); } if (params.empty() == false) data->AddAlgParams(params); params.clear(); nparams = (int) sumNames.size(); for(int iparam=0; iparam<nparams; iparam++) { param.SetName(StringUtils::ConvertMBSToWCS(sumNames[iparam])); param.SetValueAscii(sumValues[iparam]); params.push_back(param); } if (params.empty() == false) data->AddSummaryParams(params); // Creating the writer object will create the file with the header information. CHPMultiDataFileWriter writer(*data); }
// Uses a mix of the GenericFileWriter and raw commands void TestFileGenerator::WriteOutGenericDATDataFile1UsingGenericWriter() { GenericDataHeader gdh; AddStandardGenericDataHeader(gdh); // 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); // Open the file. ofstream fileStream; fileStream.open( "test.file.data_dat", ios_base::out | ios_base::binary | ios_base::trunc); // Write the file header using raw methods until the writer is available. // magic number FileOutput::WriteUInt8(fileStream, 59); // version FileOutput::WriteInt8(fileStream, 1); // Number of data cubes - confirm this FileOutput::WriteUInt32(fileStream, 1); // offset to the data cube byte offset array int offsetLocation = fileStream.tellp(); FileOutput::WriteUInt32(fileStream, 1); //???? // Write the GenericDataHeader to the file GenericDataHeaderWriter gdhWriter; gdhWriter.Write(fileStream, gdh); // // Data Cube // int offset = fileStream.tellp(); // Write the DataSetHeader DataSetWriter dphWriter(&fileStream, &dph); dphWriter.WriteHeader(); // Write out the data for( int32_t i=0; i < rows; ++i ) { u_int16_t value = (u_int16_t)(i*10+i); FileOutput::WriteUInt16(fileStream, value); } // write the offset fileStream.seekp(offsetLocation); FileOutput::WriteUInt32(fileStream, offset); fileStream.close(); }
/** * No more probesets will be processed, this is a chance to finish outputting * results and clean up. * @param qMethod - Quantification method that was used. * @return true if success, false otherwise. */ bool QuantMethodExprCCCHPReport::finish(QuantMethod &qMethod) { // Sanity to check we saw all the probe sets we were expecting. if (m_CurrentProbeSetCount != m_Info.m_NumProbeSets) { Err::errAbort("QuantMethodExprCCCHPReport::finish() - Expecting: " + ToStr(m_Info.m_NumProbeSets) + " but got: " + ToStr(m_CurrentProbeSetCount) + ". Command Console CHP file will be corrupt."); } // Flush remaining signal entries in the buffer. m_ExpressionQuantificationBufferWriter.FlushBuffer(); // Rewrite CHP files to get chip summary entires Verbose::out(1,"Creating final files for CHP output"); Verbose::progressBegin(1, ToStr("Finalizing Expression CHP Files"), m_CHPFileNames.size(), 1, m_CHPFileNames.size()); try { for (unsigned int chip = 0; chip < m_CHPFileNames.size(); chip++) { // open up tmp chp file to pull results from GenericData data; GenericFileReader reader; std::string filename = m_CHPFileNames[chip]+".tmp"; reader.SetFilename(filename); reader.ReadHeader(data); GenericDataHeader* hdr = data.Header().GetGenericDataHdr(); GenericDataHeader updateHdr; for (int source = 0; source < m_ChipSummaries.size(); source++) { ChipSummary::metricDefVec_t metricDefs = m_ChipSummaries[source]->getMetricDefs(); for (int i = 0; i < metricDefs.size(); i++) { ChipSummary::Metric metric; if (!m_ChipSummaries[source]->getMetric(chip, metricDefs[i].m_name, metric)) { Err::errAbort("QuantMethodExprCCCHPReport: metric '" + metricDefs[i].m_name + "' was not found"); } std::wstring mName(CHIP_SUMMARY_PARAMETER_NAME_PREFIX); mName += StringUtils::ConvertMBSToWCS(metric.m_Name); ParameterNameValueType param; if (hdr->FindNameValParam(mName, param) == false) { Err::errAbort("QuantMethodExprCCCHPReport: metric name '" + StringUtils::ConvertWCSToMBS(mName) + "' could not be found in the header of " + filename); } switch (param.GetParameterType()) { case ParameterNameValueType::Int8Type: param.SetValueInt8((int8_t)metric.m_Integer); break; case ParameterNameValueType::UInt8Type: param.SetValueUInt8((u_int8_t)metric.m_Integer); break; case ParameterNameValueType::Int16Type: param.SetValueInt16((int16_t)metric.m_Integer); break; case ParameterNameValueType::UInt16Type: param.SetValueUInt16((u_int16_t)metric.m_Integer); break; case ParameterNameValueType::Int32Type: param.SetValueInt32((int32_t)metric.m_Integer); break; case ParameterNameValueType::UInt32Type: param.SetValueUInt32((u_int32_t)metric.m_Integer); break; case ParameterNameValueType::FloatType: param.SetValueFloat((float)metric.m_Double); break; case ParameterNameValueType::TextType: param.SetValueText(StringUtils::ConvertMBSToWCS(metric.m_String), (int) metric.m_String.length()); break; case ParameterNameValueType::AsciiType: if (metric.m_String.size() > 256) { Err::errAbort("QuantMethodExprCCCHPReport: string header parameter too long, name = '" + metric.m_Name + "', value = '" + metric.m_String + "'"); } param.SetValueAscii(metric.m_String, (int) metric.m_String.length()); break; default: Err::errAbort("QuantMethodExprCCCHPReport: unknown header parameter type found in file " + filename); } updateHdr.AddNameValParam(param); } } std::ofstream os; Fs::aptOpen(os, filename, std::ios::out|std::ios::binary|std::ios::in); if (!os) { Err::errAbort("QuantMethodExprCCCHPReport: file " + filename + " could not be opened for writing"); } GenericDataHeaderUpdater updater; updater.Update(os, updateHdr, *hdr); os.close(); Verbose::progressStep(1); } } catch (...) { removeAllChps(); Err::errAbort("Error in creating final CHP output."); } Verbose::progressEnd(1, ToStr("Done.")); // Remove .tmp extension for (unsigned int i = 0; i < m_CHPFileNames.size(); i++) { std::string from = m_CHPFileNames[i] + ".tmp"; std::string to = m_CHPFileNames[i]; if (!Fs::fileRename(from.c_str(),to.c_str())) { removeAllChps(); Err::errAbort("Unable to rename '" + from + "' to '" + to + "'"); } } removeTmpChps(); return true; }
void GenericDataTest_FileIndependent::setUp() { // Create generic data header data = new GenericData; data->Header().SetFilename("../data/test.file.data_dat"); header = new GenericDataHeader; header->SetFileCreationTime(L"20040823T17:06:00Z"); // header->SetFileCreationTime(DateTime::GetCurrentDateTime().ToString().c_str()); // change time to wstring? header->SetFileTypeId(INTENSITY_DATA_TYPE); // header->SetFileId(AffymetrixGuid::GenerateNewGuid()); header->SetFileId("someuniquedatfileid"); header->SetLocale(L"en-US"); // Create parent array file header parent = new GenericDataHeader; parent->SetFileTypeId(ARRAY_TYPE_IDENTIFIER); parent->SetLocale(L"en-US"); // parent->SetFileId(AffymetrixGuid::GenerateNewGuid()); parent->SetFileId("someuniquearrayfileid"); parent->SetFileCreationTime(L"20031225T18:23:00Z"); ParameterNameValueType nvt; nvt.SetName(ARRAY_ID_PARAM_NAME); nvt.SetValueAscii("arrayidis17"); parent->AddNameValParam(nvt); header->AddParent(*parent); // Add GenericDataHeader to the FileHeader data->Header().SetGenericDataHdr(*header); // Create DataGroupHeaders dch = new DataGroupHeader; dch->SetName(L"Default"); // Create DataSetHeaders dphPI = new DataSetHeader; dphPI->SetName(L"pixel intensity"); ParameterNameValueType param; param.SetName(L"Scanner"); param.SetValueText(L"M10"); dphPI->AddNameValParam(param); dphPI->AddUShortColumn(L"Intensity"); dphPI->SetRowCnt(1); dphGrid = new DataSetHeader; dphGrid->SetName(L"grid coordinates"); param.SetName(L"Corner Pattern"); param.SetValueText(L"Checkerboard"); dphGrid->AddNameValParam(param); dphGrid->AddUShortColumn(L"GridULX"); dphGrid->AddUShortColumn(L"GridULY"); dphGrid->AddUShortColumn(L"GridURX"); dphGrid->AddUShortColumn(L"GridURY"); dphGrid->AddUShortColumn(L"GridLRX"); dphGrid->AddUShortColumn(L"GridLRY"); dphGrid->AddUShortColumn(L"GridLLX"); dphGrid->AddUShortColumn(L"GridLLY"); dphGrid->SetRowCnt(1); // Add DataGroupHeaders dch->AddDataSetHdr(*dphPI); dch->AddDataSetHdr(*dphGrid); data->Header().AddDataGroupHdr(*dch); }
/* * Create a results file with the CEL file header and other parameters. */ void CopyNumberResultWriter::CreateResultFile(affymetrix_fusion_io::FusionCELData& cel, const std::string& fileName) { try { // Create the results file with the header. CHPMultiDataData *data = new CHPMultiDataData(fileName); data->SetEntryCount(CopyNumberMultiDataType, numberProbeSets, maxProbeSetNameLength[CopyNumberMultiDataType], columns); if (numberCytoRegions > 0) data->SetEntryCount(CytoMultiDataType, numberCytoRegions, maxProbeSetNameLength[CytoMultiDataType],cytoRegionColumns); if (numberGenotypeProbeSets > 0) data->SetEntryCount(GenotypeMultiDataType, numberGenotypeProbeSets, maxProbeSetNameLength[GenotypeMultiDataType], genotypeColumns); data->SetAlgName(StringUtils::ConvertMBSToWCS(algName)); data->SetAlgVersion(StringUtils::ConvertMBSToWCS(algVersion)); data->SetArrayType(cel.GetChipType()); GenericDataHeader *gdh = data->GetFileHeader()->GetGenericDataHdr(); ParameterNameValueType param; param.SetName(PROGRAM_NAME); param.SetValueText(StringUtils::ConvertMBSToWCS(programName)); gdh->AddNameValParam(param); param.SetName(L"program-version"); param.SetValueText(StringUtils::ConvertMBSToWCS(programVersion)); gdh->AddNameValParam(param); param.SetName(PROGRAM_COMPANY); param.SetValueText(StringUtils::ConvertMBSToWCS(programCompany)); gdh->AddNameValParam(param); ParameterNameValueTypeList params = algParams; param.SetName(L"ArraySet"); param.SetValueText(cel.GetChipType()); params.push_back(param); data->AddAlgParams(params); data->AddSummaryParams(summaryParams); DataSetHeader *dsh = data->GetDataSetHeader(CopyNumberMultiDataType); for (ParameterNameValueTypeList::iterator it=chrStartStop.begin(); it!=chrStartStop.end(); it++) dsh->AddNameValParam(*it); GenericData *gdata = cel.GetGenericData(); if (gdata != NULL) gdh->AddParent(*gdata->Header().GetGenericDataHdr()); CHPMultiDataFileWriter *writer = new CHPMultiDataFileWriter(*data); delete writer; delete data; // Create a buffer writer object outputFiles.clear(); outputFiles.push_back(fileName); vector<MultiDataType> dataTypes; dataTypes.push_back(CopyNumberMultiDataType); if (numberCytoRegions > 0) dataTypes.push_back(CytoMultiDataType); if (numberGenotypeProbeSets > 0) dataTypes.push_back(GenotypeMultiDataType); bufferWriter = new CHPMultiDataFileBufferWriter(); bufferWriter->Initialize(&outputFiles, dataTypes, maxProbeSetNameLength); } catch (CalvinException &ex) { string err = "Error creating the output file: " + fileName; wstring msg = ex.ToString(); if (msg.empty() == false) err += " " + StringUtils::ConvertWCSToMBS(msg); throw err; } catch (...) { string err = "Error creating the output file: " + fileName; throw err; } }
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(); }