void CHPFileReaderTest::ReadCHPUniversalFileTest() { CHPData data; CHPFileReader reader; CPPUNIT_ASSERT_NO_THROW(reader.SetFilename("../data/CHP_universal_file")); CPPUNIT_ASSERT_NO_THROW(reader.Read(data)); CPPUNIT_ASSERT(data.GetFilename() == "../data/CHP_universal_file"); CPPUNIT_ASSERT(data.GetEntryCount() == 2); CPPUNIT_ASSERT(data.GetBackgroundZoneCnt() == 2); CHPUniversalEntry entry1; data.GetEntry(0, entry1); CPPUNIT_ASSERT(entry1.GetBackground() == 11.0f); CHPUniversalEntry entry2; data.GetEntry(1, entry2); CPPUNIT_ASSERT(entry2.GetBackground() == 1.0f); CHPBackgroundZone zone1; data.GetBackgroundZone(0, zone1); CPPUNIT_ASSERT(zone1.GetCenterX() == 11.0f); CPPUNIT_ASSERT(zone1.GetCenterY() == 17.8f); CPPUNIT_ASSERT(zone1.GetBackground() == 56.9f); CPPUNIT_ASSERT(zone1.GetSmoothFactor() == 45.89f); CHPBackgroundZone zone2; data.GetBackgroundZone(1, zone2); CPPUNIT_ASSERT(zone2.GetCenterX() == 1.0f); CPPUNIT_ASSERT(zone2.GetCenterY() == 7.8f); CPPUNIT_ASSERT(zone2.GetBackground() == 6.9f); CPPUNIT_ASSERT(zone2.GetSmoothFactor() == 5.89f); }
void CHPFileReaderTest::ReadCHPExpressionFileTest() { CHPData data; CHPFileReader reader; CPPUNIT_ASSERT_NO_THROW(reader.SetFilename("../data/CHP_expression_file")); CPPUNIT_ASSERT_NO_THROW(reader.Read(data)); CPPUNIT_ASSERT(data.GetFilename() == "../data/CHP_expression_file"); CPPUNIT_ASSERT(data.GetEntryCount() == 10); CPPUNIT_ASSERT(data.GetBackgroundZoneCnt() == 2); CHPExpressionEntry entry1; data.GetEntry(0, entry1); CPPUNIT_ASSERT(entry1.GetProbeSetName() == "probe set 1"); CPPUNIT_ASSERT(entry1.GetDetection() == 10); CPPUNIT_ASSERT(entry1.GetDetectionPValue() == 11.0f); float signal = entry1.GetSignal(); CPPUNIT_ASSERT(signal == 17.8f); CPPUNIT_ASSERT(entry1.GetNumPairs() == 6); CPPUNIT_ASSERT(entry1.GetNumPairsUsed() == 5); CPPUNIT_ASSERT(entry1.GetChange() == 2); float chgPVal = entry1.GetChangePValue(); CPPUNIT_ASSERT(chgPVal == 56.9f); CPPUNIT_ASSERT(entry1.GetSigLogRatio() == 45.89f); CPPUNIT_ASSERT(entry1.GetSigLogRatioLo() == 42.0f); CPPUNIT_ASSERT(entry1.GetSigLogRatioHi() == 47.0f); CPPUNIT_ASSERT(entry1.GetCommonPairs() == 2); CHPExpressionEntry entry2; data.GetEntry(1, entry2); CPPUNIT_ASSERT(entry2.GetProbeSetName() == "probe set 2"); CPPUNIT_ASSERT(entry2.GetDetection() == 10); CPPUNIT_ASSERT(entry2.GetDetectionPValue() == 1.0f); CPPUNIT_ASSERT(entry2.GetSignal() == 7.8f); CPPUNIT_ASSERT(entry2.GetNumPairs() == 6); CPPUNIT_ASSERT(entry2.GetNumPairsUsed() == 5); CPPUNIT_ASSERT(entry2.GetChange() == 2); CPPUNIT_ASSERT(entry2.GetChangePValue() == 5.9f); CPPUNIT_ASSERT(entry2.GetSigLogRatio() == 4.89f); CPPUNIT_ASSERT(entry2.GetSigLogRatioLo() == 2.0f); CPPUNIT_ASSERT(entry2.GetSigLogRatioHi() == 7.0f); CPPUNIT_ASSERT(entry2.GetCommonPairs() == 2); CHPBackgroundZone zone1; data.GetBackgroundZone(0, zone1); CPPUNIT_ASSERT(zone1.GetCenterX() == 11.0f); CPPUNIT_ASSERT(zone1.GetCenterY() == 17.8f); CPPUNIT_ASSERT(zone1.GetBackground() == 56.9f); CPPUNIT_ASSERT(zone1.GetSmoothFactor() == 45.89f); CHPBackgroundZone zone2; data.GetBackgroundZone(1, zone2); CPPUNIT_ASSERT(zone2.GetCenterX() == 1.0f); CPPUNIT_ASSERT(zone2.GetCenterY() == 7.8f); CPPUNIT_ASSERT(zone2.GetBackground() == 6.9f); CPPUNIT_ASSERT(zone2.GetSmoothFactor() == 5.89f); }
void CHPFileReaderTest::ReadCHPGenotypingFileTest() { CHPData data; CHPFileReader reader; CPPUNIT_ASSERT_NO_THROW(reader.SetFilename("../data/CHP_genotype_file")); CPPUNIT_ASSERT_NO_THROW(reader.Read(data)); CPPUNIT_ASSERT(data.GetFilename() == "../data/CHP_genotype_file"); CPPUNIT_ASSERT(data.GetEntryCount() == 2); CPPUNIT_ASSERT(data.GetBackgroundZoneCnt() == 2); CHPGenotypeEntry entry1; data.GetEntry(0, entry1); CPPUNIT_ASSERT(entry1.GetProbeSetName() == "probe set 1"); CPPUNIT_ASSERT(entry1.GetCall() == 1); CPPUNIT_ASSERT(entry1.GetConfidence() == 11.0f); float ras1 = entry1.GetRAS1(); CPPUNIT_ASSERT(ras1 == 17.8f); CPPUNIT_ASSERT(entry1.GetRAS2() == 6.0f); CPPUNIT_ASSERT(entry1.GetAACall() == 5.0f); CPPUNIT_ASSERT(entry1.GetABCall() == 2.0f); CPPUNIT_ASSERT(entry1.GetBBCall() == 56.9f); CPPUNIT_ASSERT(entry1.GetNoCall() == 45.89f); CHPGenotypeEntry entry2; data.GetEntry(1, entry2); CPPUNIT_ASSERT(entry2.GetProbeSetName() == "probe set 2"); CPPUNIT_ASSERT(entry2.GetCall() == 2); CPPUNIT_ASSERT(entry2.GetConfidence() == 1.0f); CPPUNIT_ASSERT(entry2.GetRAS1() == 7.8f); CPPUNIT_ASSERT(entry2.GetRAS2() == 6.0f); CPPUNIT_ASSERT(entry2.GetAACall() == 5.0f); CPPUNIT_ASSERT(entry2.GetABCall() == 2.0f); CPPUNIT_ASSERT(entry2.GetBBCall() == 5.9f); CPPUNIT_ASSERT(entry2.GetNoCall() == 4.8f); CHPBackgroundZone zone1; data.GetBackgroundZone(0, zone1); CPPUNIT_ASSERT(zone1.GetCenterX() == 11.0f); CPPUNIT_ASSERT(zone1.GetCenterY() == 17.8f); CPPUNIT_ASSERT(zone1.GetBackground() == 56.9f); CPPUNIT_ASSERT(zone1.GetSmoothFactor() == 45.89f); CHPBackgroundZone zone2; data.GetBackgroundZone(1, zone2); CPPUNIT_ASSERT(zone2.GetCenterX() == 1.0f); CPPUNIT_ASSERT(zone2.GetCenterY() == 7.8f); CPPUNIT_ASSERT(zone2.GetBackground() == 6.9f); CPPUNIT_ASSERT(zone2.GetSmoothFactor() == 5.89f); }
/* * Check if the input file is a Calvin file. */ static bool IsCalvinCHPFile(const char *fileName) { CHPData data; CHPFileReader reader; reader.SetFilename(fileName); try { reader.Read(data); data.Clear(); return true; } catch (affymetrix_calvin_exceptions::CalvinException) { } catch (...) { } return false; }
/* * Open the files. */ bool CHPCompareGCOStoCalvin::OpenFiles(const char *gcosFile, const char *calvinFile) { gcos.SetFileName(gcosFile); if (gcos.Read() == false) { differences = "Failed to read the GCOS file\r\n"; return false; } CHPFileReader reader; try { reader.SetFilename(calvinFile); reader.Read(calvin); } catch (...) { differences = "Failed to read the Calvin file\r\n"; return false; } return true; }
/* * Convert the file. */ bool CHPFileConvertToXDA::ConvertCalvinFile(const char *fileName, const char *newFile) { Clear(); // Read the input file. CHPData inFile; CHPFileReader reader; reader.SetFilename(fileName); try { reader.Read(inFile); } catch (...) { errorCode = UnableToOpenChpFile; return false; } // Copy the input file object to the output file object. CCHPFileWriter outFile; outFile.SetFileName(newFile); CHPConversionUtilities::Copy(inFile, outFile); if (parentFileName.empty() == false) { // override the parent file name // Attempt to remove the path. string::size_type posBS = parentFileName.rfind('\\'); string::size_type posS = parentFileName.rfind('/'); if (posBS != -1) { outFile.SetParentCelFileName(parentFileName.substr(posBS+1).c_str()); } else if (posS != -1) { outFile.SetParentCelFileName(parentFileName.substr(posS+1).c_str()); } else { outFile.SetParentCelFileName(parentFileName.c_str()); } } // Override chip type if it was set in extra parameters std::string chipType = GetChipTypeFromExtraParameters(); if (chipType.length() > 0) { outFile.GetHeader().SetChipType(chipType.c_str()); } // Write the output file. if (outFile.CreateNewFile() == false) { errorCode = UnableToWriteTheFile; return false; } if (outFile.Save() == false) { errorCode = UnableToWriteTheFile; return false; } return true; }
void CHPFileReaderTest::ReadCHPReseqFileTest() { CHPData data; CHPFileReader reader; CPPUNIT_ASSERT_NO_THROW(reader.SetFilename("../data/CHP_reseq_file")); CPPUNIT_ASSERT_NO_THROW(reader.Read(data)); CPPUNIT_ASSERT(data.GetFilename() == "../data/CHP_reseq_file"); CPPUNIT_ASSERT(data.GetEntryCount() == 5); CPPUNIT_ASSERT(data.GetBackgroundZoneCnt() == 1); CPPUNIT_ASSERT(data.GetForceCnt() == 2); CPPUNIT_ASSERT(data.GetOrigCnt() == 3); const double eps = 1e-5; CHPReseqEntry e; data.GetEntry(0, e); CPPUNIT_ASSERT(e.call == 'a'); CPPUNIT_ASSERT_DOUBLES_EQUAL(e.score, 1.0f, eps); data.GetEntry(1, e); CPPUNIT_ASSERT(e.call == 'c'); CPPUNIT_ASSERT_DOUBLES_EQUAL(e.score, 2.0f, eps); data.GetEntry(2, e); CPPUNIT_ASSERT(e.call == 'g'); CPPUNIT_ASSERT_DOUBLES_EQUAL(e.score, 3.0f, eps); data.GetEntry(3, e); CPPUNIT_ASSERT(e.call == 't'); CPPUNIT_ASSERT_DOUBLES_EQUAL(e.score, 4.0f, eps); data.GetEntry(4, e); CPPUNIT_ASSERT(e.call == 'n'); CPPUNIT_ASSERT_DOUBLES_EQUAL(e.score, 5.0f, eps); CHPReseqForceCall force; data.GetForceCall(0, force); CPPUNIT_ASSERT(force.position == 1); CPPUNIT_ASSERT(force.call == 'a'); CPPUNIT_ASSERT(force.reason == CC_SATURATION_LEVEL_FORCE_CALL); data.GetForceCall(1, force); CPPUNIT_ASSERT(force.position == 2); CPPUNIT_ASSERT(force.call == 'c'); CPPUNIT_ASSERT(force.reason == CC_WEAK_SIGNAL_THR_FORCE_CALL); CHPReseqOrigCall orig; data.GetOrigCall(0, orig); CPPUNIT_ASSERT(orig.position == 3); CPPUNIT_ASSERT(orig.call == 't'); data.GetOrigCall(1, orig); CPPUNIT_ASSERT(orig.position == 4); CPPUNIT_ASSERT(orig.call == 'a'); data.GetOrigCall(2, orig); CPPUNIT_ASSERT(orig.position == 5); CPPUNIT_ASSERT(orig.call == 'g'); }