public void TestProteoformCommunityRelate_ED()
        {
            SaveState.lollipop = new Lollipop();
            SaveState.lollipop.decoy_databases = 1;
            // In empty comminity, relate ed is empty
            Assert.AreEqual(0, SaveState.lollipop.ed_relations.Count);

            //create a decoy proteoform community
            SaveState.lollipop.decoy_proteoform_communities.Add(SaveState.lollipop.decoy_community_name_prefix + "0", new ProteoformCommunity());
            TheoreticalProteoform pf2 = ConstructorsForTesting.make_a_theoretical("decoyProteoform1", 0, -1);

            SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].theoretical_proteoforms = new TheoreticalProteoform[1] {
                pf2
            };
            SaveState.lollipop.relate_ed();
            // Have a single decoy community --> have single ed_relations
            Assert.AreEqual(1, SaveState.lollipop.ed_relations.Count);
            // But it's empty
            Assert.IsEmpty(SaveState.lollipop.ed_relations[SaveState.lollipop.decoy_community_name_prefix + "0"]);

            // In order to make it not empty, we must have relate_et method output a non-empty List
            // it must take as arguments non-empty pfs1 and pfs2
            // So testProteoformCommunity.experimental_proteoforms must be non-empty
            // And decoy_proteoforms["fake_decoy_proteoform1"] must be non-empty
            ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("experimentalProteoform1");

            SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].theoretical_proteoforms.First().ExpandedProteinList = new List <ProteinWithGoTerms> {
                p1
            };

            Assert.IsEmpty(SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].experimental_proteoforms);
            SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].experimental_proteoforms = new ExperimentalProteoform[] { pf1 };

            SaveState.lollipop.clear_et();
            prepare_for_et(new List <double> {
                pf1.modified_mass - pf2.modified_mass
            });
            SaveState.lollipop.relate_ed();

            // Make sure there is one relation total, because only a single decoy was provided
            Assert.AreEqual(1, SaveState.lollipop.ed_relations.Count);
            Assert.IsNotEmpty(SaveState.lollipop.ed_relations);
            Assert.AreEqual(1, SaveState.lollipop.ed_relations[SaveState.lollipop.decoy_community_name_prefix + "0"].Count); // Make sure there is one relation for the provided fake_decoy_proteoform1

            ProteoformRelation rel = SaveState.lollipop.ed_relations[SaveState.lollipop.decoy_community_name_prefix + "0"][0];

            Assert.IsFalse(rel.Accepted);
            Assert.AreEqual("decoyProteoform1", rel.connected_proteoforms[1].accession);
            Assert.AreEqual(0, rel.DeltaMass);
            Assert.IsEmpty(((TheoreticalProteoform)rel.connected_proteoforms[1]).fragment);
            Assert.AreEqual(1, rel.nearby_relations_count);  //shows that calculate_unadjusted_group_count works
            //Assert.AreEqual(1, rel.mass_difference_group.Count);  //I don't think we need this test anymore w/ way peaks are made -LVS
            Assert.AreEqual(-1, rel.lysine_count);
            Assert.AreEqual("T2", ((TheoreticalProteoform)rel.connected_proteoforms[1]).name);
            Assert.AreEqual(0, ((ExperimentalProteoform)rel.connected_proteoforms[0]).aggregated_components.Count); //nothing aggregated with the basic constructor
            Assert.IsTrue(rel.outside_no_mans_land);
            Assert.IsNull(rel.peak);
            Assert.True(string.Equals("unmodified", ((TheoreticalProteoform)rel.connected_proteoforms[1]).ptm_description, StringComparison.CurrentCultureIgnoreCase));
            Assert.AreEqual(1, rel.nearby_relations_count);
        }
        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);
        }
Esempio n. 3
0
        public void results_decoy_dataframe_with_something()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.input_files.Add(ConstructorsForTesting.InputFile("fake.txt", Labeling.NeuCode, Purpose.Identification, "n", "s", "1", "1", "1")); //0
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E1");

            e.linked_proteoform_references = new List <Proteoform>(new List <Proteoform> {
                ConstructorsForTesting.make_a_theoretical()
            });
            e.ptm_set = e.linked_proteoform_references.Last().ptm_set;
            ProteoformFamily f = new ProteoformFamily(e);

            f.construct_family();
            Sweet.lollipop.decoy_proteoform_communities.Add("Decoy1", new ProteoformCommunity());
            Sweet.lollipop.decoy_proteoform_communities["Decoy1"].families = new List <ProteoformFamily> {
                f
            };
            var time_stamp = Sweet.time_stamp();
            var directory  = TestContext.CurrentContext.TestDirectory;

            ResultsSummaryGenerator.save_all(TestContext.CurrentContext.TestDirectory, time_stamp, Sweet.lollipop.TusherAnalysis1 as IGoAnalysis, Sweet.lollipop.TusherAnalysis1 as TusherAnalysis);
            Assert.IsTrue(File.Exists(Path.Combine(directory, "decoy_experimental_results_" + time_stamp + ".tsv")));
            var lines = File.ReadAllLines(Path.Combine(directory, "decoy_experimental_results_" + time_stamp + ".tsv"));

            Assert.AreEqual(2, lines.Length);
        }
        public void test_no_mans_land()
        {
            var e  = ConstructorsForTesting.ExperimentalProteoform("");
            var ee = ProteoformComparison.ExperimentalExperimental;

            // Small masses, tight tolerance
            ProteoformRelation r1 = new ProteoformRelation(e, e, ee, 0.015 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory);

            Assert.IsTrue(r1.outside_no_mans_land);
            ProteoformRelation r2 = new ProteoformRelation(e, e, ee, 0.016 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory);

            Assert.IsFalse(r2.outside_no_mans_land);
            ProteoformRelation r3 = new ProteoformRelation(e, e, ee, -0.967 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory);

            Assert.IsTrue(r3.outside_no_mans_land);
            ProteoformRelation r4 = new ProteoformRelation(e, e, ee, -0.966 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory);

            Assert.IsFalse(r4.outside_no_mans_land);

            // Larger masses, larger tolerance
            ProteoformRelation r5 = new ProteoformRelation(e, e, ee, 200.22 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory);

            Assert.IsTrue(r5.outside_no_mans_land);
            ProteoformRelation r6 = new ProteoformRelation(e, e, ee, 200.23 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory);

            Assert.IsFalse(r6.outside_no_mans_land);
            ProteoformRelation r7 = new ProteoformRelation(e, e, ee, 200.92 - SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory);

            Assert.IsTrue(r7.outside_no_mans_land);
            ProteoformRelation r8 = new ProteoformRelation(e, e, ee, 200.91 - SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory);

            Assert.IsFalse(r8.outside_no_mans_land);
        }
