public void test_construct_one_proteform_family_from_ET_with_two_theoretical_pf_groups_with_same_accession()
        {
            ProteoformCommunity.gene_centric_families = false;
            ProteoformCommunity community = construct_two_families_with_potentially_colliding_theoreticals();

            SaveState.lollipop.target_proteoform_community = community;

            Assert.AreEqual(2, community.families.Count);
            Assert.AreEqual(9, community.families.SelectMany(f => f.proteoforms).Count());
            Assert.AreEqual(5, community.families.FirstOrDefault(f => f.proteoforms.Select(p => p.accession).Contains("E1")).proteoforms.Count);
            Assert.AreEqual(4, community.families.FirstOrDefault(f => f.proteoforms.Select(p => p.accession).Contains("E6")).proteoforms.Count);
            Assert.AreEqual(3, community.families.FirstOrDefault(f => f.proteoforms.Select(p => p.accession).Contains("E1")).experimental_proteoforms.Count);
            Assert.AreEqual(2, community.families.FirstOrDefault(f => f.proteoforms.Select(p => p.accession).Contains("E1")).theoretical_proteoforms.Count);
            Assert.AreEqual("" + "; " + "GENE", community.families.FirstOrDefault(f => f.proteoforms.Select(p => p.accession).Contains("E1")).gene_list); //both would give null preferred gene names, since that field isn't set up
            Assert.True(String.Join("", community.families.Select(f => f.experimentals_list)).Contains("E1"));
            Assert.True(String.Join("", community.families.Select(f => f.name_list)).Contains(p1_name));
            Assert.True(String.Join("", community.families.Select(f => f.accession_list)).Contains(pf1_accession));
            Assert.True(String.Join("", community.families.Select(f => f.agg_mass_list)).Contains(1234.56.ToString()));

            //Check that the list of proteoforms is the same in the relations as in the proteoform lists
            HashSet <Proteoform> relation_proteoforms = new HashSet <Proteoform>(community.families.SelectMany(f => f.relations).SelectMany(r => r.connected_proteoforms));

            Assert.True(community.experimental_proteoforms.OfType <Proteoform>().Concat(community.theoretical_proteoforms).All(p => relation_proteoforms.Contains(p)));
            Assert.True(relation_proteoforms.All(p => community.experimental_proteoforms.Contains(p) || community.theoretical_proteoforms.Contains(p)));
        }
Beispiel #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 community_clear_ee()
        {
            ProteoformCommunity community = construct_two_families_with_potentially_colliding_theoreticals();

            Assert.IsNotEmpty(SaveState.lollipop.et_relations);
            Assert.IsNotEmpty(SaveState.lollipop.ee_relations);
            Assert.IsNotEmpty(community.families);
            Assert.True(SaveState.lollipop.et_relations.Any(r => r.RelationType == ProteoformComparison.ExperimentalTheoretical));
            Assert.True(SaveState.lollipop.et_peaks.Any(r => r.RelationType == ProteoformComparison.ExperimentalTheoretical));
            Assert.IsNotNull(community.experimental_proteoforms.First().family);
            Assert.IsNotNull(community.experimental_proteoforms.First().gene_name);
            Assert.IsNotNull(community.experimental_proteoforms.First().linked_proteoform_references);
            Assert.IsNotEmpty(community.experimental_proteoforms.First().ptm_set.ptm_combination);
            Assert.True(community.experimental_proteoforms.First().relationships.Any(r => r.RelationType == ProteoformComparison.ExperimentalTheoretical));
            SaveState.lollipop.clear_ee();
            Assert.IsNotEmpty(SaveState.lollipop.et_relations);
            Assert.IsEmpty(SaveState.lollipop.ee_relations);
            Assert.IsEmpty(SaveState.lollipop.ee_peaks);
            Assert.IsNotEmpty(SaveState.lollipop.et_peaks);
            Assert.IsEmpty(community.families);
            Assert.False(SaveState.lollipop.ee_relations.Any(r => r.RelationType == ProteoformComparison.ExperimentalExperimental));
            Assert.False(SaveState.lollipop.ee_peaks.Any(r => r.RelationType == ProteoformComparison.ExperimentalExperimental));
            Assert.Null(community.experimental_proteoforms.First().family);
            Assert.Null(community.experimental_proteoforms.First().gene_name);
            Assert.Null(community.experimental_proteoforms.First().linked_proteoform_references);
            Assert.IsEmpty(community.experimental_proteoforms.First().ptm_set.ptm_combination);
            Assert.False(community.experimental_proteoforms.First().relationships.Any(r => r.RelationType == ProteoformComparison.ExperimentalExperimental));
        }
        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);
        }
        public void test_results_summary_with_peaks()
        {
            SaveState.lollipop.theoretical_database.theoretical_proteins = new Dictionary <InputFile, Protein[]>();
            SaveState.lollipop.theoretical_database.expanded_proteins    = new ProteinWithGoTerms[0];
            ProteoformCommunity community = construct_two_families_with_potentially_colliding_theoreticals();

            Assert.True(ResultsSummaryGenerator.generate_full_report().Length > 0);
        }
Beispiel #6
0
        public void cytoscape_script_from_topdown()
        {
            Sweet.lollipop = new Lollipop();
            ProteoformCommunity community = TestProteoformFamilies.construct_community_with_td_proteoforms(-1);

            Sweet.lollipop.target_proteoform_community = community;
            TopDownProteoform td = ConstructorsForTesting.TopDownProteoform("ASDF", 1000, 50);

            td.gene_name = new GeneName(new List <Tuple <string, string> > {
                new Tuple <string, string>("genename", "genename")
            });
            ProteoformFamily fam = new ProteoformFamily(td);

            fam.construct_family();
            CytoscapeScript.write_cytoscape_script(new List <ProteoformFamily>()
            {
                fam
            }, new List <ProteoformFamily>()
            {
                fam
            },
                                                   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,
                                                   true, Lollipop.gene_name_labels[1]);
            string[]         edge_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.edge_file_prefix + "test" + CytoscapeScript.edge_file_extension));
            HashSet <string> shared_pf_names_edges = new HashSet <string>();

            for (int i = 1; i < edge_lines.Length; i++)
            {
                if (edge_lines[i] == "")
                {
                    break;
                }
                string[] line = edge_lines[i].Split(new char[] { '\t' });
                shared_pf_names_edges.Add(line[0]);
                shared_pf_names_edges.Add(line[2]);
            }

            string[]         node_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.node_file_prefix + "test" + CytoscapeScript.node_file_extension));
            HashSet <string> shared_pf_names_nodes = new HashSet <string>();

            for (int i = 1; i < node_lines.Length; i++)
            {
                if (node_lines[i] == "")
                {
                    break;
                }
                string[] line = node_lines[i].Split(new char[] { '\t' });
                shared_pf_names_nodes.Add(line[0]);
            }

            Assert.True(shared_pf_names_nodes.All(name => shared_pf_names_edges.Contains(name)));
            Assert.True(shared_pf_names_edges.All(name => shared_pf_names_nodes.Contains(name)));
            Assert.AreEqual(2, shared_pf_names_nodes.Count);
            Assert.AreEqual(2, shared_pf_names_edges.Count);
        }
        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);
        }
