Exemplo n.º 1
0
        public void test_contaminant_check()
        {
            InputFile f = new InputFile("fake.txt", Purpose.ProteinDatabase);

            f.ContaminantDB = true;
            InputFile          g  = new InputFile("fake.txt", Purpose.ProteinDatabase);
            InputFile          h  = 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[] { "" }, "T2", "T3", true, false, new List <DatabaseReference>(), new List <GoTerm>());
            ProteinWithGoTerms p2 = new ProteinWithGoTerms("", "T2", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new int?[] { 0 }, new int?[] { 0 }, new string[] { "" }, "T2", "T3", true, false, new List <DatabaseReference>(), new List <GoTerm>());
            ProteinWithGoTerms p3 = new ProteinWithGoTerms("", "T3", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new int?[] { 0 }, new int?[] { 0 }, new string[] { "" }, "T2", "T3", true, false, new List <DatabaseReference>(), new List <GoTerm>());
            Dictionary <InputFile, Protein[]> dict = new Dictionary <InputFile, Protein[]> {
                { f, new Protein[] { p1 } },
                { g, new Protein[] { p2 } },
                { h, new Protein[] { p3 } },
            };
            TheoreticalProteoform t = ConstructorsForTesting.make_a_theoretical("T1_T1_asdf", p1, dict);
            TheoreticalProteoform u = ConstructorsForTesting.make_a_theoretical("T2_T1_asdf_asdf", p2, dict);
            TheoreticalProteoform v = ConstructorsForTesting.make_a_theoretical("T3_T1_asdf_Asdf_Asdf", p3, dict);
            TheoreticalProteoform w = new TheoreticalProteoformGroup(new List <TheoreticalProteoform> {
                v, u, t
            }.OrderByDescending(theo => theo.contaminant ? 1 : 0));

            Assert.True(w.contaminant);
            Assert.True(w.accession.Contains(p1.Accession));

            //Not contaminant
            TheoreticalProteoform x = new TheoreticalProteoformGroup(new List <TheoreticalProteoform> {
                v, u
            });

            Assert.False(x.contaminant);

            //PTM mass test
            Assert.AreEqual(0, t.ptm_mass);
        }
Exemplo n.º 2
0
        public void nodes_table_gives_meaningful_modified_theoreticals2()
        {
            ModificationMotif motif;

            ModificationMotif.TryGetMotif("K", out motif);
            Modification m = new Modification("id", _modificationType: "modtype", _target: motif, _locationRestriction: "Anywhere.", _monoisotopicMass: 1);

            Proteoform       p = ConstructorsForTesting.make_a_theoretical();
            ProteoformFamily f = new ProteoformFamily(p);

            f.construct_family();
            string node_table = CytoscapeScript.get_cytoscape_nodes_tsv(new List <ProteoformFamily> {
                f
            },
                                                                        null,
                                                                        CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], Lollipop.node_positioning[0], 2,
                                                                        f.theoretical_proteoforms, false, Lollipop.gene_name_labels[1]);

            Assert.True(node_table.Contains(CytoscapeScript.modified_theoretical_label));
            Assert.AreNotEqual(f.theoretical_proteoforms[0].accession, CytoscapeScript.get_proteoform_shared_name(p, Lollipop.node_labels[0], 2));
        }
        public void aggregate_out_of_middle_monoisotopic_tolerance()
        {
            missed_monoisotopics -= 1;
            Sweet.lollipop.set_missed_monoisotopic_range();
            double max_monoisotopic_mass = starter_mass + missed_monoisotopics * Lollipop.MONOISOTOPIC_UNIT_MASS;
            double min_monoisotopic_mass = starter_mass - missed_monoisotopics * Lollipop.MONOISOTOPIC_UNIT_MASS;

            Sweet.lollipop.neucode_labeled = true;
            List <IAggregatable> components = generate_neucode_components(starter_mass);

            // below lowest monoisotopic tolerance
            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(Sweet.lollipop.mass_tolerance) - Double.MinValue);
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);

            Assert.AreEqual(1, e.aggregated.Count);
            // above highest monoisotopic tolerance
            components[1].weighted_monoisotopic_mass = (max_monoisotopic_mass + max_monoisotopic_mass / 1000000 * Convert.ToDouble(Sweet.lollipop.mass_tolerance) + Double.MinValue);
            e = ConstructorsForTesting.ExperimentalProteoform("E1", components[0], components, empty_quant_components_list, true);
            Assert.AreEqual(1, e.aggregated.Count);
        }
        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));
        }
        public void nodes_table_gives_meaningful_modified_theoreticals2()
        {
            ModificationMotif motif;

            ModificationMotif.TryGetMotif("K", out motif);
            ModificationWithMass m = new ModificationWithMass("oxidation", new Tuple <string, string>("", ""), motif, ModificationSites.K, 1, new Dictionary <string, IList <string> >(), new List <double>(), new List <double>(), "");

            Proteoform       p = ConstructorsForTesting.make_a_theoretical();
            ProteoformFamily f = new ProteoformFamily(p);

            f.construct_family();
            string node_table = CytoscapeScript.get_cytoscape_nodes_tsv(new List <ProteoformFamily> {
                f
            },
                                                                        false,
                                                                        CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], Lollipop.node_positioning[0], 2,
                                                                        f.theoretical_proteoforms, false, Lollipop.gene_name_labels[1]);

            Assert.True(node_table.Contains(CytoscapeScript.modified_theoretical_label));
            Assert.AreNotEqual(f.theoretical_proteoforms[0].accession, CytoscapeScript.get_proteoform_shared_name(p, Lollipop.node_labels[0], 2));
        }
Exemplo n.º 6
0
        public void test_same_ptmset()
        {
            PtmSet set1 = new PtmSet(new List <Ptm>()
            {
                new Ptm(1, ConstructorsForTesting.get_modWithMass("id1", 5)),
                new Ptm(2, ConstructorsForTesting.get_modWithMass("id2", 6)),
                new Ptm(2, ConstructorsForTesting.get_modWithMass("id4", 6))
            });
            PtmSet set2 = new PtmSet(new List <Ptm>()
            {
                new Ptm(1, ConstructorsForTesting.get_modWithMass("id1", 5)),
                new Ptm(2, ConstructorsForTesting.get_modWithMass("id2", 6)),
                new Ptm(2, ConstructorsForTesting.get_modWithMass("id4", 6))
            });

            Assert.IsTrue(set1.same_ptmset(set2, true));
            Assert.IsTrue(set1.same_ptmset(set2, false));
            set2 = new PtmSet(new List <Ptm>()
            {
                new Ptm(1, ConstructorsForTesting.get_modWithMass("id1", 5)),
                new Ptm(2, ConstructorsForTesting.get_modWithMass("id2", 6)),
                new Ptm(2, ConstructorsForTesting.get_modWithMass("id3", 6))
            });
            Assert.IsFalse(set1.same_ptmset(set2, true));
            Assert.IsFalse(set1.same_ptmset(set2, false));
            Assert.IsFalse(set2.same_ptmset(set1, true));
            Assert.IsFalse(set2.same_ptmset(set1, false));

            set2 = new PtmSet(new List <Ptm>()
            {
                new Ptm(1, ConstructorsForTesting.get_modWithMass("id1", 5)),
                new Ptm(2, ConstructorsForTesting.get_modWithMass("id2", 6)),
            });
            Assert.IsFalse(set1.same_ptmset(set2, true));
            Assert.IsFalse(set1.same_ptmset(set2, false));
            Assert.IsFalse(set2.same_ptmset(set1, true));
            Assert.IsFalse(set2.same_ptmset(set1, false));
        }
        public void unlabeled_agg()
        {
            SaveState.lollipop.min_num_bioreps = 0;
            double max_monoisotopic_mass = TestExperimentalProteoform.starter_mass + TestExperimentalProteoform.missed_monoisotopics * Lollipop.MONOISOTOPIC_UNIT_MASS;
            double min_monoisotopic_mass = TestExperimentalProteoform.starter_mass - TestExperimentalProteoform.missed_monoisotopics * Lollipop.MONOISOTOPIC_UNIT_MASS;

            List <Component> components = TestExperimentalProteoform.generate_unlabeled_components(TestExperimentalProteoform.starter_mass);

            SaveState.lollipop.neucode_labeled      = false;
            SaveState.lollipop.remaining_components = new List <Component>(components);
            SaveState.lollipop.remaining_verification_components = new List <Component>(components);
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E");

            e.root = components[0];
            e.aggregate();
            e.verify();

            Assert.AreEqual(2, e.aggregated_components.Count);
            Assert.AreEqual(2, e.lt_verification_components.Count);
            Assert.AreEqual(0, e.hv_verification_components.Count); // everything goes into light with unlabeled
            Assert.AreEqual(0, e.lt_quant_components.Count);        // no quantitation for unlabeled, yet
            Assert.AreEqual(0, e.hv_quant_components.Count);
        }