Esempio n. 5
0
        public void test_bottom_up_PSMs()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.et_high_mass_difference = 2;
            Sweet.lollipop.et_low_mass_difference  = -2;
            Sweet.lollipop.neucode_labeled         = false;
            Sweet.lollipop.carbamidomethylation    = false;
            Sweet.lollipop.enter_input_files(new string[] { Path.Combine(TestContext.CurrentContext.TestDirectory, "testHits.psmtsv") }, Lollipop.acceptable_extensions[7], Lollipop.file_types[7], Sweet.lollipop.input_files, false);
            Sweet.lollipop.enter_input_files(new string[] { Path.Combine(TestContext.CurrentContext.TestDirectory, "uniprot_yeast_test_12entries.xml") }, Lollipop.acceptable_extensions[2], Lollipop.file_types[2], Sweet.lollipop.input_files, false);
            Sweet.lollipop.theoretical_database.get_theoretical_proteoforms(TestContext.CurrentContext.TestDirectory);
            Assert.AreEqual(10, Sweet.lollipop.theoretical_database.bottom_up_psm_by_accession.Count);

            Sweet.lollipop.min_bu_peptides = 0;
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E1");

            e.modified_mass = 1816.0128; //Q3E770 - no bottomup-peptides
            var relations = Sweet.lollipop.target_proteoform_community.relate(new ExperimentalProteoform[] { e }, Sweet.lollipop.target_proteoform_community.theoretical_proteoforms, ProteoformComparison.ExperimentalTheoretical, TestContext.CurrentContext.TestDirectory, false);

            Assert.AreEqual(1, relations.Count);
            Sweet.lollipop.min_bu_peptides = 1;
            relations = Sweet.lollipop.target_proteoform_community.relate(new ExperimentalProteoform[] { e }, Sweet.lollipop.target_proteoform_community.theoretical_proteoforms, ProteoformComparison.ExperimentalTheoretical, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(0, relations.Count);
            e.modified_mass = 29260.9826; //P0CX35
            Sweet.lollipop.min_bu_peptides = 1;
            relations = Sweet.lollipop.target_proteoform_community.relate(new ExperimentalProteoform[] { e }, Sweet.lollipop.target_proteoform_community.theoretical_proteoforms, ProteoformComparison.ExperimentalTheoretical, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(0, relations.Count); //modified peptide, no mod theoretical with this accession so returns 0
            e.modified_mass = 59841.6191;        //P32329
            relations       = Sweet.lollipop.target_proteoform_community.relate(new ExperimentalProteoform[] { e }, Sweet.lollipop.target_proteoform_community.theoretical_proteoforms, ProteoformComparison.ExperimentalTheoretical, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(1, relations.Count);

            Assert.AreEqual(0, Proteoform.get_possible_PSMs("Q3E770", new PtmSet(new List <Ptm>()), 3, 20).Count());
            Assert.AreEqual(0, Proteoform.get_possible_PSMs("P0CX35", new PtmSet(new List <Ptm>()), 3, 20).Count());
            Assert.AreEqual(1, Proteoform.get_possible_PSMs("P0CX35", Sweet.lollipop.theoretical_database.possible_ptmset_dictionary[80].Where(p => p.ptm_description.Contains("Phospho")).First(), 2, 500).Count());
            Assert.AreEqual(0, Proteoform.get_possible_PSMs("P0CX35", Sweet.lollipop.theoretical_database.possible_ptmset_dictionary[80].Where(p => p.ptm_description.Contains("Phospho")).First(), 1, 5).Count());
        }
        public void choose_next_exp_proteoform()
        {
            ExperimentalProteoform c = ConstructorsForTesting.ExperimentalProteoform("E");
            ExperimentalProteoform d = ConstructorsForTesting.ExperimentalProteoform("E");
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E");
            ExperimentalProteoform f = ConstructorsForTesting.ExperimentalProteoform("E");

            c.agg_mass      = 100;
            d.agg_mass      = 119;
            e.agg_mass      = 121;
            f.agg_mass      = 122;
            c.agg_intensity = 1;
            d.agg_intensity = 2;
            e.agg_intensity = 3;
            f.agg_intensity = 4;
            List <ExperimentalProteoform> ordered = new List <ExperimentalProteoform> {
                c, d, e, f
            }.OrderByDescending(cc => cc.agg_intensity).ToList();
            ExperimentalProteoform is_running = ConstructorsForTesting.ExperimentalProteoform("E");

            is_running.agg_mass      = 100;
            is_running.agg_intensity = 100;

            List <ExperimentalProteoform> active = new List <ExperimentalProteoform> {
                is_running
            };
            ExperimentalProteoform next = Sweet.lollipop.find_next_root(ordered, active);

            Assert.True(Math.Abs(next.agg_mass - is_running.agg_mass) > 2 * (double)Sweet.lollipop.maximum_missed_monos);
            Assert.AreEqual(4, next.agg_intensity);
        }
Esempio n. 7
0
        public void TestUnabeledProteoformCommunityRelateWithNotches_EE()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.neucode_labeled        = false;
            Sweet.lollipop.ee_use_notch           = true;
            Sweet.lollipop.ee_max_mass_difference = 200;

            // One experimental one theoretical protoeform; mass difference < 500 -- return 1
            ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, -1, true);
            ExperimentalProteoform pf2 = ConstructorsForTesting.ExperimentalProteoform("A2", 1010.0, -1, true);

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

            prepare_for_et(new List <double> {
                pf2.modified_mass - pf1.modified_mass
            });
            prList = community.relate(paE, paE, ProteoformComparison.ExperimentalExperimental, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(1, prList.Count);

            //Da instead of ppm -- return 1
            Sweet.lollipop.ee_notch_ppm = false;
            prList = community.relate(paE, paE, ProteoformComparison.ExperimentalExperimental, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(1, prList.Count);

            //outside ppm tolerance - return 0
            pf1.modified_mass                 = 1000;
            pf2.modified_mass                 = 1010.5;
            Sweet.lollipop.ee_notch_ppm       = true;
            Sweet.lollipop.notch_tolerance_ee = 1;
            prepare_for_et(new List <double> {
                10
            });
            prList = community.relate(paE, paE, ProteoformComparison.ExperimentalExperimental, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(0, prList.Count);


            //outside Da toelrance - return 0.
            pf1.modified_mass                 = 1000;
            pf2.modified_mass                 = 1010.5;
            Sweet.lollipop.ee_notch_ppm       = false;
            Sweet.lollipop.notch_tolerance_ee = .5;
            prepare_for_et(new List <double> {
                10
            });
            prList = community.relate(paE, paE, ProteoformComparison.ExperimentalExperimental, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(0, prList.Count);

            // One experimental one theoretical protoeform; mass difference > 500 -- return 0
            pf1.modified_mass = 1000;
            pf2.modified_mass = 2000;
            prepare_for_et(new List <double> {
                pf2.modified_mass - pf1.modified_mass
            });
            prList = community.relate(paE, paE, ProteoformComparison.ExperimentalExperimental, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(0, prList.Count);
        }
Esempio n. 8
0
        public void test_write_families_regular_display()
        {
            TheoreticalProteoform  t  = ConstructorsForTesting.make_a_theoretical();
            ExperimentalProteoform e  = ConstructorsForTesting.ExperimentalProteoform("E1");
            ProteoformRelation     et = new ProteoformRelation(e, t, ProteoformComparison.ExperimentalTheoretical, 0, TestContext.CurrentContext.TestDirectory);

            et.peak = new DeltaMassPeak(et, new HashSet <ProteoformRelation> {
                et
            });
            et.peak.Accepted = true;
            e.relationships.Add(et);
            t.relationships.Add(et);
            e.agg_intensity = 999.99;
            e.quant.TusherValues1.numeratorIntensitySum   = 444.44m;
            e.quant.TusherValues1.denominatorIntensitySum = 333.33m;
            e.quant.intensitySum = 777.77m;
            List <ProteoformFamily> f = new List <ProteoformFamily> {
                new ProteoformFamily(e)
            };

            f.First().construct_family();
            string message = CytoscapeScript.write_cytoscape_script(f, f,
                                                                    TestContext.CurrentContext.TestDirectory, "", "test",
                                                                    null, false, false,
                                                                    CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], CytoscapeScript.node_label_positions[0], Lollipop.node_positioning[0], 2,
                                                                    false, Lollipop.gene_name_labels[1]);

            Assert.True(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.script_file_prefix + "test" + CytoscapeScript.script_file_extension)));
            Assert.True(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.style_file_prefix + "test" + CytoscapeScript.style_file_extension)));
            Assert.True(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.node_file_prefix + "test" + CytoscapeScript.node_file_extension)));
            Assert.True(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.edge_file_prefix + "test" + CytoscapeScript.edge_file_extension)));

            //Check that the style xml is all there
            List <string> vizProperties = new List <string>();

            using (XmlReader xml = XmlReader.Create(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.style_file_prefix + "test" + CytoscapeScript.style_file_extension)))
            {
                while (xml.Read())
                {
                    switch (xml.NodeType)
                    {
                    case XmlNodeType.Element:
                        if (xml.Name == "visualProperty")
                        {
                            vizProperties.Add(xml.GetAttribute("name"));
                        }
                        break;
                    }
                }
            }
            Assert.AreEqual(CytoscapeScript.default_styles.Keys.Where(s => s.StartsWith("NETWORK")).Count(), vizProperties.Where(s => s.StartsWith("NETWORK")).Count());
            Assert.AreEqual(CytoscapeScript.default_styles.Keys.Where(s => s.StartsWith("NODE")).Count(), vizProperties.Where(s => s.StartsWith("NODE")).Count());
            Assert.AreEqual(CytoscapeScript.default_styles.Keys.Where(s => s.StartsWith("EDGE")).Count(), vizProperties.Where(s => s.StartsWith("EDGE")).Count());
            Assert.AreEqual(CytoscapeScript.default_styles.Keys.Where(s => !s.StartsWith("NETWORK") && !s.StartsWith("NODE") && !s.StartsWith("EDGE")).Count(), vizProperties.Where(s => !s.StartsWith("NETWORK") && !s.StartsWith("NODE") && !s.StartsWith("EDGE")).Count());
            Assert.AreEqual(CytoscapeScript.default_styles.Keys.Count, vizProperties.Count);
            Assert.True(message.StartsWith("Finished"));
        }
