public void TestConvertNumericToMultiNumeric() { var mBase = PerseusFactory.CreateMatrixData(); mBase.AddStringColumn("Id", "", new [] { "n1;n2", "n3" }); var mdata = PerseusFactory.CreateMatrixData(new[, ] { { 0.0 }, { 1.0 }, { 2.0 } }); mdata.AddStringColumn("Id", "", new [] { "n1", "n2", "n3" }); var match = new MatchingRowsByName(); var errString = string.Empty; var param = match.GetParameters(new [] { mBase, mdata }, ref errString); param.GetParam <int[]>("Copy main columns").Value = new[] { 0 }; param.GetParam <int>("Combine copied main values").Value = 5; IMatrixData[] supplTables = null; IDocumentData[] documents = null; var result = match.ProcessData(new[] { mBase, mdata }, param, ref supplTables, ref documents, BaseTest.CreateProcessInfo()); Assert.AreEqual(result.MultiNumericColumnCount, 1); CollectionAssert.AreEqual(new [] { 0.0, 1.0 }, result.MultiNumericColumns[0][0]); CollectionAssert.AreEqual(new [] { 2.0 }, result.MultiNumericColumns[0][1]); }
public void TestInitialize() { var peptidesValues = new[, ] { { 9.0f } }; peptides = PerseusFactory.CreateMatrixData(peptidesValues, new List <string> { "pep_MS/MS Count" }); peptides.AddNumericColumn("pep_Intensity", "", new [] { 0.0 }); peptides.AddStringColumn("pep_id", "", new [] { "35" }); peptides.AddStringColumn("pep_Protein group IDs", "", new [] { "13;21" }); peptides.Quality.Init(1, 1); peptides.Quality.Set(0, 0, 1); var multiNum = new ExpandMultiNumeric(); var errorString = string.Empty; var parameters2 = multiNum.GetParameters(peptides, ref errorString); parameters2.GetParam <int[]>("Text columns").Value = new[] { 1 }; IMatrixData[] suppl = null; IDocumentData[] docs = null; multiNum.ProcessData(peptides, parameters2, ref suppl, ref docs, CreateProcessInfo()); var proteinMainValues = new[, ] { { 166250000.0f }, { 8346000.0f } }; proteinMain = PerseusFactory.CreateMatrixData(proteinMainValues, new List <string> { "prot_LFQ intensity" }); proteinMain.Name = "protein main"; proteinMain.AddStringColumn("prot_id", "", new [] { "13", "21" }); proteinMain.AddStringColumn("prot_gene name", "", new [] { "geneA", "geneB" }); var expandValues = new[, ] { { 9.0f }, { 9.0f } }; expand = PerseusFactory.CreateMatrixData(expandValues, new List <string> { "pep_MS/MS Count" }); expand.Name = "expand"; expand.AddNumericColumn("pep_Intensity", "", new [] { 0.0, 0.0 }); expand.AddStringColumn("pep_id", "", new [] { "35", "35" }); expand.AddStringColumn("pep_Protein group IDs", "", new [] { "13", "21" }); matching = new MatchingRowsByName(); var err = string.Empty; parameters = matching.GetParameters(new[] { expand, proteinMain }, ref err); }
public void TestConvertNumericToMultiNumeric() { var mBase = PerseusFactory.CreateMatrixData(); mBase.AddStringColumn("Id", "", new [] { "n1;n2", "n3", "n5" }); Assert.IsTrue(mBase.IsConsistent(out var mBaseConsistent), mBaseConsistent); var mdata = PerseusFactory.CreateMatrixData(new[, ] { { 0.0 }, { 1.0 }, { 2.0 }, { 3.0 } }); mdata.AddStringColumn("Id", "", new [] { "n1", "n2", "n3", "n4" }); Assert.IsTrue(mdata.IsConsistent(out var mdataConsistent), mdataConsistent); var match = new MatchingRowsByName(); var errString = string.Empty; var param = match.GetParameters(new [] { mBase, mdata }, ref errString); param.GetParam <int[]>("Copy main columns").Value = new[] { 0 }; param.GetParam <int>("Combine copied main values").Value = 5; param.GetParam <int>("Join style").Value = 1; param.GetParam <bool>("Add indicator").Value = true; param.GetParam <bool>("Add original row numbers").Value = true; IMatrixData[] supplTables = null; IDocumentData[] documents = null; var result = match.ProcessData(new[] { mBase, mdata }, param, ref supplTables, ref documents, BaseTest.CreateProcessInfo()); var indicator = result.GetCategoryColumnAt(0).Select(cats => cats.SingleOrDefault() ?? ""); CollectionAssert.AreEqual(new [] { "+", "+", "", "+" }, indicator); CollectionAssert.AreEqual(new [] { "n1;n2", "n3", "n5", "n4" }, result.GetStringColumn("Id")); CollectionAssert.AreEqual(new [] { "Original row numbers", "Column 1" }, result.MultiNumericColumnNames); CollectionAssert.AreEqual(new [] { 0.0, 1.0 }, result.MultiNumericColumns[0][0]); CollectionAssert.AreEqual(new [] { 2.0 }, result.MultiNumericColumns[0][1]); CollectionAssert.AreEqual(new double[0], result.MultiNumericColumns[0][2]); CollectionAssert.AreEqual(new [] { 3.0 }, result.MultiNumericColumns[0][3]); CollectionAssert.AreEqual(new [] { 0.0, 1.0 }, result.MultiNumericColumns[1][0]); CollectionAssert.AreEqual(new [] { 2.0 }, result.MultiNumericColumns[1][1]); CollectionAssert.AreEqual(new double[0], result.MultiNumericColumns[1][2]); CollectionAssert.AreEqual(new [] { 3.0 }, result.MultiNumericColumns[1][3]); }
public void TestMatchingCaseInSensitive() { var mBase = PerseusFactory.CreateMatrixData(); mBase.AddStringColumn("Name", "", new [] { "A", "a", "B", "b", "C", "c" }); Assert.IsTrue(mBase.IsConsistent(out var mBaseConsistent), mBaseConsistent); var mdata = PerseusFactory.CreateMatrixData(); mdata.AddStringColumn("Name", "", new [] { "a", "B" }); Assert.IsTrue(mdata.IsConsistent(out var mdataConsistent), mdataConsistent); var match = new MatchingRowsByName(); var errString = string.Empty; var param = match.GetParameters(new [] { mBase, mdata }, ref errString); param.GetParam <bool>("Add indicator").Value = true; param.GetParam <bool>("Ignore case").Value = true; IMatrixData[] supplTables = null; IDocumentData[] documents = null; var result = match.ProcessData(new[] { mBase, mdata }, param, ref supplTables, ref documents, BaseTest.CreateProcessInfo()); var indicator = result.GetCategoryColumnAt(0).Select(cats => cats.SingleOrDefault() ?? "").ToArray(); CollectionAssert.AreEqual(new [] { "+", "+", "+", "+", "", "" }, indicator); }