Exemplo n.º 8
0
        public void cytoscape_improper_build_folder()
        {
            TheoreticalProteoform  t  = ConstructorsForTesting.make_a_theoretical();
            ExperimentalProteoform e  = ConstructorsForTesting.ExperimentalProteoform("E1");
            ProteoformRelation     et = new ProteoformRelation(e, t, ProteoformComparison.ExperimentalTheoretical, 0, TestContext.CurrentContext.TestDirectory);

            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,
                                                                    "", "", "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.False(message.StartsWith("Finished"));
        }
        public void unlabeled_agg()
        {
            double max_monoisotopic_mass = TestExperimentalProteoform.starter_mass + TestExperimentalProteoform.missed_monoisotopics * Lollipop.MONOISOTOPIC_UNIT_MASS;
            double min_monoisotopic_mass = TestExperimentalProteoform.starter_mass - TestExperimentalProteoform.missed_monoisotopics * Lollipop.MONOISOTOPIC_UNIT_MASS;

            List <IAggregatable> components = TestExperimentalProteoform.generate_unlabeled_components(TestExperimentalProteoform.starter_mass);

            Sweet.lollipop.neucode_labeled                   = false;
            Sweet.lollipop.remaining_to_aggregate            = new List <IAggregatable>(components);
            Sweet.lollipop.remaining_verification_components = new HashSet <Component>(components.OfType <Component>());
            Sweet.lollipop.missed_monoisotopics_range        = Enumerable.Range(-3, 3 * 2 + 1).ToList();
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E");

            e.root = components[0];
            e.aggregate();
            e.verify();

            Assert.AreEqual(2, e.aggregated.Count);
            Assert.AreEqual(2, e.lt_verification_components.Count);
            Assert.AreEqual(0, e.hv_verification_components.Count); // everything goes into light with unlabeled
            Assert.AreEqual(0, e.lt_quant_components.Count);        // no quantitation for unlabeled, yet
            Assert.AreEqual(0, e.hv_quant_components.Count);
        }
        public void assign_quant_components_large_tolerance_split_range()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.neucode_labeled            = true;
            Sweet.lollipop.mass_tolerance             = 10;                                               //ppm
            Sweet.lollipop.missed_monoisotopics_range = Enumerable.Range(-3, 3 * 2 + 1).ToList();
            ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("", 20000, 2, true); // tolerance is 0.2 Da
            double hv_mass           = e.agg_mass + e.lysine_count * Lollipop.NEUCODE_LYSINE_MASS_SHIFT;  // 20000.0703

            Component bb = new Component();
            Component cc = new Component();
            Component dd = new Component();
            Component ee = new Component();
            Component ff = new Component();
            Component gg = new Component();
            Component hh = new Component();
            Component ii = new Component();

            bb.weighted_monoisotopic_mass = 19999.79;
            cc.weighted_monoisotopic_mass = 19999.99;
            dd.weighted_monoisotopic_mass = 20000;
            ee.weighted_monoisotopic_mass = 20000.03;
            //boundary is 20000.036
            ff.weighted_monoisotopic_mass = 20000.04;
            gg.weighted_monoisotopic_mass = 20000.07;
            hh.weighted_monoisotopic_mass = 20000.08;
            ii.weighted_monoisotopic_mass = 20000.28;

            Sweet.lollipop.remaining_quantification_components = new HashSet <Component> {
                bb, cc, dd, ee, ff, gg, hh, ii
            };
            e.assign_quantitative_components();
            Assert.AreEqual(3, e.lt_quant_components.Count);
            Assert.AreEqual(3, e.hv_quant_components.Count);
            Assert.False(e.lt_quant_components.Any(c => e.hv_quant_components.Contains(c)));
        }
Exemplo n.º 11
0
        public void get_interesting_goterm_families()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.theoretical_database.aaIsotopeMassList = new AminoAcidMasses(Sweet.lollipop.carbamidomethylation, Sweet.lollipop.neucode_labeled).AA_Masses;
            Sweet.lollipop.significance_by_permutation            = true;
            Sweet.lollipop.significance_by_log2FC = false;
            DatabaseReference d1 = new DatabaseReference("GO", "GO:1", new List <Tuple <string, string> > {
                new Tuple <string, string>("term", "P:1")
            });
            DatabaseReference d2 = new DatabaseReference("GO", "GO:2", new List <Tuple <string, string> > {
                new Tuple <string, string>("term", "P:2")
            });
            DatabaseReference d3 = new DatabaseReference("GO", "GO:1", new List <Tuple <string, string> > {
                new Tuple <string, string>("term", "P:1")
            });
            GoTerm             g1 = new GoTerm(d1);
            GoTerm             g2 = new GoTerm(d2);
            GoTerm             g3 = new GoTerm(d3);
            ProteinWithGoTerms p1 = new ProteinWithGoTerms("ASDF", "T1", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new List <ProteolysisProduct> {
                new ProteolysisProduct(0, 0, "")
            }, "T2", "T3", true, false, new List <DatabaseReference> {
                d1
            }, new List <GoTerm> {
                g1
            });
            ProteinWithGoTerms p2 = new ProteinWithGoTerms("ASDF", "T2", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new List <ProteolysisProduct> {
                new ProteolysisProduct(0, 0, "")
            }, "T2", "T3", true, false, new List <DatabaseReference> {
                d2
            }, new List <GoTerm> {
                g2
            });
            ProteinWithGoTerms p3 = new ProteinWithGoTerms("ASDF", "T3", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new List <ProteolysisProduct> {
                new ProteolysisProduct(0, 0, "")
            }, "T2", "T3", true, false, new List <DatabaseReference> {
                d3
            }, new List <GoTerm> {
                g3
            });
            Dictionary <InputFile, Protein[]> dict = new Dictionary <InputFile, Protein[]>
            {
                { new InputFile("fake.txt", Purpose.ProteinDatabase), new Protein[] { p1 } },
                { new InputFile("fake.txt", Purpose.ProteinDatabase), new Protein[] { p2 } },
                { new InputFile("fake.txt", Purpose.ProteinDatabase), new Protein[] { p3 } },
            };
            ExperimentalProteoform e1 = ConstructorsForTesting.ExperimentalProteoform("E");
            ExperimentalProteoform e2 = ConstructorsForTesting.ExperimentalProteoform("E");

            e1.quant.intensitySum = 1;
            e1.quant.TusherValues1.significant = true;
            e1.quant.tusherlogFoldChange       = 1;
            e2.quant.intensitySum = 1;
            e2.quant.TusherValues1.significant = true;
            e2.quant.tusherlogFoldChange       = 1;
            TheoreticalProteoform t = ConstructorsForTesting.make_a_theoretical("T1_T1_asdf", p1, dict);
            TheoreticalProteoform u = ConstructorsForTesting.make_a_theoretical("T2_T1_asdf_asdf", p2, dict);
            TheoreticalProteoform v = ConstructorsForTesting.make_a_theoretical("T3_T1_asdf_Asdf_Asdf", p3, dict);

            t.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p1
            };
            u.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p2
            };
            v.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p3
            };
            t.begin = 1;
            t.end   = 1;
            u.begin = 1;
            u.end   = 1;
            v.begin = 1;
            v.end   = 1;
            make_relation(e1, t);
            //make_relation(e1, v); // we don't allow this to happen anymore... we only allow one ET conntection per E
            make_relation(e2, u);
            ProteoformFamily f = new ProteoformFamily(e1); // two theoreticals with the same GoTerms... expecting one GoTerm number but two theoretical proteins (now only one)
            ProteoformFamily h = new ProteoformFamily(e2);

            f.construct_family();
            f.identify_experimentals();
            h.construct_family();
            h.identify_experimentals();
            List <ProteoformFamily> families = new List <ProteoformFamily> {
                f, h
            };

            t.family  = f;
            v.family  = f;
            e1.family = f;
            u.family  = h;
            e2.family = h;
            List <ExperimentalProteoform> fake_significant = new List <ExperimentalProteoform> {
                e1
            };
            List <ProteinWithGoTerms> significant_proteins = Sweet.lollipop.getInducedOrRepressedProteins(fake_significant, Sweet.lollipop.TusherAnalysis1.GoAnalysis);
            List <GoTermNumber>       gtn = Sweet.lollipop.TusherAnalysis1.GoAnalysis.getGoTermNumbers(significant_proteins, new List <ProteinWithGoTerms> {
                p1, p2, p3
            });

            Assert.AreEqual(1, significant_proteins.Count);
            Assert.AreEqual(1, gtn.Count);
            Assert.AreEqual("1", gtn.First().Id);
            Assert.AreEqual(0 - (decimal)Math.Log(2d / 3d, 2), gtn.First().log_odds_ratio);

            List <ProteoformFamily> fams = Sweet.lollipop.getInterestingFamilies(gtn, families);

            Assert.AreEqual(1, fams.Count);
            Assert.AreEqual(1, fams[0].theoretical_proteoforms.Count);
        }