Esempio n. 9
0
        public void TestUnabeledProteoformCommunityRelate_EE()
        {
            Sweet.lollipop.neucode_labeled        = false;
            Sweet.lollipop.ee_max_mass_difference = 250;

            // Two proteoforms; 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; mass difference > 250 -- return 0
            pf1.modified_mass = 1000;
            pf2.modified_mass = 2000;
            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; 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; one mass difference < 250 Da -- return 1
            pf3.modified_mass = 1000;
            pf4.modified_mass = 1010;
            pf5.modified_mass = 2000;
            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; mass difference > 250 Da -- return 0
            pf3.modified_mass = 1000;
            pf4.modified_mass = 2000;
            pf5.modified_mass = 3000;
            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);
        }
Esempio n. 10
0
        public void biorepintensitytableLog2Fold()
        {
            Sweet.lollipop = new Lollipop();
            Dictionary <string, List <string> > conditionsBioReps = new Dictionary <string, List <string> >
            {
                { "n", new List <string> {
                      1.ToString(), 2.ToString(), 3.ToString()
                  } },
                { "s", new List <string> {
                      1.ToString(), 2.ToString(), 3.ToString()
                  } },
            };

            Sweet.lollipop.Log2FoldChangeAnalysis.conditionBiorepIntensitySums = conditionsBioReps.SelectMany(kv => kv.Value.Select(v => new Tuple <string, string>(kv.Key, v))).ToDictionary(t => t, t => 1d);
            List <InputFile> input_files = new List <InputFile>
            {
                ConstructorsForTesting.InputFile("fake.txt", Labeling.NeuCode, Purpose.Quantification, "n", "s", "1", "1", "1"), //0
                ConstructorsForTesting.InputFile("fake.txt", Labeling.NeuCode, Purpose.Quantification, "n", "s", "1", "2", "1"), //1
                ConstructorsForTesting.InputFile("fake.txt", Labeling.NeuCode, Purpose.Quantification, "n", "s", "2", "1", "1"), //2
                ConstructorsForTesting.InputFile("fake.txt", Labeling.NeuCode, Purpose.Quantification, "n", "s", "2", "2", "1"), //3
                ConstructorsForTesting.InputFile("fake.txt", Labeling.NeuCode, Purpose.Quantification, "n", "s", "3", "1", "1"), //4
                ConstructorsForTesting.InputFile("fake.txt", Labeling.NeuCode, Purpose.Quantification, "n", "s", "3", "2", "1"), //5
            };
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("asdf");

            e.quant.Log2FoldChangeValues.allIntensities = new Dictionary <Tuple <string, string>, BiorepIntensity>
            {
                { new Tuple <string, string>("n", 1.ToString()), new BiorepIntensity(false, 1.ToString(), "n", 1) },
                { new Tuple <string, string>("n", 2.ToString()), new BiorepIntensity(true, 2.ToString(), "n", 1) },
                { new Tuple <string, string>("n", 3.ToString()), new BiorepIntensity(false, 3.ToString(), "n", 1) },
                { new Tuple <string, string>("s", 1.ToString()), new BiorepIntensity(false, 1.ToString(), "s", 1) },
                { new Tuple <string, string>("s", 2.ToString()), new BiorepIntensity(false, 2.ToString(), "s", 1) },
                { new Tuple <string, string>("s", 3.ToString()), new BiorepIntensity(false, 3.ToString(), "s", 1) },
            };
            // With imputation uses processed values
            Assert.False(ResultsSummaryGenerator.datatable_tostring(ResultsSummaryGenerator.biological_replicate_intensities(Sweet.lollipop.Log2FoldChangeAnalysis, new List <ExperimentalProteoform> {
                e
            }, input_files, conditionsBioReps, true, true)).Contains("NaN"));

            // Without imputation uses raw values
            e.biorepIntensityList = e.quant.Log2FoldChangeValues.allIntensities.Values.Where(x => !x.imputed).ToList();
            Assert.True(ResultsSummaryGenerator.datatable_tostring(ResultsSummaryGenerator.biological_replicate_intensities(Sweet.lollipop.Log2FoldChangeAnalysis, new List <ExperimentalProteoform> {
                e
            }, input_files, conditionsBioReps, false, true)).Contains("\t0\t"));

            // Headers should be condition_biorep_fraction_techrep
            string[] header = ResultsSummaryGenerator.datatable_tostring(ResultsSummaryGenerator.biological_replicate_intensities(Sweet.lollipop.Log2FoldChangeAnalysis, new List <ExperimentalProteoform> {
                e
            }, input_files, conditionsBioReps, false, true)).Split('\n')[0].Split('\t');
            Assert.True(header[1] == "n_1" && header[2] == "n_2" && header[3] == "n_3" && header[4] == "s_1" && header[5] == "s_2" && header[6] == "s_3");
            string[] line = ResultsSummaryGenerator.datatable_tostring(ResultsSummaryGenerator.biological_replicate_intensities(Sweet.lollipop.Log2FoldChangeAnalysis, new List <ExperimentalProteoform> {
                e
            }, input_files, conditionsBioReps, false, true)).Split('\n')[1].Split('\t');
            Assert.True(line.First() == e.accession);
            Assert.True(line[1] == "1" && line[2] == "0" && line[3] == "1" && line[4] == "1" && line[5] == "1" && line[6] == "1"); // all "n" condition is imputed
        }
        public void aggregate_just_the_root()
        {
            List <IAggregatable> components = generate_neucode_components(starter_mass);

            components.Remove(components[1]);
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);

            Assert.AreEqual(1, e.aggregated.Count);
            Assert.AreEqual(components[0], e.aggregated.First());
        }