Beispiel #8
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 gene_centric_family()
        {
            ProteoformCommunity.gene_centric_families = true;
            ProteoformCommunity.preferred_gene_label  = Lollipop.gene_name_labels[1];

            ProteoformCommunity community = construct_two_families_with_potentially_colliding_theoreticals();

            Assert.AreEqual(1, community.families.Count);

            //Only the distinct gene names are kept in list
            Assert.AreEqual(String.Join("; ", new string[] { "", "GENE", "GENE" }.Distinct()), community.families.FirstOrDefault(f => f.proteoforms.Select(p => p.accession).Contains("E1")).gene_list); //both would give null preferred gene names, since that field isn't set up
        }
        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 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);
        }
Beispiel #12
0
        public void cytoscape_edges_and_nodes_match()
        {
            Sweet.lollipop = new Lollipop();
            ProteoformCommunity community = TestProteoformFamilies.construct_two_families_with_potentially_colliding_theoreticals();

            Sweet.lollipop.target_proteoform_community = community;
            IEnumerable <TheoreticalProteoform> theoreticals = community.families.SelectMany(f => f.theoretical_proteoforms);
            string edges = CytoscapeScript.get_cytoscape_edges_tsv(community.families,
                                                                   Lollipop.edge_labels[0], Lollipop.node_labels[0], 2,
                                                                   theoreticals, false, Lollipop.gene_name_labels[1]);

            string[]         lines = edges.Split(new char[] { '\n' });
            HashSet <string> shared_pf_names_edges = new HashSet <string>();

            for (int i = 1; i < lines.Length; i++)
            {
                if (lines[i] == "")
                {
                    break;
                }
                string[] line = lines[i].Split(new char[] { '\t' });
                shared_pf_names_edges.Add(line[0]);
                shared_pf_names_edges.Add(line[2]);
            }

            string nodes = CytoscapeScript.get_cytoscape_nodes_tsv(community.families, null,
                                                                   CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], Lollipop.node_positioning[0], 2,
                                                                   theoreticals, false, Lollipop.gene_name_labels[1]);

            lines = nodes.Split(new char[] { '\n' });
            HashSet <string> shared_pf_names_nodes = new HashSet <string>();

            for (int i = 1; i < lines.Length; i++)
            {
                if (lines[i] == "")
                {
                    break;
                }
                string[] line = lines[i].Split(new char[] { '\t' });
                shared_pf_names_nodes.Add(line[0]);
            }

            Assert.True(shared_pf_names_nodes.All(name => shared_pf_names_edges.Contains(name)));
            Assert.True(shared_pf_names_edges.All(name => shared_pf_names_nodes.Contains(name)));
            Assert.AreEqual(9, shared_pf_names_nodes.Count); //both families
        }
        public void community_clear_families()
        {
            SaveState.lollipop = new Lollipop();
            ProteoformCommunity target = construct_two_families_with_potentially_colliding_theoreticals();
            ProteoformCommunity decoy  = construct_two_families_with_potentially_colliding_theoreticals();

            SaveState.lollipop.target_proteoform_community = target;
            SaveState.lollipop.decoy_proteoform_communities.Add(SaveState.lollipop.decoy_community_name_prefix + "0", decoy);
            Assert.IsNotEmpty(SaveState.lollipop.target_proteoform_community.families);
            Assert.True(SaveState.lollipop.target_proteoform_community.experimental_proteoforms.Any(p => p.family != null));
            Assert.IsNotEmpty(SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].families);
            Assert.True(SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].experimental_proteoforms.Any(p => p.family != null));
            SaveState.lollipop.clear_all_families();
            Assert.IsEmpty(SaveState.lollipop.target_proteoform_community.families);
            Assert.True(SaveState.lollipop.target_proteoform_community.experimental_proteoforms.All(p => p.family == null));
            Assert.IsEmpty(SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].families);
            Assert.True(SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].experimental_proteoforms.All(p => p.family == null));
        }