Exemplo n.º 12
0
        public void test_goterm_analysis_with_custom_list()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.theoretical_database.aaIsotopeMassList = new AminoAcidMasses(Sweet.lollipop.carbamidomethylation, Sweet.lollipop.neucode_labeled).AA_Masses;
            Sweet.lollipop.significance_by_permutation            = true;
            Sweet.lollipop.significance_by_log2FC = false;
            DatabaseReference d1 = new DatabaseReference("GO", "GO:1", new List <Tuple <string, string> > {
                new Tuple <string, string>("term", "P:1")
            });
            DatabaseReference d2 = new DatabaseReference("GO", "GO:2", new List <Tuple <string, string> > {
                new Tuple <string, string>("term", "P:2")
            });
            DatabaseReference d3 = new DatabaseReference("GO", "GO:1", new List <Tuple <string, string> > {
                new Tuple <string, string>("term", "P:1")
            });
            GoTerm             g1 = new GoTerm(d1);
            GoTerm             g2 = new GoTerm(d2);
            GoTerm             g3 = new GoTerm(d3);
            ProteinWithGoTerms p1 = new ProteinWithGoTerms("ASDF", "T1", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new List <ProteolysisProduct> {
                new ProteolysisProduct(0, 0, "")
            }, "T2", "T3", true, false, new List <DatabaseReference> {
                d1
            }, new List <GoTerm> {
                g1
            });
            ProteinWithGoTerms p2 = new ProteinWithGoTerms("ASDF", "T2", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new List <ProteolysisProduct> {
                new ProteolysisProduct(0, 0, "")
            }, "T2", "T3", true, false, new List <DatabaseReference> {
                d2
            }, new List <GoTerm> {
                g2
            });
            ProteinWithGoTerms p3 = new ProteinWithGoTerms("ASDF", "T3", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new List <ProteolysisProduct> {
                new ProteolysisProduct(0, 0, "")
            }, "T2", "T3", true, false, new List <DatabaseReference> {
                d3
            }, new List <GoTerm> {
                g3
            });
            Dictionary <InputFile, Protein[]> dict = new Dictionary <InputFile, Protein[]> {
                { new InputFile("fake.txt", Purpose.ProteinDatabase), new Protein[] { p1 } },
                { new InputFile("fake.txt", Purpose.ProteinDatabase), new Protein[] { p2 } },
                { new InputFile("fake.txt", Purpose.ProteinDatabase), new Protein[] { p3 } },
            };
            ExperimentalProteoform e1 = ConstructorsForTesting.ExperimentalProteoform("E");
            ExperimentalProteoform e2 = ConstructorsForTesting.ExperimentalProteoform("E");

            e1.quant.intensitySum = 1;
            e1.quant.TusherValues1.significant = true;
            e1.quant.tusherlogFoldChange       = 1;
            e2.quant.intensitySum = 1;
            e2.quant.TusherValues1.significant = true;
            e2.quant.tusherlogFoldChange       = 1;
            TheoreticalProteoform t = ConstructorsForTesting.make_a_theoretical("T1_T1_asdf", p1, dict);
            TheoreticalProteoform u = ConstructorsForTesting.make_a_theoretical("T2_T1_asdf_asdf", p2, dict);
            TheoreticalProteoform v = ConstructorsForTesting.make_a_theoretical("T3_T1_asdf_Asdf_Asdf", p3, dict);

            t.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p1
            };
            u.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p2
            };
            v.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p3
            };
            make_relation(e1, t);
            make_relation(e1, v);
            make_relation(e2, u);
            ProteoformFamily f = new ProteoformFamily(e1); // two theoreticals with the same GoTerms... expecting one GoTerm number but two theoretical proteins
            ProteoformFamily h = new ProteoformFamily(e2);

            f.construct_family();
            f.identify_experimentals();
            h.construct_family();
            h.identify_experimentals();
            List <ProteoformFamily> families = new List <ProteoformFamily> {
                f, h
            };

            t.family  = f;
            v.family  = f;
            e1.family = f;
            u.family  = h;
            e2.family = h;
            Sweet.lollipop.TusherAnalysis1.inducedOrRepressedProteins = Sweet.lollipop.getInducedOrRepressedProteins(new List <ExperimentalProteoform> {
                e1
            }, Sweet.lollipop.TusherAnalysis1.GoAnalysis);
            Sweet.lollipop.TusherAnalysis1.GoAnalysis.allTheoreticalProteins = true;
            Sweet.lollipop.theoretical_database.expanded_proteins            = new ProteinWithGoTerms[] { p1, p2, p3 };
            Sweet.lollipop.TusherAnalysis1.GoAnalysis.backgroundProteinsList = Path.Combine(TestContext.CurrentContext.TestDirectory, "test_protein_list.txt");
            Sweet.lollipop.TusherAnalysis1.GoAnalysis.GO_analysis(Sweet.lollipop.TusherAnalysis1.inducedOrRepressedProteins);
            Assert.AreEqual(1, Sweet.lollipop.TusherAnalysis1.inducedOrRepressedProteins.Count);  // only taking one ET connection by definition in forming ET relations; only one is used in identify theoreticals
            Assert.AreEqual(1, Sweet.lollipop.TusherAnalysis1.GoAnalysis.goTermNumbers.Count);
            Assert.AreEqual("1", Sweet.lollipop.TusherAnalysis1.GoAnalysis.goTermNumbers.First().Id);
            Assert.AreEqual(0 - (decimal)Math.Log(2d / 3d, 2), Sweet.lollipop.TusherAnalysis1.GoAnalysis.goTermNumbers.First().log_odds_ratio);

            List <ProteoformFamily> fams = Sweet.lollipop.getInterestingFamilies(Sweet.lollipop.TusherAnalysis1.GoAnalysis.goTermNumbers, families);

            Assert.AreEqual(1, fams.Count);
            Assert.AreEqual(2, fams[0].theoretical_proteoforms.Count);
        }
        public void TestUnabeledProteoformCommunityRelate_ET()
        {
            SaveState.lollipop.neucode_labeled = false;

            // 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
            });
            prList = community.relate(paE, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(1, prList.Count);

            // One experimental one theoretical protoeform; mass difference > 500 -- return 0
            pf1.modified_mass = 1000;
            pf2.modified_mass = 2000;
            paE[0]            = pf1;
            paT[0]            = pf2;
            prepare_for_et(new List <double> {
                pf1.modified_mass - pf2.modified_mass
            });
            prList = community.relate(paE, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(0, prList.Count);

            //Two experimental one theoretical proteoforms; mass difference < 500 Da -- return 2
            ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, -1, true);
            ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("A2", 1010.0, -1, true);
            TheoreticalProteoform  pf5 = ConstructorsForTesting.make_a_theoretical();

            pf5.modified_mass       = 1020.0;
            pf5.lysine_count        = 1;
            pf5.is_target           = true;
            pf5.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p1
            };
            ExperimentalProteoform[] paE2 = new ExperimentalProteoform[2];
            paE2[0] = pf3;
            paE2[1] = pf4;
            paT[0]  = pf5;
            prepare_for_et(new List <double> {
                pf3.modified_mass - pf5.modified_mass,
                pf4.modified_mass - pf5.modified_mass,
            });
            prList = community.relate(paE2, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(2, prList.Count);

            //Two experimental one theoretical proteoforms; one mass difference >500 Da -- return 0
            pf3.modified_mass = 1000;
            pf4.modified_mass = 1010;
            pf5.modified_mass = 2000;
            paE2[0]           = pf3;
            paE2[1]           = pf4;
            paT[0]            = pf5;
            prepare_for_et(new List <double> {
                pf3.modified_mass - pf5.modified_mass,
                pf4.modified_mass - pf5.modified_mass,
            });
            prList = community.relate(paE2, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(0, prList.Count);

            //Two experimental one theoretical proteoforms; mass difference > 500 Da -- return 0
            pf3.modified_mass = 1000;
            pf4.modified_mass = 2000;
            pf5.modified_mass = 3000;
            paE2[0]           = pf3;
            paE2[1]           = pf4;
            paT[0]            = pf5;
            prepare_for_et(new List <double> {
                pf3.modified_mass - pf5.modified_mass,
                pf4.modified_mass - pf5.modified_mass,
            });
            prList = community.relate(paE2, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(0, prList.Count);
        }
        public void TestNeuCodeLabeledProteoformCommunityRelate_EE()
        {
            SaveState.lollipop.neucode_labeled = true;

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

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

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

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

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

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

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

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

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

            //Three proteoforms; lysine count equal; mass difference > 250 Da -- return 0
            pf3.lysine_count  = 1;
            pf3.modified_mass = 1000;
            pf4.lysine_count  = 1;
            pf4.modified_mass = 1600;
            pf5.lysine_count  = 1;
            pf5.modified_mass = 2500;
            pa2[0]            = pf3;
            pa2[1]            = pf4;
            pa2[2]            = pf5;
            prList            = community.relate(pa2, pa2, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            Assert.AreEqual(0, prList.Count);
        }
Exemplo n.º 15
0
        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);
            }
        }