Esempio n. 12
0
        public static void no_relations_doesnt_crash()
        {
            ExperimentalProteoform e1 = ConstructorsForTesting.ExperimentalProteoform("e1");
            ExperimentalProteoform e2 = ConstructorsForTesting.ExperimentalProteoform("e2");

            ConstructorsForTesting.make_relation(e1, e2);
            DeltaMassPeak p = e1.relationships.First().peak;

            Assert.AreEqual(0, p.count_nearby_decoys(new List <ProteoformRelation>()));
        }
Esempio n. 13
0
        public static void accept_peaks_doesnt_crash_with_weird_relation()
        {
            ProteoformCommunity c = new ProteoformCommunity();
            ProteoformRelation  r = new ProteoformRelation(ConstructorsForTesting.ExperimentalProteoform("E1"), ConstructorsForTesting.ExperimentalProteoform("E1"), ProteoformComparison.ExperimentalFalse, 0, TestContext.CurrentContext.TestDirectory);

            r.outside_no_mans_land = true;
            r.nearby_relations     = new List <ProteoformRelation>();
            Assert.Throws <ArgumentException>(() => c.accept_deltaMass_peaks(new List <ProteoformRelation> {
                r
            }, new List <ProteoformRelation>()));
        }
        public void test_construct_one_proteform_family_from_ET_with_theoretical_pf_group()
        {
            ProteoformCommunity test_community = new ProteoformCommunity();

            SaveState.lollipop.theoretical_database.uniprotModifications = new Dictionary <string, List <Modification> > {
                { "unmodified", new List <Modification> {
                      new Modification("unmodified", "unknown")
                  } }
            };

            InputFile          f  = new InputFile("fake.txt", Purpose.ProteinDatabase);
            ProteinWithGoTerms p1 = new ProteinWithGoTerms("", "T1", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new int?[] { 0 }, new int?[] { 0 }, new string[] { "" }, "name", "full_name", true, false, new List <DatabaseReference>(), new List <GoTerm>());
            Dictionary <InputFile, Protein[]> dict = new Dictionary <InputFile, Protein[]> {
                { f, new Protein[] { p1 } }
            };
            TheoreticalProteoform t = ConstructorsForTesting.make_a_theoretical("T1_T1_asdf", p1, dict);


            //One accepted ET relation; should give one ProteoformFamily
            SaveState.lollipop.min_peak_count_et = 1;
            ExperimentalProteoform     pf1 = ConstructorsForTesting.ExperimentalProteoform("E1");
            TheoreticalProteoformGroup pf2 = new TheoreticalProteoformGroup(new List <TheoreticalProteoform> {
                t
            });
            ProteoformComparison comparison = ProteoformComparison.ExperimentalTheoretical;
            ProteoformRelation   pr1        = new ProteoformRelation(pf1, pf2, comparison, 0, TestContext.CurrentContext.TestDirectory);

            pr1.Accepted = true;
            List <ProteoformRelation> prs = new List <ProteoformRelation> {
                pr1
            };

            foreach (ProteoformRelation pr in prs)
            {
                pr.set_nearby_group(prs, prs.Select(r => r.InstanceId).ToList());
            }
            DeltaMassPeak peak = new DeltaMassPeak(prs[0], prs);

            SaveState.lollipop.et_peaks = new List <DeltaMassPeak> {
                peak
            };
            test_community.experimental_proteoforms = new ExperimentalProteoform[] { pf1 };
            test_community.theoretical_proteoforms  = new TheoreticalProteoform[] { pf2 };
            test_community.construct_families();
            Assert.AreEqual(1, test_community.families.Count);
            Assert.AreEqual(2, test_community.families[0].proteoforms.Count);
            Assert.AreEqual(1, test_community.families.First().experimental_proteoforms.Count);
            Assert.AreEqual(1, test_community.families.First().theoretical_proteoforms.Count);
            Assert.AreEqual("E1", test_community.families.First().experimentals_list);
            Assert.AreEqual(p1.Name, test_community.families.First().name_list);
            Assert.AreEqual(pf2.accession, test_community.families.First().accession_list);
        }
