public void TestUnabeledProteoformCommunityRelate_EF()
        {
            ProteoformCommunity       test_community;
            List <ProteoformRelation> unequal_relations;

            //Two equal, two unequal lysine count. Each should create two unequal relations, so eight relations total
            //However, it shouldn't compare to itself, so that would make 4 total relations
            test_community = new ProteoformCommunity();
            SaveState.lollipop.neucode_labeled      = true;
            test_community.experimental_proteoforms = new ExperimentalProteoform[] {
                ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A2", 1000.0, 5, true),
                ConstructorsForTesting.ExperimentalProteoform("A3", 1000.0, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A4", 1000.0, 2, true)
            };
            SaveState.lollipop.ee_relations = test_community.relate(test_community.experimental_proteoforms, test_community.experimental_proteoforms, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            unequal_relations = test_community.relate_ef(test_community.experimental_proteoforms, test_community.experimental_proteoforms);
            Assert.AreNotEqual(test_community.experimental_proteoforms[0], test_community.experimental_proteoforms[2]);
            Assert.False(test_community.allowed_relation(test_community.experimental_proteoforms[0], test_community.experimental_proteoforms[0], ProteoformComparison.ExperimentalExperimental));
            Assert.AreNotEqual(test_community.experimental_proteoforms[0].lysine_count, test_community.experimental_proteoforms[1].lysine_count);
            Assert.False(test_community.allowed_relation(test_community.experimental_proteoforms[0], test_community.experimental_proteoforms[1], ProteoformComparison.ExperimentalExperimental));
            Assert.True(test_community.allowed_relation(test_community.experimental_proteoforms[0], test_community.experimental_proteoforms[2], ProteoformComparison.ExperimentalExperimental));
            Assert.False(test_community.allowed_relation(test_community.experimental_proteoforms[0], test_community.experimental_proteoforms[3], ProteoformComparison.ExperimentalExperimental));
            Assert.AreEqual(2, unequal_relations.Count); //only 2 relations are > 3 lysines apart

            //Two equal, two unequal lysine count. But one each has mass_difference > 250, so no relations
            test_community = new ProteoformCommunity();
            test_community.experimental_proteoforms = new ExperimentalProteoform[] {
                ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A2", 2000, 2, true),
                ConstructorsForTesting.ExperimentalProteoform("A3", 3000, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A4", 4000, 2, true)
            };
            SaveState.lollipop.ee_relations = test_community.relate(test_community.experimental_proteoforms, test_community.experimental_proteoforms, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            unequal_relations = test_community.relate_ef(test_community.experimental_proteoforms, test_community.experimental_proteoforms);
            Assert.AreEqual(0, unequal_relations.Count);

            //None equal lysine count (apart from itself), four unequal lysine count. Each should create no unequal relations, so no relations total
            test_community = new ProteoformCommunity();
            test_community.experimental_proteoforms = new ExperimentalProteoform[] {
                ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A2", 1000.0, 2, true),
                ConstructorsForTesting.ExperimentalProteoform("A3", 1000.0, 3, true),
                ConstructorsForTesting.ExperimentalProteoform("A4", 1000.0, 4, true)
            };
            SaveState.lollipop.ee_relations = test_community.relate(test_community.experimental_proteoforms, test_community.experimental_proteoforms, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            unequal_relations = test_community.relate_ef(test_community.experimental_proteoforms, test_community.experimental_proteoforms);
            Assert.AreEqual(0, unequal_relations.Count);

            //All equal, no unequal lysine count because there's an empty list of unequal lysine-count proteoforms. Each should create no unequal relations, so no relations total
            test_community = new ProteoformCommunity();
            test_community.experimental_proteoforms = new ExperimentalProteoform[] {
                ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A2", 1000.0, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A3", 1000.0, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A4", 1000.0, 1, true)
            };
            unequal_relations = test_community.relate_ef(test_community.experimental_proteoforms, test_community.experimental_proteoforms);
            Assert.AreEqual(0, unequal_relations.Count);
        }
Exemplo n.º 2
0
        //Special histogram counting relations of mass difference from unmodified
        private void cb_discoveryHistogram_CheckedChanged(object sender, EventArgs e)
        {
            if (cb_discoveryHistogram.Checked)
            {
                Cursor = Cursors.WaitCursor;
                if (et_histogram_from_unmod.Count == 0)
                {
                    ProteoformCommunity community = new ProteoformCommunity();
                    et_histogram_from_unmod = community.relate(SaveState.lollipop.target_proteoform_community.experimental_proteoforms.Where(ex => ex.accepted).ToArray(), SaveState.lollipop.target_proteoform_community.theoretical_proteoforms.Where(t => t.ptm_set.mass == 0).Select(t => new Proteoform(t.accession, t.unmodified_mass, t.lysine_count, t.is_target)).ToArray(), ProteoformComparison.ExperimentalTheoretical, false, Environment.CurrentDirectory, false);
                }
                DisplayUtility.GraphRelationsChart(ct_ET_Histogram, et_histogram_from_unmod, "relations", true);

                // Show the raw relations in the table
                tb_relationTableFilter.TextChanged -= tb_relationTableFilter_TextChanged;
                tb_relationTableFilter.Text         = "";
                tb_relationTableFilter.TextChanged += tb_relationTableFilter_TextChanged;

                displayRelations = et_histogram_from_unmod.Select(r => new DisplayProteoformRelation(r)).ToList();
                DisplayUtility.FillDataGridView(dgv_ET_Relations, displayRelations);

                // Get rid of the stripline by default
                cb_Graph_lowerThreshold.Checked = false;
                Cursor = Cursors.Default;
            }
            else
            {
                DisplayUtility.GraphRelationsChart(ct_ET_Histogram, SaveState.lollipop.et_relations, "relations", true);
                FillETRelationsGridView();
                cb_Graph_lowerThreshold.Checked     = true;
                tb_relationTableFilter.TextChanged -= tb_relationTableFilter_TextChanged;
                tb_relationTableFilter.Text         = "";
                tb_relationTableFilter.TextChanged += tb_relationTableFilter_TextChanged;
            }
        }
        public void TestNeuCodeLabeledProteoformCommunityRelate_EE()
        {
            SaveState.lollipop.neucode_labeled = true;

            // Two proteoforms; lysine count equal; mass difference < 250 -- return 1
            ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, 1, true);
            ExperimentalProteoform pf2 = ConstructorsForTesting.ExperimentalProteoform("A2", 1010.0, 1, true);

            ExperimentalProteoform[] pa1 = new ExperimentalProteoform[2];
            pa1[0] = pf1;
            pa1[1] = pf2;
            List <ProteoformRelation> prList = new List <ProteoformRelation>();

            prList = community.relate(pa1, pa1, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(1, prList.Count);

            // Two proteoforms; lysine count equal; mass difference > 250 -- return 0
            pf1.modified_mass = 1000;
            pf1.lysine_count  = 1;
            pf2.modified_mass = 2000;
            pf2.lysine_count  = 1;
            pa1[0]            = pf1;
            pa1[1]            = pf2;
            prList            = community.relate(pa1, pa1, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(0, prList.Count);

            // Two proteoforms; lysine count NOT equal; mass difference < 250 -- return 0
            pf1.modified_mass = 1000;
            pf1.lysine_count  = 1;
            pf2.modified_mass = 1100;
            pf2.lysine_count  = 2;
            pa1[0]            = pf1;
            pa1[1]            = pf2;
            prList            = community.relate(pa1, pa1, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(0, prList.Count);

            //Three proteoforms; lysine count equal; mass difference < 250 Da -- return 3
            ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, 1, true);
            ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("A2", 1010.0, 1, true);
            ExperimentalProteoform pf5 = ConstructorsForTesting.ExperimentalProteoform("A3", 1020.0, 1, true);

            ExperimentalProteoform[] pa2 = new ExperimentalProteoform[3];
            pa2[0] = pf3;
            pa2[1] = pf4;
            pa2[2] = pf5;
            prList = community.relate(pa2, pa2, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(3, prList.Count);

            //Three proteoforms; lysine count equal; one mass difference < 250 Da; one mass difference > 500 -- return 1
            pf3.modified_mass = 1000;
            pf3.lysine_count  = 1;
            pf4.modified_mass = 1010;
            pf4.lysine_count  = 1;
            pf5.modified_mass = 2020;
            pf5.lysine_count  = 1;
            pa2[0]            = pf3;
            pa2[1]            = pf4;
            pa2[2]            = pf5;
            prList            = community.relate(pa2, pa2, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(1, prList.Count);

            //Three proteoforms; lysine count NOT equal; mass difference < 250 Da -- return 0
            pf3.modified_mass = 1000;
            pf3.lysine_count  = 1;
            pf4.modified_mass = 1010;
            pf4.lysine_count  = 2;
            pf5.modified_mass = 1020;
            pf5.lysine_count  = 3;
            pa2[0]            = pf3;
            pa2[1]            = pf4;
            pa2[2]            = pf5;
            prList            = community.relate(pa2, pa2, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(0, prList.Count);

            //Three proteoforms; lysine count equal; mass difference > 250 Da -- return 0
            pf3.lysine_count  = 1;
            pf3.modified_mass = 1000;
            pf4.lysine_count  = 1;
            pf4.modified_mass = 1600;
            pf5.lysine_count  = 1;
            pf5.modified_mass = 2500;
            pa2[0]            = pf3;
            pa2[1]            = pf4;
            pa2[2]            = pf5;
            prList            = community.relate(pa2, pa2, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(0, prList.Count);
        }