Exemplo n.º 16
0
        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));
        }
Exemplo n.º 17
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>()));
        }
Exemplo n.º 18
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);
            }
        }
Exemplo n.º 19
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 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);
        }
Exemplo n.º 22
0
        public void get_interesting_goterm_families()
        {
            SaveState.lollipop = new Lollipop();
            DatabaseReference d1 = new DatabaseReference("GO", "GO:1", new List <Tuple <string, string> > {
                new Tuple <string, string>("term", "P:1")
            });
            DatabaseReference d2 = new DatabaseReference("GO", "GO:2", new List <Tuple <string, string> > {
                new Tuple <string, string>("term", "P:2")
            });
            DatabaseReference d3 = new DatabaseReference("GO", "GO:1", new List <Tuple <string, string> > {
                new Tuple <string, string>("term", "P:1")
            });
            GoTerm             g1 = new GoTerm(d1);
            GoTerm             g2 = new GoTerm(d2);
            GoTerm             g3 = new GoTerm(d3);
            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[] { "" }, "T2", "T3", true, false, new List <DatabaseReference> {
                d1
            }, new List <GoTerm> {
                g1
            });
            ProteinWithGoTerms p2 = new ProteinWithGoTerms("", "T2", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new int?[] { 0 }, new int?[] { 0 }, new string[] { "" }, "T2", "T3", true, false, new List <DatabaseReference> {
                d2
            }, new List <GoTerm> {
                g2
            });
            ProteinWithGoTerms p3 = new ProteinWithGoTerms("", "T3", new List <Tuple <string, string> > {
                new Tuple <string, string>("", "")
            }, new Dictionary <int, List <Modification> >(), new int?[] { 0 }, new int?[] { 0 }, new string[] { "" }, "T2", "T3", true, false, new List <DatabaseReference> {
                d3
            }, new List <GoTerm> {
                g3
            });
            Dictionary <InputFile, Protein[]> dict = new Dictionary <InputFile, Protein[]>
            {
                { new InputFile("fake.txt", Purpose.ProteinDatabase), new Protein[] { p1 } },
                { new InputFile("fake.txt", Purpose.ProteinDatabase), new Protein[] { p2 } },
                { new InputFile("fake.txt", Purpose.ProteinDatabase), new Protein[] { p3 } },
            };
            ExperimentalProteoform e1 = ConstructorsForTesting.ExperimentalProteoform("E");
            ExperimentalProteoform e2 = ConstructorsForTesting.ExperimentalProteoform("E");

            e1.quant.intensitySum  = 1;
            e1.quant.FDR           = 0;
            e1.quant.logFoldChange = 1;
            e2.quant.intensitySum  = 1;
            e2.quant.FDR           = 0;
            e2.quant.logFoldChange = 1;
            TheoreticalProteoform t = ConstructorsForTesting.make_a_theoretical("T1_T1_asdf", p1, dict);
            TheoreticalProteoform u = ConstructorsForTesting.make_a_theoretical("T2_T1_asdf_asdf", p2, dict);
            TheoreticalProteoform v = ConstructorsForTesting.make_a_theoretical("T3_T1_asdf_Asdf_Asdf", p3, dict);

            t.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p1
            };
            u.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p2
            };
            v.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p3
            };
            make_relation(e1, t);
            //make_relation(e1, v); // we don't allow this to happen anymore... we only allow one ET conntection per E
            make_relation(e2, u);
            ProteoformFamily f = new ProteoformFamily(e1); // two theoreticals with the same GoTerms... expecting one GoTerm number but two theoretical proteins (now only one)
            ProteoformFamily h = new ProteoformFamily(e2);

            f.construct_family();
            f.identify_experimentals();
            h.construct_family();
            h.identify_experimentals();
            List <ProteoformFamily> families = new List <ProteoformFamily> {
                f, h
            };

            t.family  = f;
            v.family  = f;
            e1.family = f;
            u.family  = h;
            e2.family = h;
            List <ExperimentalProteoform> fake_significant = new List <ExperimentalProteoform> {
                e1
            };
            List <ProteinWithGoTerms> significant_proteins = SaveState.lollipop.getInducedOrRepressedProteins(fake_significant, 0, 1, 0);
            List <GoTermNumber>       gtn = SaveState.lollipop.getGoTermNumbers(significant_proteins, new List <ProteinWithGoTerms> {
                p1, p2, p3
            });

            Assert.AreEqual(1, significant_proteins.Count);
            Assert.AreEqual(1, gtn.Count);
            Assert.AreEqual("1", gtn.First().Id);
            Assert.AreEqual(0 - (decimal)Math.Log(2d / 3d, 2), gtn.First().log_odds_ratio);

            List <ProteoformFamily> fams = SaveState.lollipop.getInterestingFamilies(gtn, families);

            Assert.AreEqual(1, fams.Count);
            Assert.AreEqual(1, fams[0].theoretical_proteoforms.Count);
        }
        public void agg_proteoforms_meeting_criteria2()
        {
            Sweet.lollipop = new Lollipop();

            string anysingle = "Biorep+Techreps From Any Single Condition";
            string any       = "Biorep+Techreps From Any Condition";
            string fromeach  = "Biorep+Techreps From Each Condition";
            List <ExperimentalProteoform> exps = new List <ExperimentalProteoform> {
                ConstructorsForTesting.ExperimentalProteoform("E")
            };
            List <string> conditions = new List <string> {
                "s", "ns"
            };
            Component c1 = new Component();

            c1.input_file = new InputFile("somePath", Purpose.Identification);
            c1.input_file.lt_condition         = conditions[0];
            c1.input_file.biological_replicate = "1";
            c1.input_file.technical_replicate  = "1";
            exps[0].aggregated.Add(c1);
            List <ExperimentalProteoform> exps_out = new List <ExperimentalProteoform>();

            //PASSES WHEN THERE ARE ENOUGH IN SPECIFIED CONDITIONS
            //One biorep+techrep obs passes any-single-conditon test
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, anysingle, 1);
            Assert.AreEqual(1, exps_out.Count);

            //Two biorep+techrep obs in single condition passes any-single-conditon test
            Component c2 = new Component();

            c2.input_file = new InputFile("somePath", Purpose.Identification);
            c2.input_file.lt_condition         = conditions[0];
            c2.input_file.biological_replicate = "1";
            c2.input_file.technical_replicate  = "2";
            exps[0].aggregated.Add(c2);
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, anysingle, 2);
            Assert.AreEqual(1, exps_out.Count);

            //Two biorep+techrep obs in single condition passes any-conditon test
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, any, 2);
            Assert.AreEqual(1, exps_out.Count);

            //Two biorep+techrep obs in single condition doesn't pass for-each-conditon test
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, fromeach, 1);
            Assert.AreEqual(0, exps_out.Count);

            // DOESN'T PASS WHEN LESS THAN THRESHOLD
            //Two biorep+techrep obs in single condition doesn't pass 3 from any-single-conditon test
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, anysingle, 3);
            Assert.AreEqual(0, exps_out.Count);

            //Two biorep+techrep obs in single condition doesn't pass 3 from any-conditon test
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, any, 3);
            Assert.AreEqual(0, exps_out.Count);

            //Two biorep+techrep obs in single condition  doesn't pass 2 from for-each-conditon test
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, fromeach, 2);
            Assert.AreEqual(0, exps_out.Count);

            Component c3 = new Component();

            c3.input_file = new InputFile("somePath", Purpose.Identification);
            c3.input_file.lt_condition         = conditions[1];
            c3.input_file.biological_replicate = "100";
            c3.input_file.technical_replicate  = "1";
            exps[0].aggregated.Add(c3);

            //At least one biorep+techrep in each condition passes for-each-conditon test
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, fromeach, 1);
            Assert.AreEqual(1, exps_out.Count);

            // DOESN'T PASS WHEN LESS THAN THRESHOLD IN SPECIFIC CONDITIONS UNLESS ANY-CONDITION
            //Two and one biorep+techrep obs in two different conditions doesn't pass 3 from any-single-conditon test
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, anysingle, 3);
            Assert.AreEqual(0, exps_out.Count);

            //Two and one biorep+techrep obs in two different conditions passes 3 from any-conditon test
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, any, 3);
            Assert.AreEqual(1, exps_out.Count);

            //Two and one biorep+techrep obs in two different conditions doesn't pass 3 from for-each-conditon test
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, fromeach, 3);
            Assert.AreEqual(0, exps_out.Count);

            //DOESN'T PASS WHEN NOT MATCHING LISTED CONDITIONS, EXCEPT FOR ANY-CONDITION
            foreach (var x in exps[0].aggregated)
            {
                x.input_file.lt_condition = "not_a_condition";
            }
            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, anysingle, 3);
            Assert.AreEqual(0, exps_out.Count);

            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, any, 3);
            Assert.AreEqual(1, exps_out.Count);

            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, fromeach, 3);
            Assert.AreEqual(0, exps_out.Count);

            //NOT JUST COUNTING BIOREP INTENSITIES, BUT RATHER BIOREPS WITH OBSERVATIONS
            exps[0].aggregated.Clear();
            Component c4 = new Component();

            c4.input_file = new InputFile("somePath", Purpose.Identification);
            c4.input_file.lt_condition         = conditions[0];
            c4.input_file.biological_replicate = "1";
            c4.input_file.technical_replicate  = "1";
            exps[0].aggregated.Add(c4);
            Component c5 = new Component();

            c5.input_file = new InputFile("somePath", Purpose.Identification);
            c5.input_file.lt_condition         = conditions[0];
            c5.input_file.biological_replicate = "1";
            c5.input_file.technical_replicate  = "1";
            exps[0].aggregated.Add(c5);
            Component c6 = new Component();

            c6.input_file = new InputFile("somePath", Purpose.Identification);
            c6.input_file.lt_condition         = conditions[0];
            c6.input_file.biological_replicate = "1";
            c6.input_file.technical_replicate  = "1";
            exps[0].aggregated.Add(c6);
            Component c7 = new Component();

            c7.input_file = new InputFile("somePath", Purpose.Identification);
            c7.input_file.lt_condition         = conditions[0];
            c7.input_file.biological_replicate = "1";
            c7.input_file.technical_replicate  = "1";
            exps[0].aggregated.Add(c7);

            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, anysingle, 2);
            Assert.AreEqual(0, exps_out.Count);

            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, any, 2);
            Assert.AreEqual(0, exps_out.Count);

            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, fromeach, 2);
            Assert.AreEqual(0, exps_out.Count);

            Component c8 = new Component();

            c8.input_file = new InputFile("somePath", Purpose.Identification);
            c8.input_file.lt_condition         = conditions[1];
            c8.input_file.biological_replicate = "1";
            c8.input_file.technical_replicate  = "1";
            exps[0].aggregated.Add(c8);
            Component c9 = new Component();

            c9.input_file = new InputFile("somePath", Purpose.Identification);
            c9.input_file.lt_condition         = conditions[1];
            c9.input_file.biological_replicate = "1";
            c9.input_file.technical_replicate  = "1";
            exps[0].aggregated.Add(c9);
            Component c10 = new Component();

            c10.input_file = new InputFile("somePath", Purpose.Identification);
            c10.input_file.lt_condition         = conditions[1];
            c10.input_file.biological_replicate = "1";
            c10.input_file.technical_replicate  = "1";
            exps[0].aggregated.Add(c10);
            Component c11 = new Component();

            c11.input_file = new InputFile("somePath", Purpose.Identification);
            c11.input_file.lt_condition         = conditions[1];
            c11.input_file.biological_replicate = "1";
            c11.input_file.technical_replicate  = "1";
            exps[0].aggregated.Add(c11);

            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, anysingle, 2);
            Assert.AreEqual(0, exps_out.Count);

            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, any, 2);
            Assert.AreEqual(1, exps_out.Count);

            exps_out = Sweet.lollipop.determineAggProteoformsMeetingCriteria(conditions, exps, fromeach, 2);
            Assert.AreEqual(0, exps_out.Count);
        }
        public void test_construct_target_and_decoy_families()
        {
            SaveState.lollipop = new Lollipop();
            SaveState.lollipop.neucode_labeled = true;
            ExperimentalProteoform pf1    = ConstructorsForTesting.ExperimentalProteoform("E1", 1000, 5, true);
            ExperimentalProteoform pf2    = ConstructorsForTesting.ExperimentalProteoform("E2", 1020, 5, true);
            ExperimentalProteoform pf3    = ConstructorsForTesting.ExperimentalProteoform("E3", 1040, 8, true);
            ExperimentalProteoform pf4    = ConstructorsForTesting.ExperimentalProteoform("E4", 1050, 5, true);
            TheoreticalProteoform  t1     = ConstructorsForTesting.make_a_theoretical("t1", 1000, 5);
            TheoreticalProteoform  decoy1 = ConstructorsForTesting.make_a_theoretical("Decoy1", 1020, 5);

            TestProteoformCommunityRelate.prepare_for_et(new List <double>()
            {
                0
            });

            SaveState.lollipop.target_proteoform_community = new ProteoformCommunity();
            SaveState.lollipop.target_proteoform_community.experimental_proteoforms = new ExperimentalProteoform[4] {
                pf1, pf2, pf3, pf4
            };
            SaveState.lollipop.target_proteoform_community.theoretical_proteoforms = new TheoreticalProteoform[1] {
                t1
            };
            SaveState.lollipop.decoy_proteoform_communities.Add(SaveState.lollipop.decoy_community_name_prefix + "0", new ProteoformCommunity());
            SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].experimental_proteoforms = SaveState.lollipop.target_proteoform_community.experimental_proteoforms.Select(e => new ExperimentalProteoform(e)).ToArray();
            SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].theoretical_proteoforms  = new TheoreticalProteoform[1] {
                decoy1
            };

            SaveState.lollipop.et_relations = SaveState.lollipop.target_proteoform_community.relate(SaveState.lollipop.target_proteoform_community.experimental_proteoforms, SaveState.lollipop.target_proteoform_community.theoretical_proteoforms, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            SaveState.lollipop.ee_relations = SaveState.lollipop.target_proteoform_community.relate(SaveState.lollipop.target_proteoform_community.experimental_proteoforms, SaveState.lollipop.target_proteoform_community.experimental_proteoforms, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, true);
            SaveState.lollipop.relate_ed();
            SaveState.lollipop.relate_ef();
            foreach (ProteoformRelation pr in SaveState.lollipop.et_relations)
            {
                pr.set_nearby_group(SaveState.lollipop.et_relations, SaveState.lollipop.et_relations.Select(r => r.InstanceId).ToList());
            }
            foreach (ProteoformRelation pr in SaveState.lollipop.ee_relations)
            {
                pr.set_nearby_group(SaveState.lollipop.ee_relations, SaveState.lollipop.ee_relations.Select(r => r.InstanceId).ToList());
            }

            SaveState.lollipop.et_peaks = SaveState.lollipop.target_proteoform_community.accept_deltaMass_peaks(SaveState.lollipop.et_relations, SaveState.lollipop.ed_relations);
            SaveState.lollipop.ee_peaks = SaveState.lollipop.target_proteoform_community.accept_deltaMass_peaks(SaveState.lollipop.ee_relations, SaveState.lollipop.ef_relations);

            //one ED relation
            Assert.AreEqual(1, SaveState.lollipop.ed_relations.Values.SelectMany(v => v).Count());
            Assert.AreEqual(1, SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].theoretical_proteoforms.SelectMany(t => t.relationships).Count());

            //peak is unaccepted --> relation should be unaccepted, peak added to relation
            Assert.IsFalse(SaveState.lollipop.ed_relations.First().Value.FirstOrDefault().Accepted); //should be false if peak unaccepted
            Assert.AreEqual(1, SaveState.lollipop.et_peaks.Count);
            Assert.IsNotNull(SaveState.lollipop.ed_relations.Values.SelectMany(v => v).First().peak);


            //peak is accepted --> relation should be accepted, peak added to relation
            SaveState.lollipop.clear_et();
            SaveState.lollipop.min_peak_count_et = 1;
            SaveState.lollipop.et_relations      = SaveState.lollipop.target_proteoform_community.relate(SaveState.lollipop.target_proteoform_community.experimental_proteoforms, SaveState.lollipop.target_proteoform_community.theoretical_proteoforms, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            SaveState.lollipop.relate_ed();
            foreach (ProteoformRelation pr in SaveState.lollipop.et_relations)
            {
                pr.set_nearby_group(SaveState.lollipop.et_relations, SaveState.lollipop.et_relations.Select(r => r.InstanceId).ToList());
            }
            foreach (ProteoformRelation pr in SaveState.lollipop.ee_relations)
            {
                pr.set_nearby_group(SaveState.lollipop.ee_relations, SaveState.lollipop.ee_relations.Select(r => r.InstanceId).ToList());
            }
            SaveState.lollipop.et_peaks = SaveState.lollipop.target_proteoform_community.accept_deltaMass_peaks(SaveState.lollipop.et_relations, SaveState.lollipop.ed_relations);

            SaveState.lollipop.et_peaks = SaveState.lollipop.target_proteoform_community.accept_deltaMass_peaks(SaveState.lollipop.et_relations, SaveState.lollipop.ed_relations);
            Assert.IsTrue(SaveState.lollipop.ed_relations.First().Value.FirstOrDefault().Accepted);               //should be true if peak accepted
            Assert.IsNotNull(SaveState.lollipop.ed_relations.Values.SelectMany(v => v).First().peak);
            Assert.AreEqual(1, SaveState.lollipop.ed_relations.Values.SelectMany(v => v).Count(r => r.Accepted)); //only 1 relation is in delta mass range of accepted peak - only 1 accepted

            //2 ef relations, unaccepted because peak unaccepted
            Assert.AreEqual(3, SaveState.lollipop.ef_relations.Values.SelectMany(v => v).Count());                //2 ef relations
            Assert.AreEqual(0, SaveState.lollipop.ef_relations.Values.SelectMany(v => v).Count(r => r.Accepted)); //all peaks accepted are false, so relation accepted should be false

            //one peak accepted --> one of the EF relations falls into range of peak and should be accepted
            SaveState.lollipop.clear_ee();
            SaveState.lollipop.min_peak_count_ee = 1;
            SaveState.lollipop.ee_relations      = SaveState.lollipop.target_proteoform_community.relate(SaveState.lollipop.target_proteoform_community.experimental_proteoforms, SaveState.lollipop.target_proteoform_community.experimental_proteoforms, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, true);
            SaveState.lollipop.relate_ef();
            SaveState.lollipop.ee_peaks = SaveState.lollipop.target_proteoform_community.accept_deltaMass_peaks(SaveState.lollipop.ee_relations, SaveState.lollipop.ef_relations);
            Assert.AreEqual(3, SaveState.lollipop.ee_peaks.Count(p => p.Accepted));
            Assert.AreEqual(3, SaveState.lollipop.ee_relations.Count);
            Assert.AreEqual(1, SaveState.lollipop.ef_relations.Values.SelectMany(v => v).Count(r => r.Accepted)); //only 1 relation is in delta mass range of accepted peak - only 1 accepted
            SaveState.lollipop.construct_target_and_decoy_families();

            //should be 2 target families and 3 decoy families
            //only make decoy relations out of accepted relations --> 1 family with accepted relations
            Assert.AreEqual(2, SaveState.lollipop.target_proteoform_community.families.Count);
            Assert.AreEqual(3, SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].families.Count);
            Assert.AreEqual(1, SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].families.Count(f => f.relations.Count > 0));
            Assert.AreEqual(2, SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].families.SelectMany(f => f.relations).Count());
        }