Esempio n. 15
0
        public void saveall()
        {
            SaveState.lollipop = new Lollipop();
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("asdf");

            SaveState.lollipop.qVals.Add(e.quant);
            GoTermNumber g = new GoTermNumber(new GoTerm("id", "desc", Aspect.BiologicalProcess), 0, 0, 0, 0);

            g.by = -1;
            SaveState.lollipop.goTermNumbers.Add(g);
            ResultsSummaryGenerator.save_all(TestContext.CurrentContext.TestDirectory, SaveState.time_stamp());
        }
        public void test_construct_multi_member_family()
        {
            //Four experimental proteoforms, three relations (linear), all accepted; should give 1 bundled family
            SaveState.lollipop = new Lollipop();
            ProteoformCommunity test_community = new ProteoformCommunity();

            SaveState.lollipop.target_proteoform_community = test_community;

            SaveState.lollipop.theoretical_database.uniprotModifications = new Dictionary <string, List <Modification> > {
                { "unmodified", new List <Modification> {
                      new Modification("unmodified", "unknown")
                  } }
            };

            SaveState.lollipop.min_peak_count_ee = 2;
            ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("E1");
            ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("E2");
            ExperimentalProteoform pf5 = ConstructorsForTesting.ExperimentalProteoform("E3");
            ExperimentalProteoform pf6 = ConstructorsForTesting.ExperimentalProteoform("E4");

            test_community.experimental_proteoforms = new ExperimentalProteoform[] { pf3, pf4, pf5, pf6 };

            ProteoformComparison comparison34 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison45 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison56 = ProteoformComparison.ExperimentalExperimental;

            ConstructorsForTesting.make_relation(pf3, pf4, comparison34, 0);
            ConstructorsForTesting.make_relation(pf4, pf5, comparison45, 0);
            ConstructorsForTesting.make_relation(pf5, pf6, comparison56, 0);

            List <ProteoformRelation> prs2 = new HashSet <ProteoformRelation>(test_community.experimental_proteoforms.SelectMany(p => p.relationships).Concat(test_community.theoretical_proteoforms.SelectMany(p => p.relationships))).OrderBy(r => r.DeltaMass).ToList();

            foreach (ProteoformRelation pr in prs2)
            {
                pr.set_nearby_group(prs2, prs2.Select(r => r.InstanceId).ToList());
            }
            Assert.AreEqual(3, pf3.relationships.First().nearby_relations_count);
            Assert.AreEqual(3, pf5.relationships.First().nearby_relations_count);
            Assert.AreEqual(3, pf6.relationships.First().nearby_relations_count);

            test_community.accept_deltaMass_peaks(prs2, new List <ProteoformRelation>());
            Assert.AreEqual(1, SaveState.lollipop.ee_peaks.Count);
            Assert.AreEqual(3, SaveState.lollipop.ee_peaks[0].grouped_relations.Count);

            test_community.experimental_proteoforms = new ExperimentalProteoform[] { pf3, pf4, pf5, pf6 };
            test_community.construct_families();
            Assert.AreEqual(1, test_community.families.Count);
            Assert.AreEqual("", test_community.families.First().accession_list);
            Assert.AreEqual(4, test_community.families.First().proteoforms.Count);
            Assert.AreEqual(4, test_community.families.First().experimental_proteoforms.Count);
            Assert.AreEqual(0, test_community.families.First().theoretical_proteoforms.Count);
        }
        public void aggregate_outside_rt_tolerance()
        {
            Sweet.lollipop.neucode_labeled = true;
            List <IAggregatable>   components = generate_neucode_components(starter_mass);
            ExperimentalProteoform e          = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);

            components[1].rt_apex = starter_rt - Sweet.lollipop.retention_time_tolerance - 1;
            e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);
            Assert.AreEqual(1, e.aggregated.Count);
            components[1].rt_apex = starter_rt + Sweet.lollipop.retention_time_tolerance + 1;
            e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);
            Assert.AreEqual(1, e.aggregated.Count);
        }
 public void test_community_has_proteoforms()
 {
     community.experimental_proteoforms = new ExperimentalProteoform[] { };
     community.theoretical_proteoforms  = new TheoreticalProteoform[] { };
     Assert.False(community.has_e_proteoforms);
     Assert.False(community.has_e_and_t_proteoforms);
     community.experimental_proteoforms = new ExperimentalProteoform[] { ConstructorsForTesting.ExperimentalProteoform("E1") };
     Assert.True(community.has_e_proteoforms);
     Assert.False(community.has_e_and_t_proteoforms);
     community.theoretical_proteoforms = new TheoreticalProteoform[] { ConstructorsForTesting.make_a_theoretical() };
     Assert.True(community.has_e_proteoforms);
     Assert.True(community.has_e_and_t_proteoforms);
 }
        public void aggregate_outside_lysine_count_tolerance()
        {
            SaveState.lollipop.neucode_labeled = true;
            List <Component>       components = generate_neucode_components(starter_mass);
            ExperimentalProteoform e          = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);

            ((NeuCodePair)components[1]).lysine_count = starter_lysine_count + Convert.ToInt32(SaveState.lollipop.missed_lysines) + 1;
            e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);
            Assert.AreEqual(1, e.aggregated_components.Count);
            ((NeuCodePair)components[1]).lysine_count = starter_lysine_count - Convert.ToInt32(SaveState.lollipop.missed_lysines) - 1;
            e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);
            Assert.AreEqual(1, e.aggregated_components.Count);
        }
        public void aggregate_outside_lysine_count_tolerance()
        {
            Sweet.lollipop.neucode_labeled = true;
            List <IAggregatable>   components = generate_neucode_components(starter_mass);
            ExperimentalProteoform e          = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);

            ((NeuCodePair)components[1]).lysine_count = starter_lysine_count + Sweet.lollipop.maximum_missed_lysines + 1;
            e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);
            Assert.AreEqual(1, e.aggregated.Count);
            ((NeuCodePair)components[1]).lysine_count = starter_lysine_count - Sweet.lollipop.maximum_missed_lysines - 1;
            e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);
            Assert.AreEqual(1, e.aggregated.Count);
        }
        public void aggregate_mass_corrects_for_monoisotopic_errors()
        {
            //Make a monoisotopic error, and test that it removes it before aggregation
            List <IAggregatable> components = generate_neucode_components(starter_mass);

            components[4].weighted_monoisotopic_mass = starter_mass + missed_monoisotopics * Lollipop.MONOISOTOPIC_UNIT_MASS;
            ExperimentalProteoform e              = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);
            double expected_agg_intensity         = components.Count * starter_intensity;
            double intensity_normalization_factor = components.Count * starter_intensity / expected_agg_intensity;
            double expected_agg_mass              = starter_mass * intensity_normalization_factor;

            Assert.AreEqual(expected_agg_mass, e.agg_mass);
        }
