void IntensityFileTypeTest::testFromHP() { FusionCELData cel; cel.SetFileName("../data/T1_r1.CEL"); cel.Read(false); CPPUNIT_ASSERT(FromHP(cel) == true); cel.SetFileName("../data/ht.cel"); cel.Read(false); CPPUNIT_ASSERT(FromHP(cel) == false); cel.SetFileName("../data/gcos_m10.CEL"); cel.Read(false); CPPUNIT_ASSERT(FromHP(cel) == false); cel.SetFileName("../data/hp.cel"); cel.Read(false); CPPUNIT_ASSERT(FromHP(cel) == true); }
void CopyNumberResultWriterTest::testWrite() { CopyNumberResultWriter writer; const char *fileNames[] = {"test1.cn", "test2.cn"}; list<ParameterNameValueType> algParams; list<ParameterNameValueType> sumParams; vector<ColumnInfo> cols; writer.MaximumProbeSetNameLength(12); writer.MaximumCytoRegionNameLength(12); writer.MaximumGenotypeProbeSetNameLength(12); writer.AlgName() = "MYALG"; writer.AlgVersion() = "1.0"; writer.NumberProbeSets() = 10; writer.NumberCytoRegions() = 10; writer.NumberGenotypeProbeSets() = 10; writer.Columns() = cols; writer.AlgParams() = algParams; writer.SetChromosomeProbeSetIndexInformation(X_CHR, 0, writer.NumberProbeSets()); for (int i=0; i<2; i++) { FusionCELData cel; cel.SetFileName("../data/small_cel_file"); cel.Read(false); writer.SummaryParams() = sumParams; writer.CreateResultFile(cel, fileNames[i]); cel.Close(); ProbeSetMultiDataCopyNumberData entry; char buf[64]; for (int j=0; j<writer.NumberProbeSets(); j++) { entry.chr = X_CHR; entry.position = j+i; snprintf(buf, 64, "%d", j+i); entry.name = buf; writer.WriteProbeSetResult(entry); } ProbeSetMultiDataCytoRegionData cy; for (int j=0; j<writer.NumberCytoRegions(); j++) { cy.call = 1; cy.confidenceScore = (float)(j+i); snprintf(buf, 64, "%d", j+i); cy.name = buf; writer.WriteCytoRegionResult(cy); } ProbeSetMultiDataGenotypeData gt; for (int j=0; j<writer.NumberGenotypeProbeSets(); j++) { gt.call = 1; gt.confidence = (float)(j+i); snprintf(buf, 64, "%d", j+i); gt.name = buf; writer.WriteGenotypeProbeSetResult(gt); } writer.CloseResultsFile(); } for (int i=0; i<2; i++) { FusionCHPData *chp = FusionCHPDataReg::Read(fileNames[i]); CPPUNIT_ASSERT(chp != NULL); FusionCHPMultiDataData *genoChp = FusionCHPMultiDataData::FromBase(chp); CPPUNIT_ASSERT(genoChp != NULL); CPPUNIT_ASSERT(genoChp->GetAlgName() == L"MYALG"); CPPUNIT_ASSERT(genoChp->GetAlgVersion() == L"1.0"); CPPUNIT_ASSERT(genoChp->GetArrayType() == L"Hg-small"); CPPUNIT_ASSERT(genoChp->GetEntryCount(ExpressionMultiDataType) == 0); CPPUNIT_ASSERT(genoChp->GetEntryCount(GenotypeMultiDataType) == 10); CPPUNIT_ASSERT(genoChp->GetEntryCount(CopyNumberMultiDataType) == 10); CPPUNIT_ASSERT(genoChp->GetEntryCount(CytoMultiDataType) == 10); DataSetHeader *dsh = genoChp->GetDataSetHeader(CopyNumberMultiDataType); CPPUNIT_ASSERT(dsh->GetNameValParamCnt() == 3); ParameterNameValueTypeConstIt begin; ParameterNameValueTypeConstIt end; ParameterNameValueTypeConstIt it; dsh->GetNameValIterators(begin, end); it = begin; CPPUNIT_ASSERT(it->GetValueInt32() == 0); ++it; CPPUNIT_ASSERT(it->GetValueInt32() == 10); ++it; CPPUNIT_ASSERT(it->GetValueAscii() == "X"); ProbeSetMultiDataCopyNumberData entry; char buf[64]; for (int j=0; j<10; j++) { genoChp->GetCopyNumberEntry(CopyNumberMultiDataType, j, entry); CPPUNIT_ASSERT(entry.chr == X_CHR); CPPUNIT_ASSERT(entry.position == j+i); snprintf(buf, 64, "%d", j+i); CPPUNIT_ASSERT(entry.name.compare(buf) == 0); } ProbeSetMultiDataCytoRegionData cy; for (int j=0; j<10; j++) { genoChp->GetCytoRegionEntry(CytoMultiDataType, j, cy); CPPUNIT_ASSERT(cy.call == 1); CPPUNIT_ASSERT_DOUBLES_EQUAL(cy.confidenceScore, j+i, 0.0001f); snprintf(buf, 64, "%d", j+i); CPPUNIT_ASSERT(cy.name.compare(buf) == 0); } ProbeSetMultiDataGenotypeData gt; for (int j=0; j<10; j++) { genoChp->GetGenotypeEntry(GenotypeMultiDataType, j, gt); CPPUNIT_ASSERT(gt.call == 1); CPPUNIT_ASSERT_DOUBLES_EQUAL(gt.confidence, j+i, 0.0001f); snprintf(buf, 64, "%d", j+i); CPPUNIT_ASSERT(gt.name.compare(buf) == 0); } delete chp; } }