Exemplo n.º 25
0
        public void TestDeltaMassPeakConstructor()
        {
            Sweet.lollipop = new Lollipop();
            ConstructorsForTesting.read_mods();
            Sweet.lollipop.et_high_mass_difference = 250;
            Sweet.lollipop.et_low_mass_difference  = -250;
            Sweet.lollipop.peak_width_base_ee      = 0.015;
            Sweet.lollipop.peak_width_base_et      = 0.015;

            ExperimentalProteoform pf1           = ConstructorsForTesting.ExperimentalProteoform("acession1");
            TheoreticalProteoform  pf2           = ConstructorsForTesting.make_a_theoretical();
            ProteoformComparison   relation_type = ProteoformComparison.ExperimentalTheoretical;
            double delta_mass = 1 - 1e-7;

            ExperimentalProteoform pf3            = ConstructorsForTesting.ExperimentalProteoform("acession3");
            TheoreticalProteoform  pf4            = ConstructorsForTesting.make_a_theoretical();
            ProteoformComparison   relation_type2 = ProteoformComparison.ExperimentalTheoretical;
            double delta_mass2 = 1;

            ExperimentalProteoform pf5            = ConstructorsForTesting.ExperimentalProteoform("acession5");
            TheoreticalProteoform  pf6            = ConstructorsForTesting.make_a_theoretical();
            ProteoformComparison   relation_type3 = ProteoformComparison.ExperimentalTheoretical;
            double delta_mass3 = 1 + 1e-7;

            ExperimentalProteoform pf55            = ConstructorsForTesting.ExperimentalProteoform("acession5");
            TheoreticalProteoform  pf65            = ConstructorsForTesting.make_a_theoretical();
            ProteoformComparison   relation_type35 = ProteoformComparison.ExperimentalTheoretical;
            double delta_mass35 = 1 + 2e-7;

            List <ProteoformRelation> theList = new List <ProteoformRelation>();

            theList.Add(new ProteoformRelation(pf1, pf2, relation_type, delta_mass, TestContext.CurrentContext.TestDirectory));
            theList.Add(new ProteoformRelation(pf3, pf4, relation_type2, delta_mass2, TestContext.CurrentContext.TestDirectory));
            theList.Add(new ProteoformRelation(pf5, pf6, relation_type3, delta_mass3, TestContext.CurrentContext.TestDirectory));
            theList.Add(new ProteoformRelation(pf55, pf65, relation_type35, delta_mass35, TestContext.CurrentContext.TestDirectory));

            ProteoformRelation base_relation = new ProteoformRelation(pf3, pf4, relation_type2, delta_mass2, TestContext.CurrentContext.TestDirectory);

            //base_relation.nearby_relations = base_relation.set_nearby_group(theList, theList.Select(r => r.InstanceId).ToList());
            Console.WriteLine("Creating deltaMassPeak");
            DeltaMassPeak deltaMassPeak = new DeltaMassPeak(base_relation, new HashSet <ProteoformRelation>(theList));

            Console.WriteLine("Created deltaMassPeak");

            Assert.AreEqual(0, deltaMassPeak.peak_group_fdr);
            Dictionary <string, List <ProteoformRelation> > decoy_relations = new Dictionary <string, List <ProteoformRelation> >();

            decoy_relations["decoyDatabase1"] = new List <ProteoformRelation>();

            ExperimentalProteoform pf7            = ConstructorsForTesting.ExperimentalProteoform("experimental1");
            TheoreticalProteoform  pf8            = ConstructorsForTesting.make_a_theoretical();
            ProteoformComparison   relation_type4 = ProteoformComparison.ExperimentalDecoy;
            double             delta_mass4        = 1;
            ProteoformRelation decoy_relation     = new ProteoformRelation(pf7, pf8, relation_type4, delta_mass4, TestContext.CurrentContext.TestDirectory);

            decoy_relations["decoyDatabase1"].Add(decoy_relation);

            deltaMassPeak.calculate_fdr(decoy_relations);
            Assert.AreEqual(0.25, deltaMassPeak.peak_group_fdr); // 1 decoy database, (1 decoy relation, median=1), 4 target relations

            decoy_relations["decoyDatabase2"] = new List <ProteoformRelation>();
            decoy_relations["decoyDatabase2"].Add(decoy_relation);
            decoy_relations["decoyDatabase2"].Add(decoy_relation);

            deltaMassPeak.calculate_fdr(decoy_relations);
            Assert.AreEqual(0.375, deltaMassPeak.peak_group_fdr); // 2 decoy databases (1 & 2 decoy relations, median=1.5), 4 target relations
        }