Esempio n. 22
0
        public void artificial_deltaMPeak()
        {
            Sweet.lollipop.theoretical_database.all_possible_ptmsets = new List <PtmSet>();
            ExperimentalProteoform       pf3        = ConstructorsForTesting.ExperimentalProteoform("E1");
            ExperimentalProteoform       pf4        = ConstructorsForTesting.ExperimentalProteoform("E2");
            ProteoformComparison         comparison = ProteoformComparison.ExperimentalExperimental;
            ProteoformRelation           pr2        = new ProteoformRelation(pf3, pf4, comparison, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation           pr3        = new ProteoformRelation(pf3, pf4, comparison, 0, TestContext.CurrentContext.TestDirectory);
            HashSet <ProteoformRelation> prs        = new HashSet <ProteoformRelation> {
                pr2, pr3
            };

            Assert.AreEqual(prs, new DeltaMassPeak(pr2, prs).grouped_relations);
        }
        public void test_aggregate_copy()
        {
            double max_monoisotopic_mass = starter_mass + missed_monoisotopics * Lollipop.MONOISOTOPIC_UNIT_MASS;
            double min_monoisotopic_mass = starter_mass - missed_monoisotopics * Lollipop.MONOISOTOPIC_UNIT_MASS;

            SaveState.lollipop.neucode_labeled = true;
            List <Component> components = generate_neucode_components(starter_mass);

            // in bounds lowest monoisotopic error
            components[1].charge_states.Clear(); // must clear charge states because you can't set the weighted monoisotopic mass if there are charge states.
            components[1].weighted_monoisotopic_mass = min_monoisotopic_mass - min_monoisotopic_mass / 1000000 * Convert.ToDouble(SaveState.lollipop.mass_tolerance);
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);

            Assert.AreEqual(2, e.aggregated_components.Count);
            // in bounds highest monoisotopic error
            components[1].weighted_monoisotopic_mass = max_monoisotopic_mass + max_monoisotopic_mass / 1000000 * Convert.ToDouble(SaveState.lollipop.mass_tolerance);
            e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);
            e.manual_validation_id           = "something";
            e.manual_validation_quant        = "something";
            e.manual_validation_verification = "something";
            ExperimentalProteoform f = new ExperimentalProteoform(e);

            Assert.AreEqual(e.root, f.root);
            Assert.AreEqual(e.agg_intensity, f.agg_intensity);
            Assert.AreEqual(e.agg_mass, f.agg_mass);
            Assert.AreEqual(e.modified_mass, f.modified_mass);
            Assert.AreEqual(e.agg_rt, f.agg_rt);
            Assert.AreEqual(e.lysine_count, f.lysine_count);
            Assert.AreEqual(e.accepted, f.accepted);
            Assert.AreEqual("E1", f.quant.accession);
            Assert.AreEqual(e.mass_shifted, f.mass_shifted);
            Assert.AreEqual(e.is_target, f.is_target);
            Assert.AreEqual(e.family, f.family);
            Assert.AreEqual(e.manual_validation_id, f.manual_validation_id);
            Assert.AreEqual(e.manual_validation_quant, f.manual_validation_quant);
            Assert.AreEqual(e.manual_validation_verification, f.manual_validation_verification);
            Assert.AreNotEqual(e.aggregated_components.GetHashCode(), f.aggregated_components.GetHashCode());
            Assert.AreEqual(e.aggregated_components.Count, f.aggregated_components.Count);
            Assert.AreNotEqual(e.lt_quant_components.GetHashCode(), f.lt_quant_components.GetHashCode());
            Assert.AreEqual(e.lt_quant_components.Count, f.lt_quant_components.Count);
            Assert.AreNotEqual(e.lt_verification_components.GetHashCode(), f.lt_verification_components.GetHashCode());
            Assert.AreEqual(e.lt_verification_components.Count, f.lt_verification_components.Count);
            Assert.AreNotEqual(e.hv_quant_components.GetHashCode(), f.hv_quant_components.GetHashCode());
            Assert.AreEqual(e.hv_quant_components.Count, f.hv_quant_components.Count);
            Assert.AreNotEqual(e.hv_verification_components.GetHashCode(), f.hv_verification_components.GetHashCode());
            Assert.AreEqual(e.hv_verification_components.Count, f.hv_verification_components.Count);
            Assert.AreNotEqual(e.biorepIntensityList.GetHashCode(), f.biorepIntensityList.GetHashCode());
            Assert.AreEqual(e.biorepIntensityList.Count, f.biorepIntensityList.Count);
        }
