예제 #1
0
void CalvinCHPMultiDataFileUpdaterTest::testMultiData1()
{
	CreateReferenceFile1();

    vector<ColumnInfo> cols;
	CalvinCHPMultiDataFileUpdater upd;
    ProbeSetMultiDataGenotypeData e;
	upd.Initialize(TEST1_FILE);

    e.call = 11;
    e.confidence = 111.0f;
	upd.UpdateMultiData(GenotypeMultiDataType, 0, e);

    e.call = 22;
    e.confidence = 222.0f;
	upd.UpdateMultiData(GenotypeMultiDataType, 2, e);

	CHPMultiDataData data;
	CHPMultiDataFileReader reader;
	CPPUNIT_ASSERT_NO_THROW(reader.SetFilename(TEST1_FILE));
	CPPUNIT_ASSERT_NO_THROW(reader.Read(data));
	CPPUNIT_ASSERT(data.GetEntryCount(GenotypeMultiDataType) == 4);

    data.GetGenotypeEntry(GenotypeMultiDataType, 0, e);
	CPPUNIT_ASSERT(e.name == "1");
	CPPUNIT_ASSERT(e.call == 11);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(e.confidence, 111.0f, 0.000001f);
	data.GetGenotypeEntry(GenotypeMultiDataType, 1, e);
	CPPUNIT_ASSERT(e.name == "2");
	CPPUNIT_ASSERT(e.call == 2);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(e.confidence, 20.0f, 0.000001f);
	data.GetGenotypeEntry(GenotypeMultiDataType, 2, e);
	CPPUNIT_ASSERT(e.name == "3");
	CPPUNIT_ASSERT(e.call == 22);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(e.confidence, 222.0f, 0.000001f);
	data.GetGenotypeEntry(GenotypeMultiDataType, 3, e);
	CPPUNIT_ASSERT(e.name == "4");
	CPPUNIT_ASSERT(e.call == 4);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(e.confidence, 40.0f, 0.000001f);
}
예제 #2
0
void CalvinCHPMultiDataFileUpdaterTest::testMultiData3()
{
	CreateReferenceFile3();

    vector<ColumnInfo> cols;
    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);

	CalvinCHPMultiDataFileUpdater upd;
    ProbeSetMultiDataCopyNumberData e;
	ProbeSetMultiDataCytoRegionData c;
	upd.Initialize(TEST3_FILE);

    e.metrics.resize(9);

    e.chr = 11;
    e.position = 111;
    e.metrics[0].SetValueInt8(9);
    e.metrics[1].SetValueUInt8(10);
    e.metrics[2].SetValueInt16(17);
    e.metrics[3].SetValueUInt16(18);
    e.metrics[4].SetValueInt32(33);
    e.metrics[5].SetValueUInt32(34);
    e.metrics[6].SetValueFloat(55.0f);
    e.metrics[7].SetValueAscii("text");
    e.metrics[8].SetValueText(L"ascii");
	upd.UpdateMultiData(CopyNumberMultiDataType, 0, e, cols);

    e.chr = 22;
    e.position = 222;
    e.metrics[0].SetValueInt8(10);
    e.metrics[1].SetValueUInt8(11);
    e.metrics[2].SetValueInt16(18);
    e.metrics[3].SetValueUInt16(19);
    e.metrics[4].SetValueInt32(34);
    e.metrics[5].SetValueUInt32(35);
    e.metrics[6].SetValueFloat(66.0f);
    e.metrics[7].SetValueAscii("text2");
    e.metrics[8].SetValueText(L"ascii2");
	upd.UpdateMultiData(CopyNumberMultiDataType, 2, e, cols);

    vector<ColumnInfo> cycols;
    c.call = 11;
    c.confidenceScore = 111.0f;
    c.chr = 11;
    c.startPosition = 11;
    c.stopPosition = 22;
    upd.UpdateMultiData(CytoMultiDataType, 0, c, cycols);

    c.call = 2;
    c.confidenceScore = 20.0f;
    c.chr = 22;
    c.startPosition = 22;
    c.stopPosition = 33;
    upd.UpdateMultiData(CytoMultiDataType, 1, c, cycols);

	CHPMultiDataData data;
	CHPMultiDataFileReader reader;
	CPPUNIT_ASSERT_NO_THROW(reader.SetFilename(TEST3_FILE));
	CPPUNIT_ASSERT_NO_THROW(reader.Read(data));
	CPPUNIT_ASSERT(data.GetEntryCount(CopyNumberMultiDataType) == 4);
	CPPUNIT_ASSERT(data.GetEntryCount(CytoMultiDataType) == 2);

    data.GetCopyNumberEntry(CopyNumberMultiDataType, 0, e);
	CPPUNIT_ASSERT(e.name == "1");
	CPPUNIT_ASSERT(e.chr == 11);
    CPPUNIT_ASSERT(e.position == 111);
    CPPUNIT_ASSERT(e.metrics[0].GetValueInt8() == 9);
    CPPUNIT_ASSERT(e.metrics[1].GetValueUInt8() == 10);
    CPPUNIT_ASSERT(e.metrics[2].GetValueInt16() == 17);
    CPPUNIT_ASSERT(e.metrics[3].GetValueUInt16() == 18);
    CPPUNIT_ASSERT(e.metrics[4].GetValueInt32() == 33);
    CPPUNIT_ASSERT(e.metrics[5].GetValueUInt32() == 34);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(e.metrics[6].GetValueFloat(), 55.0f, 0.00001f);
    CPPUNIT_ASSERT(e.metrics[7].GetValueAscii() == "text");
    CPPUNIT_ASSERT(e.metrics[8].GetValueText() == L"ascii");

    data.GetCopyNumberEntry(CopyNumberMultiDataType, 1, e);
	CPPUNIT_ASSERT(e.name == "2");
	CPPUNIT_ASSERT(e.chr == 2);
	CPPUNIT_ASSERT(e.position == 20);
    CPPUNIT_ASSERT(e.metrics[0].GetValueInt8() == 8);
    CPPUNIT_ASSERT(e.metrics[1].GetValueUInt8() == 8);
    CPPUNIT_ASSERT(e.metrics[2].GetValueInt16() == 16);
    CPPUNIT_ASSERT(e.metrics[3].GetValueUInt16() == 16);
    CPPUNIT_ASSERT(e.metrics[4].GetValueInt32() == 32);
    CPPUNIT_ASSERT(e.metrics[5].GetValueUInt32() == 32);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(e.metrics[6].GetValueFloat(), 44.0f, 0.00001f);
    CPPUNIT_ASSERT(e.metrics[7].GetValueAscii() == "ascii");
    CPPUNIT_ASSERT(e.metrics[8].GetValueText() == L"text");

    data.GetCopyNumberEntry(CopyNumberMultiDataType, 2, e);
	CPPUNIT_ASSERT(e.name == "3");
	CPPUNIT_ASSERT(e.chr == 22);
	CPPUNIT_ASSERT(e.position == 222);
    CPPUNIT_ASSERT(e.metrics[0].GetValueInt8() == 10);
    CPPUNIT_ASSERT(e.metrics[1].GetValueUInt8() == 11);
    CPPUNIT_ASSERT(e.metrics[2].GetValueInt16() == 18);
    CPPUNIT_ASSERT(e.metrics[3].GetValueUInt16() == 19);
    CPPUNIT_ASSERT(e.metrics[4].GetValueInt32() == 34);
    CPPUNIT_ASSERT(e.metrics[5].GetValueUInt32() == 35);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(e.metrics[6].GetValueFloat(), 66.0f, 0.00001f);
    CPPUNIT_ASSERT(e.metrics[7].GetValueAscii() == "text2");
    CPPUNIT_ASSERT(e.metrics[8].GetValueText() == L"ascii2");

    data.GetCopyNumberEntry(CopyNumberMultiDataType, 3, e);
	CPPUNIT_ASSERT(e.name == "4");
	CPPUNIT_ASSERT(e.chr == 4);
	CPPUNIT_ASSERT(e.position == 40);
    CPPUNIT_ASSERT(e.metrics[0].GetValueInt8() == 8);
    CPPUNIT_ASSERT(e.metrics[1].GetValueUInt8() == 8);
    CPPUNIT_ASSERT(e.metrics[2].GetValueInt16() == 16);
    CPPUNIT_ASSERT(e.metrics[3].GetValueUInt16() == 16);
    CPPUNIT_ASSERT(e.metrics[4].GetValueInt32() == 32);
    CPPUNIT_ASSERT(e.metrics[5].GetValueUInt32() == 32);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(e.metrics[6].GetValueFloat(), 44.0f, 0.00001f);
    CPPUNIT_ASSERT(e.metrics[7].GetValueAscii() == "ascii");
    CPPUNIT_ASSERT(e.metrics[8].GetValueText() == L"text");



    data.GetCytoEntry(CytoMultiDataType, 0, c);
	CPPUNIT_ASSERT(c.name == "1");
	CPPUNIT_ASSERT(c.call == 11);
	CPPUNIT_ASSERT(c.chr == 11);
    CPPUNIT_ASSERT(c.startPosition == 11);
    CPPUNIT_ASSERT(c.stopPosition == 22);
    CPPUNIT_ASSERT_DOUBLES_EQUAL(c.confidenceScore, 111.0f, 0.00001f);

    data.GetCytoEntry(CytoMultiDataType, 1, c);
	CPPUNIT_ASSERT(c.name == "2");
	CPPUNIT_ASSERT(c.chr == 22);
    CPPUNIT_ASSERT(c.startPosition == 22);
    CPPUNIT_ASSERT(c.stopPosition == 33);
	CPPUNIT_ASSERT(c.call == 2);
	CPPUNIT_ASSERT_DOUBLES_EQUAL(c.confidenceScore, 20.0f, 0.00001f);

}