Exemplo n.º 26
0
        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();
            Sweet.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)
            };
            Sweet.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)); // this is taken care of in relate, now
            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)); // this is taken care of in relate, now
            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();
            Sweet.lollipop.ee_relations.Clear();
            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)
            };
            Sweet.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)
            };
            Sweet.lollipop.ee_relations = test_community.relate(test_community.experimental_proteoforms, test_community.experimental_proteoforms, ProteoformComparison.ExperimentalExperimental, true, TestContext.CurrentContext.TestDirectory, false);
            unequal_relations           = test_community.relate_ef(test_community.experimental_proteoforms, test_community.experimental_proteoforms);
            Assert.AreEqual(0, unequal_relations.Count);

            //All equal, no unequal lysine count because there's an empty list of unequal lysine-count proteoforms. Each should create no unequal relations, so no relations total
            test_community = new ProteoformCommunity();
            test_community.experimental_proteoforms = new ExperimentalProteoform[] {
                ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A2", 1000.0, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A3", 1000.0, 1, true),
                ConstructorsForTesting.ExperimentalProteoform("A4", 1000.0, 1, true)
            };
            unequal_relations = test_community.relate_ef(test_community.experimental_proteoforms, test_community.experimental_proteoforms);
            Assert.AreEqual(0, unequal_relations.Count);
        }