Esempio n. 24
0
        public void results_dataframe_with_something()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.input_files.Add(ConstructorsForTesting.InputFile("fake.txt", Labeling.NeuCode, Purpose.Identification, "n", "s", "1", "1", "1")); //0
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E1");

            e.linked_proteoform_references = new List <Proteoform>(new List <Proteoform> {
                ConstructorsForTesting.make_a_theoretical()
            });
            e.ptm_set = e.linked_proteoform_references.Last().ptm_set;
            ProteoformFamily f = new ProteoformFamily(e);

            f.construct_family();
            Sweet.lollipop.target_proteoform_community.families = new List <ProteoformFamily> {
                f
            };
            string[] lines = ResultsSummaryGenerator.datatable_tostring(ResultsSummaryGenerator.experimental_results_dataframe(Sweet.lollipop.target_proteoform_community, Sweet.lollipop.TusherAnalysis1)).Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.True(lines.Count() == 3);
            Assert.True(lines.Any(a => a.Contains("E1")));
            TopDownProteoform td = ConstructorsForTesting.TopDownProteoform("TD1", 1000, 10);

            td.linked_proteoform_references = new List <Proteoform>(new List <Proteoform> {
                ConstructorsForTesting.make_a_theoretical()
            });
            td.ptm_set = e.linked_proteoform_references.Last().ptm_set;
            ProteoformFamily f2 = new ProteoformFamily(td);

            f2.construct_family();
            Sweet.lollipop.target_proteoform_community.families = new List <ProteoformFamily> {
                f2
            };
            Sweet.lollipop.topdown_proteoforms = new List <TopDownProteoform>()
            {
                td
            };
            lines = ResultsSummaryGenerator.datatable_tostring(ResultsSummaryGenerator.experimental_results_dataframe(Sweet.lollipop.target_proteoform_community, Sweet.lollipop.TusherAnalysis1)).Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.True(lines.Count() == 3);
            lines = ResultsSummaryGenerator.datatable_tostring(ResultsSummaryGenerator.topdown_results_dataframe()).Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.True(lines.Count() == 3);
            Assert.True(lines.Any(a => a.Contains("TD1")));
            Sweet.lollipop.target_proteoform_community.families = new List <ProteoformFamily> {
                f, f2
            };
            lines = ResultsSummaryGenerator.datatable_tostring(ResultsSummaryGenerator.experimental_intensities_dataframe()).Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.AreEqual(lines.Count(), 4);
            Assert.True(lines.Any(a => a.Contains("E1")));
            Assert.True(lines.Any(a => a.Contains("TD1")));
        }
        public void test_construct_one_proteform_family_from_ET()
        {
            SaveState.lollipop = new Lollipop();
            ProteoformCommunity test_community = new ProteoformCommunity();

            SaveState.lollipop.target_proteoform_community = test_community;
            SaveState.lollipop.theoretical_database.uniprotModifications = new Dictionary <string, List <Modification> > {
                { "unmodified", new List <Modification> {
                      new Modification("unmodified", "unknown")
                  } }
            };

            //One accepted ET relation; should give one ProteoformFamily
            SaveState.lollipop.min_peak_count_et = 1;
            ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("E1");

            pf1.accepted = true;
            TheoreticalProteoform pf2 = ConstructorsForTesting.make_a_theoretical();

            pf2.name = "T1";
            ProteoformComparison comparison = ProteoformComparison.ExperimentalTheoretical;
            ProteoformRelation   pr1        = new ProteoformRelation(pf1, pf2, comparison, 0, TestContext.CurrentContext.TestDirectory);

            pr1.Accepted = true;
            List <ProteoformRelation> prs = new List <ProteoformRelation> {
                pr1
            };

            foreach (ProteoformRelation pr in prs)
            {
                pr.set_nearby_group(prs, prs.Select(r => r.InstanceId).ToList());
            }
            DeltaMassPeak peak = new DeltaMassPeak(prs[0], prs);

            SaveState.lollipop.et_peaks = new List <DeltaMassPeak> {
                peak
            };
            test_community.experimental_proteoforms = new ExperimentalProteoform[] { pf1 };
            test_community.theoretical_proteoforms  = new TheoreticalProteoform[] { pf2 };
            test_community.construct_families();
            Assert.AreEqual("T1", test_community.families.First().name_list);
            Assert.AreEqual("T1", test_community.families.First().accession_list);
            Assert.AreEqual("E1", test_community.families.First().experimentals_list);
            Assert.AreEqual(1, test_community.families.Count);
            Assert.AreEqual(2, test_community.families[0].proteoforms.Count);
            Assert.AreEqual(1, test_community.families.First().experimental_proteoforms.Count);
            Assert.AreEqual(1, test_community.families.First().theoretical_proteoforms.Count);
        }