Beispiel #14
0
        public void cytoscape_script_from_subset_of_families()
        {
            Sweet.lollipop = new Lollipop();
            ProteoformCommunity community = TestProteoformFamilies.construct_two_families_with_potentially_colliding_theoreticals();

            Sweet.lollipop.target_proteoform_community = community;
            CytoscapeScript.write_cytoscape_script(new List <ProteoformFamily> {
                community.families[0]
            }, community.families,
                                                   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]);
            string[]         edge_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.edge_file_prefix + "test" + CytoscapeScript.edge_file_extension));
            HashSet <string> shared_pf_names_edges = new HashSet <string>();

            for (int i = 1; i < edge_lines.Length; i++)
            {
                if (edge_lines[i] == "")
                {
                    break;
                }
                string[] line = edge_lines[i].Split(new char[] { '\t' });
                shared_pf_names_edges.Add(line[0]);
                shared_pf_names_edges.Add(line[2]);
            }

            string[]         node_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.node_file_prefix + "test" + CytoscapeScript.node_file_extension));
            HashSet <string> shared_pf_names_nodes = new HashSet <string>();

            for (int i = 1; i < node_lines.Length; i++)
            {
                if (node_lines[i] == "")
                {
                    break;
                }
                string[] line = node_lines[i].Split(new char[] { '\t' });
                shared_pf_names_nodes.Add(line[0]);
            }

            Assert.True(shared_pf_names_nodes.All(name => shared_pf_names_edges.Contains(name)));
            Assert.True(shared_pf_names_edges.All(name => shared_pf_names_nodes.Contains(name)));
            Assert.AreEqual(community.families.First().proteoforms.Count, shared_pf_names_nodes.Count);
        }
        public void cytoscape_script_from_theoreticals()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.gene_centric_families = false;
            ProteoformCommunity community = TestProteoformFamilies.construct_two_families_with_potentially_colliding_theoreticals(false);

            Sweet.lollipop.target_proteoform_community = community;
            CytoscapeScript.write_cytoscape_script(community.families.SelectMany(f => f.theoretical_proteoforms.Where(t => t.ExpandedProteinList.Select(p => p.FullName).Contains(TestProteoformFamilies.p1_fullName))).ToArray(), community.families,
                                                   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]);
            string[]         edge_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.edge_file_prefix + "test" + CytoscapeScript.edge_file_extension));
            HashSet <string> shared_pf_names_edges = new HashSet <string>();

            for (int i = 1; i < edge_lines.Length; i++)
            {
                if (edge_lines[i] == "")
                {
                    break;
                }
                string[] line = edge_lines[i].Split(new char[] { '\t' });
                shared_pf_names_edges.Add(line[0]);
                shared_pf_names_edges.Add(line[2]);
            }

            string[]         node_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.node_file_prefix + "test" + CytoscapeScript.node_file_extension));
            HashSet <string> shared_pf_names_nodes = new HashSet <string>();

            for (int i = 1; i < node_lines.Length; i++)
            {
                if (node_lines[i] == "")
                {
                    break;
                }
                string[] line = node_lines[i].Split(new char[] { '\t' });
                shared_pf_names_nodes.Add(line[0]);
            }

            Assert.True(shared_pf_names_nodes.All(name => shared_pf_names_edges.Contains(name)));
            Assert.True(shared_pf_names_edges.All(name => shared_pf_names_nodes.Contains(name)));
            Assert.AreEqual(5, shared_pf_names_nodes.Count); //only the first family
        }
        public void cytoscape_script_from_gotermnumber()
        {
            ProteoformCommunity community = TestProteoformFamilies.construct_two_families_with_potentially_colliding_theoreticals();

            SaveState.lollipop.target_proteoform_community = community;
            CytoscapeScript.write_cytoscape_script(new GoTermNumber[] { new GoTermNumber(TestProteoformFamilies.p1_goterm, 0, 0, 0, 0) }, community.families,
                                                   TestContext.CurrentContext.TestDirectory, "", "test",
                                                   false, 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]);
            string[]         edge_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.edge_file_prefix + "test" + CytoscapeScript.edge_file_extension));
            HashSet <string> shared_pf_names_edges = new HashSet <string>();

            for (int i = 1; i < edge_lines.Length; i++)
            {
                if (edge_lines[i] == "")
                {
                    break;
                }
                string[] line = edge_lines[i].Split(new char[] { '\t' });
                shared_pf_names_edges.Add(line[0]);
                shared_pf_names_edges.Add(line[2]);
            }

            string[]         node_lines            = File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.node_file_prefix + "test" + CytoscapeScript.node_file_extension));
            HashSet <string> shared_pf_names_nodes = new HashSet <string>();

            for (int i = 1; i < node_lines.Length; i++)
            {
                if (node_lines[i] == "")
                {
                    break;
                }
                string[] line = node_lines[i].Split(new char[] { '\t' });
                shared_pf_names_nodes.Add(line[0]);
            }

            Assert.True(shared_pf_names_nodes.All(name => shared_pf_names_edges.Contains(name)));
            Assert.True(shared_pf_names_edges.All(name => shared_pf_names_nodes.Contains(name)));
            Assert.AreEqual(9, shared_pf_names_nodes.Count); //both families this time because they all have the same stuff...
        }
        public void wrong_relation_shifting()
        {
            ProteoformCommunity test_community = new ProteoformCommunity();

            SaveState.lollipop.target_proteoform_community = test_community;
            ExperimentalProteoform    pf3 = ConstructorsForTesting.ExperimentalProteoform("E1");
            ExperimentalProteoform    pf4 = ConstructorsForTesting.ExperimentalProteoform("E2");
            ProteoformComparison      wrong_comparison = ProteoformComparison.ExperimentalExperimental;
            ProteoformRelation        pr2 = new ProteoformRelation(pf3, pf4, wrong_comparison, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation        pr3 = new ProteoformRelation(pf3, pf4, wrong_comparison, 0, TestContext.CurrentContext.TestDirectory);
            List <ProteoformRelation> prs = new List <ProteoformRelation> {
                pr2, pr3
            };

            foreach (ProteoformRelation pr in prs)
            {
                pr.set_nearby_group(prs, prs.Select(r => r.InstanceId).ToList());
            }
            test_community.accept_deltaMass_peaks(prs, new List <ProteoformRelation>());
            Assert.False(SaveState.lollipop.et_peaks[0].shift_experimental_masses(1, true));
        }
Beispiel #18
0
        public static void accept_peaks_doesnt_crash_with_empty_list()
        {
            ProteoformCommunity c = new ProteoformCommunity();

            Assert.AreEqual(0, c.accept_deltaMass_peaks(new List <ProteoformRelation>(), new List <ProteoformRelation>()).Count);
        }
Beispiel #19
0
        public void shift_et_peak_unlabeled()
        {
            Sweet.lollipop = new Lollipop();
            ProteoformCommunity test_community = new ProteoformCommunity();

            Sweet.lollipop.target_proteoform_community = test_community;
            Sweet.lollipop.neucode_labeled             = false;

            //Make a few experimental proteoforms
            List <IAggregatable>   n1  = TestExperimentalProteoform.generate_neucode_components(100);
            List <IAggregatable>   n2  = TestExperimentalProteoform.generate_neucode_components(200);
            List <IAggregatable>   n3  = TestExperimentalProteoform.generate_neucode_components(200);
            List <IAggregatable>   n4  = TestExperimentalProteoform.generate_neucode_components(200);
            ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("E1");

            pf1.aggregated = n1.Select(n => (n as NeuCodePair).neuCodeLight).ToList <IAggregatable>();
            ExperimentalProteoform pf2 = ConstructorsForTesting.ExperimentalProteoform("E2");

            pf2.aggregated = n2.Select(n => (n as NeuCodePair).neuCodeLight).ToList <IAggregatable>();
            ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("E3");

            pf3.aggregated = n3.Select(n => (n as NeuCodePair).neuCodeLight).ToList <IAggregatable>();
            ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("E4");

            pf4.aggregated = n4.Select(n => (n as NeuCodePair).neuCodeLight).ToList <IAggregatable>();

            Sweet.lollipop.target_proteoform_community.experimental_proteoforms = new List <ExperimentalProteoform> {
                pf1, pf2, pf3, pf4
            }.ToArray();

            //Connect them to theoreticals to form two peaks
            ProteoformComparison      comparison14 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison      comparison25 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison      comparison36 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison      comparison47 = ProteoformComparison.ExperimentalTheoretical;
            TheoreticalProteoform     pf5          = ConstructorsForTesting.make_a_theoretical();
            TheoreticalProteoform     pf6          = ConstructorsForTesting.make_a_theoretical();
            TheoreticalProteoform     pf7          = ConstructorsForTesting.make_a_theoretical();
            TheoreticalProteoform     pf8          = ConstructorsForTesting.make_a_theoretical();
            ProteoformRelation        pr1          = new ProteoformRelation(pf1, pf5, comparison14, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation        pr2          = new ProteoformRelation(pf2, pf6, comparison25, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation        pr3          = new ProteoformRelation(pf3, pf7, comparison36, 1, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation        pr4          = new ProteoformRelation(pf4, pf8, comparison47, 1, TestContext.CurrentContext.TestDirectory);
            List <ProteoformRelation> prs          = new List <ProteoformRelation> {
                pr1, pr2, pr3, pr4
            };

            foreach (ProteoformRelation pr in prs)
            {
                pr.set_nearby_group(prs, prs.Select(r => r.InstanceId).ToList());
            }
            test_community.accept_deltaMass_peaks(prs, new List <ProteoformRelation>());
            Assert.AreEqual(2, Sweet.lollipop.et_peaks.Count);

            //Shift the peaks, which shifts all of the proteoforms
            DeltaMassPeak d2 = Sweet.lollipop.et_peaks[1];

            d2.shift_experimental_masses(-1, false);

            foreach (Component c in pf3.aggregated.Concat(pf4.aggregated).OfType <Component>())
            {
                Assert.AreEqual(-1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.manual_mass_shift);
                Assert.AreEqual(200 - 1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.weighted_monoisotopic_mass);
            }

            Sweet.lollipop.clear_et();
            Assert.AreEqual(0, Sweet.lollipop.et_peaks.Count);

            //don't double shift E if it's in two peaks...
            pr1 = new ProteoformRelation(pf1, pf5, comparison14, 1, TestContext.CurrentContext.TestDirectory);
            pr2 = new ProteoformRelation(pf1, pf6, comparison14, 1, TestContext.CurrentContext.TestDirectory);
            prs = new List <ProteoformRelation> {
                pr1, pr2
            };
            foreach (ProteoformRelation pr in prs)
            {
                pr.set_nearby_group(prs, prs.Select(r => r.InstanceId).ToList());
            }
            test_community.accept_deltaMass_peaks(prs, new List <ProteoformRelation>());
            Assert.AreEqual(1, Sweet.lollipop.et_peaks.Count);

            //Shift the peaks, which shifts all of the proteoforms
            d2 = Sweet.lollipop.et_peaks[0];
            d2.shift_experimental_masses(-1, false);

            foreach (Component c in pf3.aggregated.Concat(pf4.aggregated).OfType <Component>())
            {
                Assert.AreEqual(-1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.manual_mass_shift);
                Assert.AreEqual(200 - 1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.weighted_monoisotopic_mass);
            }
        }
Beispiel #20
0
        public void shift_et_peak_neucode_from_actions()
        {
            Sweet.lollipop = new Lollipop();
            ProteoformCommunity test_community = new ProteoformCommunity();

            Sweet.lollipop.target_proteoform_community = test_community;

            //Make a few experimental proteoforms
            List <IAggregatable>   n1  = TestExperimentalProteoform.generate_neucode_components(100);
            List <IAggregatable>   n2  = TestExperimentalProteoform.generate_neucode_components(100);
            List <IAggregatable>   n3  = TestExperimentalProteoform.generate_neucode_components(200);
            List <IAggregatable>   n4  = TestExperimentalProteoform.generate_neucode_components(200);
            ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("E1");

            pf1.aggregated = n1;
            ExperimentalProteoform pf2 = ConstructorsForTesting.ExperimentalProteoform("E2");

            pf2.aggregated = n2;
            ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("E3");

            pf3.aggregated = n3;
            ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("E4");

            pf4.aggregated = n4;

            Sweet.lollipop.target_proteoform_community.experimental_proteoforms = new List <ExperimentalProteoform> {
                pf1, pf2, pf3, pf4
            }.ToArray();

            //Connect them to theoreticals to form two peaks
            ProteoformComparison      comparison14 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison      comparison25 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison      comparison36 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison      comparison47 = ProteoformComparison.ExperimentalTheoretical;
            TheoreticalProteoform     pf5          = ConstructorsForTesting.make_a_theoretical();
            TheoreticalProteoform     pf6          = ConstructorsForTesting.make_a_theoretical();
            TheoreticalProteoform     pf7          = ConstructorsForTesting.make_a_theoretical();
            TheoreticalProteoform     pf8          = ConstructorsForTesting.make_a_theoretical();
            ProteoformRelation        pr1          = new ProteoformRelation(pf1, pf5, comparison14, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation        pr2          = new ProteoformRelation(pf2, pf6, comparison25, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation        pr3          = new ProteoformRelation(pf3, pf7, comparison36, 1, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation        pr4          = new ProteoformRelation(pf4, pf8, comparison47, 1, TestContext.CurrentContext.TestDirectory);
            List <ProteoformRelation> prs          = new List <ProteoformRelation> {
                pr1, pr2, pr3, pr4
            };

            foreach (ProteoformRelation pr in prs)
            {
                pr.set_nearby_group(prs, prs.Select(r => r.InstanceId).ToList());
            }
            test_community.accept_deltaMass_peaks(prs, new List <ProteoformRelation>());
            Assert.AreEqual(2, Sweet.lollipop.et_peaks.Count);

            //Shift the peaks, which shifts all of the proteoforms
            DeltaMassPeak d2 = Sweet.lollipop.et_peaks[1];

            d2.mass_shifter = "-1";
            Sweet.shift_peak_action(d2);
            d2.mass_shifter = null;
            using (StreamWriter file = new StreamWriter(Path.Combine(TestContext.CurrentContext.TestDirectory, "method.xml")))
                file.WriteLine(Sweet.save_method());
            Sweet.open_method(Path.Combine(TestContext.CurrentContext.TestDirectory, "method.xml"), string.Join(Environment.NewLine, File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, "method.xml"))), true, out string warning);
            Sweet.mass_shifts_from_presets();
            d2.shift_experimental_masses(Convert.ToInt32(d2.mass_shifter), true);

            foreach (Component c in
                     n3.OfType <NeuCodePair>().Select(n => n.neuCodeLight).
                     Concat(n4.OfType <NeuCodePair>().Select(n => n.neuCodeLight)))
            {
                Assert.AreEqual(-1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.manual_mass_shift);
                Assert.AreEqual(200 - 1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.weighted_monoisotopic_mass);
            }

            foreach (Component c in
                     n3.OfType <NeuCodePair>().Select(n => n.neuCodeHeavy).
                     Concat(n4.OfType <NeuCodePair>().Select(n => n.neuCodeHeavy)))
            {
                Assert.AreEqual(-1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.manual_mass_shift);
                Assert.AreEqual(200 + TestExperimentalProteoform.starter_lysine_count * Lollipop.NEUCODE_LYSINE_MASS_SHIFT - 1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.weighted_monoisotopic_mass);
            }
        }
Beispiel #21
0
        public void TestAcceptDeltaMassPeaks()
        {
            Sweet.lollipop = new Lollipop();
            ProteoformCommunity test_community = new ProteoformCommunity();

            Sweet.lollipop.target_proteoform_community = test_community;

            Sweet.lollipop.theoretical_database.uniprotModifications = new Dictionary <string, List <Modification> >
            {
                { "unmodified", new List <Modification>()
                  {
                      ConstructorsForTesting.get_modWithMass("unmodified", 0)
                  } }
            };

            //Testing the acceptance of peaks. The FDR is tested above, so I'm not going to work with that here.
            //Four proteoforms, three relations (linear), middle one isn't accepted; should give 2 families
            Sweet.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");

            ProteoformComparison comparison34 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison45 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison56 = ProteoformComparison.ExperimentalExperimental;
            ProteoformRelation   pr2          = new ProteoformRelation(pf3, pf4, comparison34, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation   pr3          = new ProteoformRelation(pf4, pf5, comparison45, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation   pr4          = new ProteoformRelation(pf5, pf6, comparison56, 0, TestContext.CurrentContext.TestDirectory);

            //Test display strings
            Assert.AreEqual("E1", pr2.connected_proteoforms[0].accession);
            Assert.AreEqual("E2", pr2.connected_proteoforms[1].accession);
            pr2.RelationType = ProteoformComparison.ExperimentalExperimental;
            pr2.RelationType = ProteoformComparison.ExperimentalTheoretical;
            pr2.RelationType = ProteoformComparison.ExperimentalDecoy;
            pr2.RelationType = ProteoformComparison.ExperimentalFalse;
            pr2.RelationType = comparison34;

            List <ProteoformRelation> prs2 = new List <ProteoformRelation> {
                pr2, pr3, pr4
            };

            foreach (ProteoformRelation pr in prs2)
            {
                pr.set_nearby_group(prs2, prs2.Select(r => r.InstanceId).ToList());
            }
            Assert.AreEqual(3, pr2.nearby_relations_count);
            Assert.AreEqual(3, pr3.nearby_relations_count);
            Assert.AreEqual(3, pr4.nearby_relations_count);

            Sweet.lollipop.theoretical_database.all_possible_ptmsets = new List <PtmSet> {
                new PtmSet(new List <Ptm> {
                    new Ptm(-1, ConstructorsForTesting.get_modWithMass("unmodified", 0))
                })
            };
            Sweet.lollipop.theoretical_database.possible_ptmset_dictionary = Sweet.lollipop.theoretical_database.make_ptmset_dictionary();
            //auto accept set to false
            Sweet.lollipop.ee_accept_peaks_based_on_rank = false;
            Sweet.lollipop.ee_peaks = test_community.accept_deltaMass_peaks(prs2, new List <ProteoformRelation>());
            Assert.AreEqual(1, Sweet.lollipop.ee_peaks.Count);
            DeltaMassPeak peak = Sweet.lollipop.ee_peaks[0];

            Assert.IsTrue(peak.Accepted);
            Assert.AreEqual(3, peak.grouped_relations.Count);
            Assert.AreEqual(3, pr2.peak.peak_relation_group_count);
            Assert.AreEqual(0, pr2.peak.DeltaMass);
            Assert.AreEqual("[unmodified]", peak.possiblePeakAssignments_string);

            //Test that the relations in the peak are added to each of the proteoforms referenced in the peak
            Assert.True(pf3.relationships.Contains(pr2));
            Assert.True(pf4.relationships.Contains(pr2) && pf4.relationships.Contains(pr3));
            Assert.True(pf5.relationships.Contains(pr3) && pf5.relationships.Contains(pr4));

            //autoaccept set to true, must be less than first quartile rank...
            Sweet.lollipop.clear_ee();
            Sweet.lollipop.mod_rank_first_quartile       = 0;
            Sweet.lollipop.ee_accept_peaks_based_on_rank = true;
            Sweet.lollipop.ee_peaks = test_community.accept_deltaMass_peaks(prs2, new List <ProteoformRelation>());
            peak = Sweet.lollipop.ee_peaks[0];
            Assert.IsFalse(peak.Accepted);
            Assert.AreEqual(0, peak.possiblePeakAssignments.Min(p => p.ptm_rank_sum));

            Sweet.lollipop.clear_ee();
            Sweet.lollipop.mod_rank_first_quartile       = 1;
            Sweet.lollipop.ee_accept_peaks_based_on_rank = true;
            Sweet.lollipop.ee_peaks = test_community.accept_deltaMass_peaks(prs2, new List <ProteoformRelation>());
            peak = Sweet.lollipop.ee_peaks[0];
            Assert.IsTrue(peak.Accepted);
            Assert.AreEqual(0, peak.possiblePeakAssignments.Min(p => p.ptm_rank_sum));
        }
        public void test_construct_two_families()
        {
            //Five experimental proteoforms, four relations (linear), second on not accepted into a peak, one peak; should give 2 families
            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.ee_max_mass_difference = 20;
            SaveState.lollipop.peak_width_base_ee     = 0.015;
            SaveState.lollipop.min_peak_count_ee      = 3; //needs to be high so that 0 peak accepted, other peak isn't....

            ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("E1");
            ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("E2");
            ExperimentalProteoform pf5 = ConstructorsForTesting.ExperimentalProteoform("E3");
            ExperimentalProteoform pf6 = ConstructorsForTesting.ExperimentalProteoform("E4");
            ExperimentalProteoform pf7 = ConstructorsForTesting.ExperimentalProteoform("E5");

            ProteoformComparison comparison34 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison45 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison56 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison67 = ProteoformComparison.ExperimentalExperimental;
            ProteoformRelation   pr2          = new ProteoformRelation(pf3, pf4, comparison34, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation   pr3          = new ProteoformRelation(pf4, pf5, comparison45, 19, TestContext.CurrentContext.TestDirectory); //not accepted
            ProteoformRelation   pr4          = new ProteoformRelation(pf5, pf6, comparison56, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation   pr5          = new ProteoformRelation(pf6, pf7, comparison67, 0, TestContext.CurrentContext.TestDirectory);

            List <ProteoformRelation> prs2 = new List <ProteoformRelation> {
                pr2, pr3, pr4, pr5
            }.OrderBy(r => r.DeltaMass).ToList();

            foreach (ProteoformRelation pr in prs2)
            {
                pr.set_nearby_group(prs2, prs2.Select(r => r.InstanceId).ToList());
            }
            Assert.AreEqual(3, pr2.nearby_relations_count);
            Assert.AreEqual(1, pr3.nearby_relations_count);
            Assert.AreEqual(3, pr4.nearby_relations_count);
            Assert.AreEqual(3, pr5.nearby_relations_count);

            test_community.accept_deltaMass_peaks(prs2, new List <ProteoformRelation>());
            Assert.AreEqual(2, SaveState.lollipop.ee_peaks.Count);
            Assert.AreEqual(1, SaveState.lollipop.ee_peaks.Where(peak => peak.Accepted).Count());
            Assert.AreEqual(3, SaveState.lollipop.ee_peaks.Where(peak => peak.Accepted).First().grouped_relations.Count());

            test_community.experimental_proteoforms = new ExperimentalProteoform[] { pf3, pf4, pf5, pf6, pf7 };
            test_community.construct_families();
            Assert.AreEqual(2, test_community.families.Count);
            Assert.AreEqual("", test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf3)).accession_list);
            Assert.AreEqual(2, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf3)).proteoforms.Count);
            Assert.AreEqual(2, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf3)).experimental_proteoforms.Count);
            Assert.AreEqual(0, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf3)).theoretical_proteoforms.Count);
            Assert.AreEqual("", test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf5)).accession_list);
            Assert.AreEqual(3, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf5)).proteoforms.Count);
            Assert.AreEqual(3, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf5)).experimental_proteoforms.Count);
            Assert.AreEqual(0, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf5)).theoretical_proteoforms.Count);
        }
        public void test_accept_from_presets()
        {
            Sweet.lollipop = new Lollipop();
            ProteoformCommunity test_community = new ProteoformCommunity();

            Sweet.lollipop.target_proteoform_community = test_community;

            Sweet.lollipop.theoretical_database.uniprotModifications = new Dictionary <string, List <Modification> >
            {
                { "unmodified", new List <Modification>()
                  {
                      ConstructorsForTesting.get_modWithMass("unmodified", 0)
                  } }
            };

            //Testing the acceptance of peaks. The FDR is tested above, so I'm not going to work with that here.
            //Four proteoforms, three relations (linear), middle one isn't accepted; should give 2 families
            Sweet.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");

            ProteoformComparison comparison34 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison45 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison56 = ProteoformComparison.ExperimentalExperimental;
            ProteoformRelation   pr2          = new ProteoformRelation(pf3, pf4, comparison34, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation   pr3          = new ProteoformRelation(pf4, pf5, comparison45, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation   pr4          = new ProteoformRelation(pf5, pf6, comparison56, 0, TestContext.CurrentContext.TestDirectory);

            //Test display strings
            Assert.AreEqual("E1", pr2.connected_proteoforms[0].accession);
            Assert.AreEqual("E2", pr2.connected_proteoforms[1].accession);

            List <ProteoformRelation> prs2 = new List <ProteoformRelation> {
                pr2, pr3, pr4
            };

            foreach (ProteoformRelation pr in prs2)
            {
                pr.set_nearby_group(prs2, prs2.Select(r => r.InstanceId).ToList());
            }
            Assert.AreEqual(3, pr2.nearby_relations_count);
            Assert.AreEqual(3, pr3.nearby_relations_count);
            Assert.AreEqual(3, pr4.nearby_relations_count);

            Sweet.lollipop.theoretical_database.all_possible_ptmsets = new List <PtmSet> {
                new PtmSet(new List <Ptm> {
                    new Ptm(-1, ConstructorsForTesting.get_modWithMass("unmodified", 0))
                })
            };
            Sweet.lollipop.theoretical_database.possible_ptmset_dictionary = Sweet.lollipop.theoretical_database.make_ptmset_dictionary();
            Sweet.unaccept_peak_action(pr2);
            using (StreamWriter file = new StreamWriter(Path.Combine(TestContext.CurrentContext.TestDirectory, "method.xml")))
                file.WriteLine(Sweet.save_method());
            Sweet.open_method(Path.Combine(TestContext.CurrentContext.TestDirectory, "method.xml"), string.Join(Environment.NewLine, File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, "method.xml"))), true, out string warning);
            Sweet.lollipop.ee_peaks = test_community.accept_deltaMass_peaks(prs2, new List <ProteoformRelation>());
            Assert.AreEqual(1, Sweet.lollipop.ee_peaks.Count);
            DeltaMassPeak peak = Sweet.lollipop.ee_peaks[0];

            Assert.IsFalse(peak.Accepted); // <-- even though it's above the threshold
            Assert.AreEqual(3, peak.grouped_relations.Count);
            Assert.AreEqual(3, pr2.peak.peak_relation_group_count);
            Assert.AreEqual(0, pr2.peak.DeltaMass);
            Assert.AreEqual("[unmodified]", peak.possiblePeakAssignments_string);

            //Test that the relations in the peak are added to each of the proteoforms referenced in the peak
            Assert.True(pf3.relationships.Contains(pr2));
            Assert.True(pf4.relationships.Contains(pr2) && pf4.relationships.Contains(pr3));
            Assert.True(pf5.relationships.Contains(pr3) && pf5.relationships.Contains(pr4));
        }
        public void shift_et_peak_neucode()
        {
            SaveState.lollipop = new Lollipop();
            ProteoformCommunity test_community = new ProteoformCommunity();

            SaveState.lollipop.target_proteoform_community = test_community;

            //Make a few experimental proteoforms
            List <Component>       n1  = TestExperimentalProteoform.generate_neucode_components(100);
            List <Component>       n2  = TestExperimentalProteoform.generate_neucode_components(100);
            List <Component>       n3  = TestExperimentalProteoform.generate_neucode_components(200);
            List <Component>       n4  = TestExperimentalProteoform.generate_neucode_components(200);
            ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("E1");

            pf1.aggregated_components = n1;
            ExperimentalProteoform pf2 = ConstructorsForTesting.ExperimentalProteoform("E2");

            pf2.aggregated_components = n2;
            ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("E3");

            pf3.aggregated_components = n3;
            ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("E4");

            pf4.aggregated_components = n4;

            SaveState.lollipop.target_proteoform_community.experimental_proteoforms = new List <ExperimentalProteoform> {
                pf1, pf2, pf3, pf4
            }.ToArray();

            //Connect them to theoreticals to form two peaks
            ProteoformComparison      comparison14 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison      comparison25 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison      comparison36 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison      comparison47 = ProteoformComparison.ExperimentalTheoretical;
            TheoreticalProteoform     pf5          = ConstructorsForTesting.make_a_theoretical();
            TheoreticalProteoform     pf6          = ConstructorsForTesting.make_a_theoretical();
            TheoreticalProteoform     pf7          = ConstructorsForTesting.make_a_theoretical();
            TheoreticalProteoform     pf8          = ConstructorsForTesting.make_a_theoretical();
            ProteoformRelation        pr1          = new ProteoformRelation(pf1, pf5, comparison14, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation        pr2          = new ProteoformRelation(pf2, pf6, comparison25, 0, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation        pr3          = new ProteoformRelation(pf3, pf7, comparison36, 1, TestContext.CurrentContext.TestDirectory);
            ProteoformRelation        pr4          = new ProteoformRelation(pf4, pf8, comparison47, 1, TestContext.CurrentContext.TestDirectory);
            List <ProteoformRelation> prs          = new List <ProteoformRelation> {
                pr1, pr2, pr3, pr4
            };

            foreach (ProteoformRelation pr in prs)
            {
                pr.set_nearby_group(prs, prs.Select(r => r.InstanceId).ToList());
            }
            test_community.accept_deltaMass_peaks(prs, new List <ProteoformRelation>());
            Assert.AreEqual(2, SaveState.lollipop.et_peaks.Count);

            //Shift the peaks, which shifts all of the proteoforms
            DeltaMassPeak d2 = SaveState.lollipop.et_peaks[1];

            d2.shift_experimental_masses(-1, true);

            Assert.IsTrue(pf3.mass_shifted);
            Assert.IsTrue(pf4.mass_shifted);
            foreach (Component c in
                     n3.
                     Concat(n4).
                     Concat(n3.Select(n => ((NeuCodePair)n).neuCodeLight)).
                     Concat(n4.Select(n => ((NeuCodePair)n).neuCodeLight)))
            {
                Assert.AreEqual(-1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.manual_mass_shift);
                Assert.AreEqual(200 - 1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.weighted_monoisotopic_mass);
            }

            foreach (Component c in
                     n3.Select(n => ((NeuCodePair)n).neuCodeHeavy).
                     Concat(n4.Select(n => ((NeuCodePair)n).neuCodeHeavy)))
            {
                Assert.AreEqual(-1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.manual_mass_shift);
                Assert.AreEqual(200 + TestExperimentalProteoform.starter_lysine_count * Lollipop.NEUCODE_LYSINE_MASS_SHIFT - 1.0 * Lollipop.MONOISOTOPIC_UNIT_MASS, c.weighted_monoisotopic_mass);
            }
        }
        public static ProteoformCommunity construct_two_families_with_potentially_colliding_theoreticals()
        {
            //Five experimental proteoforms, four relations (linear), second on not accepted into a peak, one peak; should give 2 families
            ProteoformCommunity community = new ProteoformCommunity();

            SaveState.lollipop = new Lollipop();
            SaveState.lollipop.target_proteoform_community = community;
            SaveState.lollipop.theoretical_database.uniprotModifications = new Dictionary <string, List <Modification> >
            {
                { "unmodified", new List <Modification> {
                      ConstructorsForTesting.get_modWithMass("unmodified", 0)
                  } },
                { "fake", new List <Modification> {
                      ConstructorsForTesting.get_modWithMass("fake", 19)
                  } },
            };

            SaveState.lollipop.modification_ranks = new Dictionary <double, int> {
                { 0, 1 }, { 19, 2 }
            };
            SaveState.lollipop.mod_rank_sum_threshold = 2;
            SaveState.lollipop.theoretical_database.all_possible_ptmsets       = PtmCombos.generate_all_ptmsets(1, SaveState.lollipop.theoretical_database.uniprotModifications.SelectMany(kv => kv.Value).OfType <ModificationWithMass>().ToList(), SaveState.lollipop.modification_ranks, 1);
            SaveState.lollipop.theoretical_database.all_mods_with_mass         = SaveState.lollipop.theoretical_database.uniprotModifications.SelectMany(kv => kv.Value).OfType <ModificationWithMass>().ToList();
            SaveState.lollipop.theoretical_database.possible_ptmset_dictionary = SaveState.lollipop.theoretical_database.make_ptmset_dictionary();

            SaveState.lollipop.ee_max_mass_difference = 20;
            SaveState.lollipop.peak_width_base_ee     = 0.015;
            SaveState.lollipop.min_peak_count_ee      = 3; //needs to be high so that 0 peak accepted, other peak isn't....
            SaveState.lollipop.min_peak_count_et      = 2; //needs to be lower so the 2 ET relations are accepted

            //TheoreticalProteoformGroup
            InputFile          f  = new InputFile("fake.txt", Purpose.ProteinDatabase);
            ProteinWithGoTerms p1 = new ProteinWithGoTerms("", p1_accession, new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new int?[] { 0 }, new int?[] { 0 }, new string[] { "" }, p1_name, p1_fullName, true, false, new List <DatabaseReference> {
                p1_dbRef
            }, new List <GoTerm> {
                p1_goterm
            });
            Dictionary <InputFile, Protein[]> dict = new Dictionary <InputFile, Protein[]> {
                { f, new Protein[] { p1 } }
            };
            TheoreticalProteoform      t   = ConstructorsForTesting.make_a_theoretical("T1_asdf", "T1_asdf", 1234.56, p1, dict);
            TheoreticalProteoformGroup pf1 = new TheoreticalProteoformGroup(new List <TheoreticalProteoform> {
                t
            });
            TheoreticalProteoform pf2 = ConstructorsForTesting.make_a_theoretical("T1_asdf_pf2", "T1_asdf_1", 1234.56, dict);


            //ExperimentalProteoforms
            ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("E1", 0, 0, true);
            ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("E2", 0, 0, true);
            ExperimentalProteoform pf5 = ConstructorsForTesting.ExperimentalProteoform("E3", 0, 0, true);
            ExperimentalProteoform pf6 = ConstructorsForTesting.ExperimentalProteoform("E4", 0, 0, true);
            ExperimentalProteoform pf7 = ConstructorsForTesting.ExperimentalProteoform("E5", 0, 0, true);
            ExperimentalProteoform pf8 = ConstructorsForTesting.ExperimentalProteoform("E6", 0, 0, true);
            TheoreticalProteoform  pf9 = ConstructorsForTesting.make_a_theoretical("T1_asdf_pf9", "T1_asdf_1", 1253.56, dict);

            community.theoretical_proteoforms  = new TheoreticalProteoform[] { pf1, pf2, pf9 };
            community.experimental_proteoforms = new ExperimentalProteoform[] { pf3, pf4, pf5, pf6, pf7, pf8 };
            pf3.agg_mass = 1234.56;
            pf4.agg_mass = 1234.56;
            pf5.agg_mass = 1234.56;
            pf6.agg_mass = 1253.56;
            pf7.agg_mass = 1253.56;
            pf8.agg_mass = 1253.56;

            ProteoformComparison comparison13 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison comparison23 = ProteoformComparison.ExperimentalTheoretical;
            ProteoformComparison comparison34 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison45 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison56 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison67 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison78 = ProteoformComparison.ExperimentalExperimental;
            ProteoformComparison comparison89 = ProteoformComparison.ExperimentalTheoretical;

            ConstructorsForTesting.make_relation(pf3, pf1, comparison13, 0);
            ConstructorsForTesting.make_relation(pf3, pf2, comparison23, 0);
            ConstructorsForTesting.make_relation(pf3, pf4, comparison34, 0);
            ConstructorsForTesting.make_relation(pf4, pf5, comparison45, 0);
            ConstructorsForTesting.make_relation(pf5, pf6, comparison56, 19); //not accepted
            ConstructorsForTesting.make_relation(pf6, pf7, comparison67, 0);
            ConstructorsForTesting.make_relation(pf7, pf8, comparison78, 0);
            ConstructorsForTesting.make_relation(pf8, pf9, comparison89, 0);

            List <ProteoformRelation> prs = new HashSet <ProteoformRelation>(community.experimental_proteoforms.SelectMany(p => p.relationships).Concat(community.theoretical_proteoforms.SelectMany(p => p.relationships))).ToList();

            foreach (Proteoform p in prs.SelectMany(r => r.connected_proteoforms))
            {
                Assert.IsNotNull(p);
            }
            List <ProteoformRelation> prs_et = prs.Where(r => r.RelationType == ProteoformComparison.ExperimentalTheoretical).OrderBy(r => r.DeltaMass).ToList();

            SaveState.lollipop.et_relations = prs_et;
            List <ProteoformRelation> prs_ee = prs.Where(r => r.RelationType == ProteoformComparison.ExperimentalExperimental).OrderBy(r => r.DeltaMass).ToList();

            SaveState.lollipop.ee_relations = prs_ee;
            foreach (ProteoformRelation pr in prs_et)
            {
                pr.set_nearby_group(prs_et, prs_et.Select(r => r.InstanceId).ToList());
            }
            foreach (ProteoformRelation pr in prs_ee)
            {
                pr.set_nearby_group(prs_ee, prs_ee.Select(r => r.InstanceId).ToList());
            }
            Assert.AreEqual(3, pf1.relationships.First().nearby_relations_count); // 2 ET relations at 0 delta mass
            Assert.AreEqual(3, pf2.relationships.First().nearby_relations_count);
            Assert.AreEqual(4, pf4.relationships.First().nearby_relations_count); // 4 EE relations at 0 delta mass
            Assert.AreEqual(4, pf5.relationships.First().nearby_relations_count);
            Assert.AreEqual(1, pf6.relationships.First().nearby_relations_count); // 1 EE relation at 19 delta mass
            Assert.AreEqual(4, pf7.relationships.First().nearby_relations_count);
            Assert.AreEqual(4, pf8.relationships.First().nearby_relations_count);

            community.accept_deltaMass_peaks(prs_et, new List <ProteoformRelation>());
            community.accept_deltaMass_peaks(prs_ee, new List <ProteoformRelation>());
            Assert.AreEqual(3, SaveState.lollipop.et_peaks.Count + SaveState.lollipop.ee_peaks.Count);
            Assert.AreEqual(1, SaveState.lollipop.et_peaks.Where(peak => peak.Accepted).Count()); // 1 ET peak
            Assert.AreEqual(1, SaveState.lollipop.ee_peaks.Where(peak => peak.Accepted).Count()); // 1 EE peak accepted
            Assert.AreEqual(4, SaveState.lollipop.ee_peaks.Where(peak => peak.Accepted && peak.RelationType == ProteoformComparison.ExperimentalExperimental).First().grouped_relations.Count());
            Assert.AreEqual(3, SaveState.lollipop.et_peaks.Where(peak => peak.Accepted && peak.RelationType == ProteoformComparison.ExperimentalTheoretical).First().grouped_relations.Count());

            community.construct_families();

            //Testing the identification of experimentals
            //test with a modificationwithmass that's 0 mass, and then see that it crawls around and labels them each with growing ptm sets with that modification
            //test that the relation.represented_modification gets set
            Assert.True(SaveState.lollipop.et_relations.All(r => r.peak.DeltaMass != 19 || r.represented_ptmset == null));
            Assert.True(SaveState.lollipop.et_relations.All(r => r.peak.DeltaMass != 0 || r.represented_ptmset.ptm_combination.First().modification.id == "unmodified"));
            Assert.True(pf1 == pf3.linked_proteoform_references.First() || pf2 == pf3.linked_proteoform_references.First());

            //test I don't get re-reassignments
            Assert.AreEqual(pf3, pf4.linked_proteoform_references.Last()); //test that the proteoform.theoretical_reference gets set to each successive PF base
            Assert.AreEqual((pf3.linked_proteoform_references.First() as TheoreticalProteoform).accession, (pf4.linked_proteoform_references.First() as TheoreticalProteoform).accession);
            Assert.AreEqual((pf3.linked_proteoform_references.First() as TheoreticalProteoform).fragment, (pf4.linked_proteoform_references.First() as TheoreticalProteoform).fragment);
            Assert.AreEqual(pf4, pf5.linked_proteoform_references.Last());
            Assert.AreEqual((pf3.linked_proteoform_references.First() as TheoreticalProteoform).accession, (pf5.linked_proteoform_references.First() as TheoreticalProteoform).accession); //test that the accession gets carried all the way through the depth of connections
            Assert.AreEqual((pf3.linked_proteoform_references.First() as TheoreticalProteoform).fragment, (pf5.linked_proteoform_references.First() as TheoreticalProteoform).fragment);
            Assert.AreEqual(pf9, pf8.linked_proteoform_references.Last());

            return(community);
        }