Exemplo n.º 27
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);
            }
        }
Exemplo n.º 28
0
        public void TestUnabeledProteoformCommunityRelateWithNotches_ET()
        {
            Sweet.lollipop.neucode_labeled = false;
            Sweet.lollipop.et_use_notch    = true;

            // 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
            });
            prList = community.relate(paE, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(1, prList.Count);

            // One experimental one theoretical protoeform; mass difference > 500 -- return 0
            pf1.modified_mass = 1000;
            pf2.modified_mass = 2000;
            paE[0]            = pf1;
            paT[0]            = pf2;
            prepare_for_et(new List <double> {
                pf1.modified_mass - pf2.modified_mass
            });
            prList = community.relate(paE, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(0, prList.Count);

            //Two experimental one theoretical proteoforms; mass difference < 500 Da -- return 2
            ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("A1", 1000.0, -1, true);
            ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("A2", 1010.0, -1, true);
            TheoreticalProteoform  pf5 = ConstructorsForTesting.make_a_theoretical();

            pf5.modified_mass       = 1020.0;
            pf5.lysine_count        = 1;
            pf5.is_target           = true;
            pf5.ExpandedProteinList = new List <ProteinWithGoTerms> {
                p1
            };
            ExperimentalProteoform[] paE2 = new ExperimentalProteoform[2];
            paE2[0] = pf3;
            paE2[1] = pf4;
            paT[0]  = pf5;
            prepare_for_et(new List <double> {
                pf3.modified_mass - pf5.modified_mass,
                pf4.modified_mass - pf5.modified_mass,
            });
            prList = community.relate(paE2, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(2, prList.Count);

            //Two experimental one theoretical proteoforms; one mass difference >500 Da -- return 0
            pf3.modified_mass = 1000;
            pf4.modified_mass = 1010;
            pf5.modified_mass = 2000;
            paE2[0]           = pf3;
            paE2[1]           = pf4;
            paT[0]            = pf5;
            prepare_for_et(new List <double> {
                pf3.modified_mass - pf5.modified_mass,
                pf4.modified_mass - pf5.modified_mass,
            });
            prList = community.relate(paE2, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(0, prList.Count);

            //Two experimental one theoretical proteoforms; mass difference > 500 Da -- return 0
            pf3.modified_mass = 1000;
            pf4.modified_mass = 2000;
            pf5.modified_mass = 3000;
            paE2[0]           = pf3;
            paE2[1]           = pf4;
            paT[0]            = pf5;
            prepare_for_et(new List <double> {
                pf3.modified_mass - pf5.modified_mass,
                pf4.modified_mass - pf5.modified_mass,
            });
            prList = community.relate(paE2, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(0, prList.Count);

            //test methionine retention
            pf1.modified_mass = 2131.04;
            pf1.lysine_count  = 1;
            pf2.modified_mass = 2000;
            pf2.lysine_count  = 1;
            pf2.begin         = 2;

            ModificationMotif motif;

            ModificationMotif.TryGetMotif("M", out motif);
            Modification m = new Modification("Met retention", _modificationType: "AminoAcid", _target: motif, _locationRestriction: "Anywhere.", _monoisotopicMass: 131.04);

            Sweet.lollipop.theoretical_database.all_mods_with_mass.Add(m);
            Sweet.lollipop.theoretical_database.all_possible_ptmsets.Add(new PtmSet(new List <Ptm> {
                new Ptm(-1, m)
            }));
            Sweet.lollipop.modification_ranks.Add(131.04, 2);
            Sweet.lollipop.theoretical_database.possible_ptmset_dictionary = Sweet.lollipop.theoretical_database.make_ptmset_dictionary();

            paE[0] = pf1;
            paT[0] = pf2;
            prList = community.relate(paE, paT, ProteoformComparison.ExperimentalTheoretical, true, TestContext.CurrentContext.TestDirectory, true);
            Assert.AreEqual(1, prList.Count);
        }
Exemplo n.º 29
0
        public void TestDeltaMassPeakConstructorWithNotches()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.et_use_notch = true;
            Sweet.lollipop.enter_input_files(new string[] { Path.Combine(TestContext.CurrentContext.TestDirectory, "ptmlist.txt") }, Lollipop.acceptable_extensions[2], Lollipop.file_types[2], Sweet.lollipop.input_files, false);
            ConstructorsForTesting.read_mods();
            Sweet.lollipop.et_high_mass_difference = 250;
            Sweet.lollipop.et_low_mass_difference  = -250;


            ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("acession1");
            TheoreticalProteoform  pf2 = ConstructorsForTesting.make_a_theoretical();

            pf1.modified_mass = 1000;
            ProteoformComparison relation_type = ProteoformComparison.ExperimentalTheoretical;
            double delta_mass = 1 - 1e-7;

            ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("acession3");
            TheoreticalProteoform  pf4 = ConstructorsForTesting.make_a_theoretical();

            pf3.modified_mass = 1000;
            ProteoformComparison relation_type2 = ProteoformComparison.ExperimentalTheoretical;
            double delta_mass2 = 1;


            ExperimentalProteoform pf5 = ConstructorsForTesting.ExperimentalProteoform("acession5");
            TheoreticalProteoform  pf6 = ConstructorsForTesting.make_a_theoretical();

            pf5.modified_mass = 1000;
            ProteoformComparison relation_type3 = ProteoformComparison.ExperimentalTheoretical;
            double delta_mass3 = 1 + 1e-7;

            ExperimentalProteoform pf55 = ConstructorsForTesting.ExperimentalProteoform("acession5");
            TheoreticalProteoform  pf65 = ConstructorsForTesting.make_a_theoretical();

            pf55.modified_mass = 1000;
            ProteoformComparison relation_type35 = ProteoformComparison.ExperimentalTheoretical;
            double delta_mass35 = 1 + 2e-7;

            TestProteoformCommunityRelate.prepare_for_et(new List <double>()
            {
                1
            });
            List <ProteoformRelation> theList = new List <ProteoformRelation>();

            theList.Add(new ProteoformRelation(pf1, pf2, relation_type, delta_mass, TestContext.CurrentContext.TestDirectory));
            theList.Add(new ProteoformRelation(pf3, pf4, relation_type2, delta_mass2, TestContext.CurrentContext.TestDirectory));
            theList.Add(new ProteoformRelation(pf5, pf6, relation_type3, delta_mass3, TestContext.CurrentContext.TestDirectory));
            theList.Add(new ProteoformRelation(pf55, pf65, relation_type35, delta_mass35, TestContext.CurrentContext.TestDirectory));

            ProteoformRelation base_relation = new ProteoformRelation(pf3, pf4, relation_type2, delta_mass2, TestContext.CurrentContext.TestDirectory);

            //base_relation.nearby_relations = base_relation.set_nearby_group(theList, theList.Select(r => r.InstanceId).ToList());
            Console.WriteLine("Creating deltaMassPeak");
            DeltaMassPeak deltaMassPeak = new DeltaMassPeak(base_relation, new HashSet <ProteoformRelation>(theList));

            Console.WriteLine("Created deltaMassPeak");

            Assert.AreEqual(0, deltaMassPeak.peak_group_fdr);
            Assert.AreEqual(4, deltaMassPeak.grouped_relations.Count);
            Assert.AreEqual("[fake1]", deltaMassPeak.possiblePeakAssignments_string);
            Assert.AreEqual(1.0, deltaMassPeak.DeltaMass);
            Dictionary <string, List <ProteoformRelation> > decoy_relations = new Dictionary <string, List <ProteoformRelation> >();

            decoy_relations["decoyDatabase1"] = new List <ProteoformRelation>();

            ExperimentalProteoform pf7 = ConstructorsForTesting.ExperimentalProteoform("experimental1");
            TheoreticalProteoform  pf8 = ConstructorsForTesting.make_a_theoretical();

            pf7.modified_mass = 1000;
            ProteoformComparison relation_type4 = ProteoformComparison.ExperimentalDecoy;
            double             delta_mass4      = 1;
            ProteoformRelation decoy_relation   = new ProteoformRelation(pf7, pf8, relation_type4, delta_mass4, TestContext.CurrentContext.TestDirectory);

            decoy_relations["decoyDatabase1"].Add(decoy_relation);

            deltaMassPeak.calculate_fdr(decoy_relations);
            Assert.AreEqual(0.25, deltaMassPeak.peak_group_fdr); // 1 decoy database, (1 decoy relation, median=1), 4 target relations

            decoy_relations["decoyDatabase2"] = new List <ProteoformRelation>();
            decoy_relations["decoyDatabase2"].Add(decoy_relation);
            decoy_relations["decoyDatabase2"].Add(decoy_relation);

            deltaMassPeak.calculate_fdr(decoy_relations);
            Assert.AreEqual(0.375, deltaMassPeak.peak_group_fdr); // 2 decoy databases (1 & 2 decoy relations, median=1.5), 4 target relations
        }
Exemplo n.º 30
0
        public void TestProteoformCommunityRelateWithNotches_ED()
        {
            Sweet.lollipop = new Lollipop();
            Sweet.lollipop.neucode_labeled = true;
            Sweet.lollipop.et_use_notch    = true;
            Sweet.lollipop.decoy_databases = 1;
            // In empty comminity, relate ed is empty
            Assert.AreEqual(0, Sweet.lollipop.ed_relations.Count);

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

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

            Sweet.lollipop.decoy_proteoform_communities[Sweet.lollipop.decoy_community_name_prefix + "0"].theoretical_proteoforms.First().ExpandedProteinList = new List <ProteinWithGoTerms> {
                p1
            };
            Assert.IsEmpty(Sweet.lollipop.decoy_proteoform_communities[Sweet.lollipop.decoy_community_name_prefix + "0"].experimental_proteoforms);
            Sweet.lollipop.decoy_proteoform_communities[Sweet.lollipop.decoy_community_name_prefix + "0"].experimental_proteoforms = new ExperimentalProteoform[] { pf1 };
            pf1.modified_mass = 1000;
            pf2.modified_mass = 1000;
            Sweet.lollipop.clear_et();
            prepare_for_et(new List <double> {
                pf1.modified_mass - pf2.modified_mass
            });
            Sweet.lollipop.relate_ed();

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

            ProteoformRelation rel = Sweet.lollipop.ed_relations[Sweet.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.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_set.ptm_description, StringComparison.CurrentCultureIgnoreCase));
            Assert.AreEqual(1, rel.nearby_relations_count);
        }