Esempio n. 26
0
        public void saveall()
        {
            Sweet.lollipop = new Lollipop();
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("asdf");

            Sweet.lollipop.qVals.Add(e.quant);
            GoTermNumber g = new GoTermNumber(new GoTerm("id", "desc", Aspect.BiologicalProcess), 0, 0, 0, 0);

            g.by = -1;
            Sweet.lollipop.TusherAnalysis1.GoAnalysis.goTermNumbers.Add(g);
            Sweet.lollipop.topdown_proteoforms = new List <TopDownProteoform>()
            {
                ConstructorsForTesting.TopDownProteoform("td1", 1000, 10)
            };
            ResultsSummaryGenerator.save_all(TestContext.CurrentContext.TestDirectory, Sweet.time_stamp(), Sweet.lollipop.TusherAnalysis1 as IGoAnalysis, Sweet.lollipop.TusherAnalysis1 as TusherAnalysis);
        }
        public void unlabeled_proteoform_calculate_properties()
        {
            Sweet.lollipop.neucode_labeled = false;
            List <IAggregatable>   components = generate_unlabeled_components(starter_mass);
            ExperimentalProteoform e          = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);

            Assert.AreEqual(2, e.aggregated.Count);
            double expected_agg_intensity = components.Count * starter_intensity;

            Assert.AreEqual(expected_agg_intensity, e.agg_intensity);
            double intensity_normalization_factor = components.Count * starter_intensity / expected_agg_intensity;
            double expected_agg_mass = starter_mass * intensity_normalization_factor;

            Assert.AreEqual(starter_mass * intensity_normalization_factor, e.agg_mass);
            Assert.AreEqual(starter_rt * intensity_normalization_factor, e.agg_rt);
        }
Esempio n. 28
0
        public void results_dataframe_with_something()
        {
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E1");

            e.linked_proteoform_references = new List <Proteoform>(new List <Proteoform> {
                ConstructorsForTesting.make_a_theoretical()
            });
            e.ptm_set = e.linked_proteoform_references.Last().ptm_set;
            ProteoformFamily f = new ProteoformFamily(e);

            f.construct_family();
            SaveState.lollipop.target_proteoform_community.families = new List <ProteoformFamily> {
                f
            };
            string[] lines = ResultsSummaryGenerator.results_dataframe().Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.True(lines.Count() == 3);
            Assert.True(lines.Any(a => a.Contains("E1")));
        }
        public void choose_next_agg_component()
        {
            Component c = new Component();
            Component d = new Component();
            Component e = new Component();
            Component f = new Component();

            c.weighted_monoisotopic_mass = 100;
            d.weighted_monoisotopic_mass = 119;
            e.weighted_monoisotopic_mass = 121;
            f.weighted_monoisotopic_mass = 122;
            c.intensity_sum = 1;
            d.intensity_sum = 2;
            e.intensity_sum = 3;
            f.intensity_sum = 4;
            List <IAggregatable> ordered = new List <IAggregatable> {
                c, d, e, f
            }.OrderByDescending(cc => cc.intensity_sum).ToList();
            Component is_running = new Component();

            is_running.weighted_monoisotopic_mass = 100;
            is_running.intensity_sum = 100;

            //Based on components
            List <IAggregatable> active = new List <IAggregatable> {
                is_running
            };
            IAggregatable next = Sweet.lollipop.find_next_root(ordered, active);

            Assert.True(Math.Abs(next.weighted_monoisotopic_mass - is_running.weighted_monoisotopic_mass) > 2 * (double)Sweet.lollipop.maximum_missed_monos);
            Assert.AreEqual(4, next.intensity_sum);

            //Based on experimental proteoforms
            ExperimentalProteoform exp = ConstructorsForTesting.ExperimentalProteoform("E");

            exp.root = is_running;
            List <ExperimentalProteoform> active2 = new List <ExperimentalProteoform> {
                exp
            };
            IAggregatable next2 = Sweet.lollipop.find_next_root(ordered, active2);

            Assert.True(Math.Abs(next.weighted_monoisotopic_mass - is_running.weighted_monoisotopic_mass) > 2 * (double)Sweet.lollipop.maximum_missed_monos);
            Assert.AreEqual(4, next.intensity_sum);
        }
Esempio n. 30
0
        public void TestUnabeledProteoformCommunityRelateLargePeakBase_ET()
        {
            Sweet.lollipop.neucode_labeled    = false;
            Sweet.lollipop.et_use_notch       = false;
            Sweet.lollipop.peak_width_base_et = 1;

            // One experimental one theoretical protoeform; mass difference < 500 -- return 1
            ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, -1, true);
            TheoreticalProteoform  pf2 = ConstructorsForTesting.make_a_theoretical();

            pf2.modified_mass       = 1010.0;
            pf2.lysine_count        = 1;
            pf2.is_target           = true;
            pf2.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p1
            };
            ExperimentalProteoform[] paE = new ExperimentalProteoform[1];
            TheoreticalProteoform[]  paT = new TheoreticalProteoform[1];
            paE[0] = pf1;
            paT[0] = pf2;
            List <ProteoformRelation> prList = new List <ProteoformRelation>();

            prepare_for_et(new List <double> {
                pf1.modified_mass - pf2.modified_mass - .9
            });
            prList = community.relate(paE, paT, ProteoformComparison.ExperimentalTheoretical, true,
                                      TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(1, prList.Count);

            prepare_for_et(new List <double> {
                pf1.modified_mass - pf2.modified_mass + .9
            });
            prList = community.relate(paE, paT, ProteoformComparison.ExperimentalTheoretical, true,
                                      TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(1, prList.Count);

            prepare_for_et(new List <double> {
                pf1.modified_mass - pf2.modified_mass + 1
            });
            prList = community.relate(paE, paT, ProteoformComparison.ExperimentalTheoretical, true,
                                      TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(0, prList.Count);
        }