public DisplayProteoformRelation(ProteoformRelation r) : base(r) { peak = r.peak; relation_type = r.RelationType; connected_proteoforms = r.connected_proteoforms; }
public void test_no_mans_land() { var e = ConstructorsForTesting.ExperimentalProteoform(""); var ee = ProteoformComparison.ExperimentalExperimental; // Small masses, tight tolerance ProteoformRelation r1 = new ProteoformRelation(e, e, ee, 0.015 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory); Assert.IsTrue(r1.outside_no_mans_land); ProteoformRelation r2 = new ProteoformRelation(e, e, ee, 0.016 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory); Assert.IsFalse(r2.outside_no_mans_land); ProteoformRelation r3 = new ProteoformRelation(e, e, ee, -0.967 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory); Assert.IsTrue(r3.outside_no_mans_land); ProteoformRelation r4 = new ProteoformRelation(e, e, ee, -0.966 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory); Assert.IsFalse(r4.outside_no_mans_land); // Larger masses, larger tolerance ProteoformRelation r5 = new ProteoformRelation(e, e, ee, 200.22 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory); Assert.IsTrue(r5.outside_no_mans_land); ProteoformRelation r6 = new ProteoformRelation(e, e, ee, 200.23 + SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory); Assert.IsFalse(r6.outside_no_mans_land); ProteoformRelation r7 = new ProteoformRelation(e, e, ee, 200.92 - SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory); Assert.IsTrue(r7.outside_no_mans_land); ProteoformRelation r8 = new ProteoformRelation(e, e, ee, 200.91 - SaveState.lollipop.peak_width_base_ee / 2, TestContext.CurrentContext.TestDirectory); Assert.IsFalse(r8.outside_no_mans_land); }
public void TestProteoformCommunityRelate_ED() { SaveState.lollipop = new Lollipop(); SaveState.lollipop.decoy_databases = 1; // In empty comminity, relate ed is empty Assert.AreEqual(0, SaveState.lollipop.ed_relations.Count); //create a decoy proteoform community SaveState.lollipop.decoy_proteoform_communities.Add(SaveState.lollipop.decoy_community_name_prefix + "0", new ProteoformCommunity()); TheoreticalProteoform pf2 = ConstructorsForTesting.make_a_theoretical("decoyProteoform1", 0, -1); SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].theoretical_proteoforms = new TheoreticalProteoform[1] { pf2 }; SaveState.lollipop.relate_ed(); // Have a single decoy community --> have single ed_relations Assert.AreEqual(1, SaveState.lollipop.ed_relations.Count); // But it's empty Assert.IsEmpty(SaveState.lollipop.ed_relations[SaveState.lollipop.decoy_community_name_prefix + "0"]); // In order to make it not empty, we must have relate_et method output a non-empty List // it must take as arguments non-empty pfs1 and pfs2 // So testProteoformCommunity.experimental_proteoforms must be non-empty // And decoy_proteoforms["fake_decoy_proteoform1"] must be non-empty ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("experimentalProteoform1"); SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].theoretical_proteoforms.First().ExpandedProteinList = new List <ProteinWithGoTerms> { p1 }; Assert.IsEmpty(SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].experimental_proteoforms); SaveState.lollipop.decoy_proteoform_communities[SaveState.lollipop.decoy_community_name_prefix + "0"].experimental_proteoforms = new ExperimentalProteoform[] { pf1 }; SaveState.lollipop.clear_et(); prepare_for_et(new List <double> { pf1.modified_mass - pf2.modified_mass }); SaveState.lollipop.relate_ed(); // Make sure there is one relation total, because only a single decoy was provided Assert.AreEqual(1, SaveState.lollipop.ed_relations.Count); Assert.IsNotEmpty(SaveState.lollipop.ed_relations); Assert.AreEqual(1, SaveState.lollipop.ed_relations[SaveState.lollipop.decoy_community_name_prefix + "0"].Count); // Make sure there is one relation for the provided fake_decoy_proteoform1 ProteoformRelation rel = SaveState.lollipop.ed_relations[SaveState.lollipop.decoy_community_name_prefix + "0"][0]; Assert.IsFalse(rel.Accepted); Assert.AreEqual("decoyProteoform1", rel.connected_proteoforms[1].accession); Assert.AreEqual(0, rel.DeltaMass); Assert.IsEmpty(((TheoreticalProteoform)rel.connected_proteoforms[1]).fragment); Assert.AreEqual(1, rel.nearby_relations_count); //shows that calculate_unadjusted_group_count works //Assert.AreEqual(1, rel.mass_difference_group.Count); //I don't think we need this test anymore w/ way peaks are made -LVS Assert.AreEqual(-1, rel.lysine_count); Assert.AreEqual("T2", ((TheoreticalProteoform)rel.connected_proteoforms[1]).name); Assert.AreEqual(0, ((ExperimentalProteoform)rel.connected_proteoforms[0]).aggregated_components.Count); //nothing aggregated with the basic constructor Assert.IsTrue(rel.outside_no_mans_land); Assert.IsNull(rel.peak); Assert.True(string.Equals("unmodified", ((TheoreticalProteoform)rel.connected_proteoforms[1]).ptm_description, StringComparison.CurrentCultureIgnoreCase)); Assert.AreEqual(1, rel.nearby_relations_count); }
public static ProteoformRelation make_relation(Proteoform p1, Proteoform p2, ProteoformComparison c, double delta_mass) { ProteoformRelation pp = new ProteoformRelation(p1, p2, c, delta_mass, TestContext.CurrentContext.TestDirectory); p1.relationships.Add(pp); p2.relationships.Add(pp); return(pp); }
public void test_write_families_regular_display() { TheoreticalProteoform t = ConstructorsForTesting.make_a_theoretical(); ExperimentalProteoform e = ConstructorsForTesting.ExperimentalProteoform("E1"); ProteoformRelation et = new ProteoformRelation(e, t, ProteoformComparison.ExperimentalTheoretical, 0, TestContext.CurrentContext.TestDirectory); et.peak = new DeltaMassPeak(et, new HashSet <ProteoformRelation> { et }); et.peak.Accepted = true; e.relationships.Add(et); t.relationships.Add(et); e.agg_intensity = 999.99; e.quant.TusherValues1.numeratorIntensitySum = 444.44m; e.quant.TusherValues1.denominatorIntensitySum = 333.33m; e.quant.intensitySum = 777.77m; List <ProteoformFamily> f = new List <ProteoformFamily> { new ProteoformFamily(e) }; f.First().construct_family(); string message = CytoscapeScript.write_cytoscape_script(f, f, TestContext.CurrentContext.TestDirectory, "", "test", null, false, false, CytoscapeScript.color_scheme_names[0], Lollipop.edge_labels[0], Lollipop.node_labels[0], CytoscapeScript.node_label_positions[0], Lollipop.node_positioning[0], 2, false, Lollipop.gene_name_labels[1]); Assert.True(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.script_file_prefix + "test" + CytoscapeScript.script_file_extension))); Assert.True(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.style_file_prefix + "test" + CytoscapeScript.style_file_extension))); Assert.True(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.node_file_prefix + "test" + CytoscapeScript.node_file_extension))); Assert.True(File.Exists(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.edge_file_prefix + "test" + CytoscapeScript.edge_file_extension))); //Check that the style xml is all there List <string> vizProperties = new List <string>(); using (XmlReader xml = XmlReader.Create(Path.Combine(TestContext.CurrentContext.TestDirectory, CytoscapeScript.style_file_prefix + "test" + CytoscapeScript.style_file_extension))) { while (xml.Read()) { switch (xml.NodeType) { case XmlNodeType.Element: if (xml.Name == "visualProperty") { vizProperties.Add(xml.GetAttribute("name")); } break; } } } Assert.AreEqual(CytoscapeScript.default_styles.Keys.Where(s => s.StartsWith("NETWORK")).Count(), vizProperties.Where(s => s.StartsWith("NETWORK")).Count()); Assert.AreEqual(CytoscapeScript.default_styles.Keys.Where(s => s.StartsWith("NODE")).Count(), vizProperties.Where(s => s.StartsWith("NODE")).Count()); Assert.AreEqual(CytoscapeScript.default_styles.Keys.Where(s => s.StartsWith("EDGE")).Count(), vizProperties.Where(s => s.StartsWith("EDGE")).Count()); Assert.AreEqual(CytoscapeScript.default_styles.Keys.Where(s => !s.StartsWith("NETWORK") && !s.StartsWith("NODE") && !s.StartsWith("EDGE")).Count(), vizProperties.Where(s => !s.StartsWith("NETWORK") && !s.StartsWith("NODE") && !s.StartsWith("EDGE")).Count()); Assert.AreEqual(CytoscapeScript.default_styles.Keys.Count, vizProperties.Count); Assert.True(message.StartsWith("Finished")); }
public void test_construct_one_proteform_family_from_ET_with_theoretical_pf_group() { ProteoformCommunity test_community = new ProteoformCommunity(); SaveState.lollipop.theoretical_database.uniprotModifications = new Dictionary <string, List <Modification> > { { "unmodified", new List <Modification> { new Modification("unmodified", "unknown") } } }; InputFile f = new InputFile("fake.txt", Purpose.ProteinDatabase); ProteinWithGoTerms p1 = new ProteinWithGoTerms("", "T1", new List <Tuple <string, string> > { new Tuple <string, string>("", "") }, new Dictionary <int, List <Modification> >(), new int?[] { 0 }, new int?[] { 0 }, new string[] { "" }, "name", "full_name", true, false, new List <DatabaseReference>(), new List <GoTerm>()); Dictionary <InputFile, Protein[]> dict = new Dictionary <InputFile, Protein[]> { { f, new Protein[] { p1 } } }; TheoreticalProteoform t = ConstructorsForTesting.make_a_theoretical("T1_T1_asdf", p1, dict); //One accepted ET relation; should give one ProteoformFamily SaveState.lollipop.min_peak_count_et = 1; ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("E1"); TheoreticalProteoformGroup pf2 = new TheoreticalProteoformGroup(new List <TheoreticalProteoform> { t }); ProteoformComparison comparison = ProteoformComparison.ExperimentalTheoretical; ProteoformRelation pr1 = new ProteoformRelation(pf1, pf2, comparison, 0, TestContext.CurrentContext.TestDirectory); pr1.Accepted = true; List <ProteoformRelation> prs = new List <ProteoformRelation> { pr1 }; foreach (ProteoformRelation pr in prs) { pr.set_nearby_group(prs, prs.Select(r => r.InstanceId).ToList()); } DeltaMassPeak peak = new DeltaMassPeak(prs[0], prs); SaveState.lollipop.et_peaks = new List <DeltaMassPeak> { peak }; test_community.experimental_proteoforms = new ExperimentalProteoform[] { pf1 }; test_community.theoretical_proteoforms = new TheoreticalProteoform[] { pf2 }; test_community.construct_families(); Assert.AreEqual(1, test_community.families.Count); Assert.AreEqual(2, test_community.families[0].proteoforms.Count); Assert.AreEqual(1, test_community.families.First().experimental_proteoforms.Count); Assert.AreEqual(1, test_community.families.First().theoretical_proteoforms.Count); Assert.AreEqual("E1", test_community.families.First().experimentals_list); Assert.AreEqual(p1.Name, test_community.families.First().name_list); Assert.AreEqual(pf2.accession, test_community.families.First().accession_list); }
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>())); }
//MAKE RELATION public static void make_relation(Proteoform p1, Proteoform p2) { ProteoformRelation pp = new ProteoformRelation(p1, p2, ProteoformComparison.ExperimentalExperimental, 0, TestContext.CurrentContext.TestDirectory); DeltaMassPeak ppp = new DeltaMassPeak(pp, new HashSet <ProteoformRelation> { pp }); pp.peak = ppp; pp.Accepted = true; ppp.Accepted = true; p1.relationships.Add(pp); p2.relationships.Add(pp); }
public void artificial_deltaMPeak() { Sweet.lollipop.theoretical_database.all_possible_ptmsets = new List <PtmSet>(); ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("E1"); ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("E2"); ProteoformComparison comparison = ProteoformComparison.ExperimentalExperimental; ProteoformRelation pr2 = new ProteoformRelation(pf3, pf4, comparison, 0, TestContext.CurrentContext.TestDirectory); ProteoformRelation pr3 = new ProteoformRelation(pf3, pf4, comparison, 0, TestContext.CurrentContext.TestDirectory); HashSet <ProteoformRelation> prs = new HashSet <ProteoformRelation> { pr2, pr3 }; Assert.AreEqual(prs, new DeltaMassPeak(pr2, prs).grouped_relations); }
public void test_construct_one_proteform_family_from_ET() { SaveState.lollipop = new Lollipop(); ProteoformCommunity test_community = new ProteoformCommunity(); SaveState.lollipop.target_proteoform_community = test_community; SaveState.lollipop.theoretical_database.uniprotModifications = new Dictionary <string, List <Modification> > { { "unmodified", new List <Modification> { new Modification("unmodified", "unknown") } } }; //One accepted ET relation; should give one ProteoformFamily SaveState.lollipop.min_peak_count_et = 1; ExperimentalProteoform pf1 = ConstructorsForTesting.ExperimentalProteoform("E1"); pf1.accepted = true; TheoreticalProteoform pf2 = ConstructorsForTesting.make_a_theoretical(); pf2.name = "T1"; ProteoformComparison comparison = ProteoformComparison.ExperimentalTheoretical; ProteoformRelation pr1 = new ProteoformRelation(pf1, pf2, comparison, 0, TestContext.CurrentContext.TestDirectory); pr1.Accepted = true; List <ProteoformRelation> prs = new List <ProteoformRelation> { pr1 }; foreach (ProteoformRelation pr in prs) { pr.set_nearby_group(prs, prs.Select(r => r.InstanceId).ToList()); } DeltaMassPeak peak = new DeltaMassPeak(prs[0], prs); SaveState.lollipop.et_peaks = new List <DeltaMassPeak> { peak }; test_community.experimental_proteoforms = new ExperimentalProteoform[] { pf1 }; test_community.theoretical_proteoforms = new TheoreticalProteoform[] { pf2 }; test_community.construct_families(); Assert.AreEqual("T1", test_community.families.First().name_list); Assert.AreEqual("T1", test_community.families.First().accession_list); Assert.AreEqual("E1", test_community.families.First().experimentals_list); Assert.AreEqual(1, test_community.families.Count); Assert.AreEqual(2, test_community.families[0].proteoforms.Count); Assert.AreEqual(1, test_community.families.First().experimental_proteoforms.Count); Assert.AreEqual(1, test_community.families.First().theoretical_proteoforms.Count); }
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 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 static void GraphRelationsChart(Chart ct, List <ProteoformRelation> relations, string series, bool gaps_zeroed) { ct.Series[series].Points.Clear(); ct.Series[series].XValueMember = "delta_mass"; ct.Series[series].YValueMembers = "nearby_relations_count"; List <ProteoformRelation> relations_ordered = relations.OrderByDescending(r => r.DeltaMass).ToList(); for (int i = 0; i < relations_ordered.Count; i++) { ProteoformRelation relation = relations_ordered[i]; ProteoformRelation next_relation = relations_ordered[i]; ct.Series[series].Points.AddXY(relation.DeltaMass, relation.nearby_relations_count); if (gaps_zeroed) { ct.Series[series].Points.AddXY(relation.DeltaMass + 1e-5, 1e-5); ct.Series[series].Points.AddXY(relation.DeltaMass - 1e-5, 1e-5); } } ct.ChartAreas[0].AxisX.Title = "Delta Mass (Da)"; ct.ChartAreas[0].AxisY.Title = "Nearby Count"; ct.ChartAreas[0].AxisX.LabelStyle.Format = "#"; ct.ChartAreas[0].AxisY.LabelStyle.Format = "#"; ct.Series[series].Color = Color.DodgerBlue; }
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 }
public void test_construct_two_families() { //Five experimental proteoforms, four relations (linear), second on not accepted into a peak, one peak; should give 2 families SaveState.lollipop = new Lollipop(); ProteoformCommunity test_community = new ProteoformCommunity(); SaveState.lollipop.target_proteoform_community = test_community; SaveState.lollipop.theoretical_database.uniprotModifications = new Dictionary <string, List <Modification> > { { "unmodified", new List <Modification> { new Modification("unmodified", "unknown") } } }; SaveState.lollipop.ee_max_mass_difference = 20; SaveState.lollipop.peak_width_base_ee = 0.015; SaveState.lollipop.min_peak_count_ee = 3; //needs to be high so that 0 peak accepted, other peak isn't.... ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("E1"); ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("E2"); ExperimentalProteoform pf5 = ConstructorsForTesting.ExperimentalProteoform("E3"); ExperimentalProteoform pf6 = ConstructorsForTesting.ExperimentalProteoform("E4"); ExperimentalProteoform pf7 = ConstructorsForTesting.ExperimentalProteoform("E5"); ProteoformComparison comparison34 = ProteoformComparison.ExperimentalExperimental; ProteoformComparison comparison45 = ProteoformComparison.ExperimentalExperimental; ProteoformComparison comparison56 = ProteoformComparison.ExperimentalExperimental; ProteoformComparison comparison67 = ProteoformComparison.ExperimentalExperimental; ProteoformRelation pr2 = new ProteoformRelation(pf3, pf4, comparison34, 0, TestContext.CurrentContext.TestDirectory); ProteoformRelation pr3 = new ProteoformRelation(pf4, pf5, comparison45, 19, TestContext.CurrentContext.TestDirectory); //not accepted ProteoformRelation pr4 = new ProteoformRelation(pf5, pf6, comparison56, 0, TestContext.CurrentContext.TestDirectory); ProteoformRelation pr5 = new ProteoformRelation(pf6, pf7, comparison67, 0, TestContext.CurrentContext.TestDirectory); List <ProteoformRelation> prs2 = new List <ProteoformRelation> { pr2, pr3, pr4, pr5 }.OrderBy(r => r.DeltaMass).ToList(); foreach (ProteoformRelation pr in prs2) { pr.set_nearby_group(prs2, prs2.Select(r => r.InstanceId).ToList()); } Assert.AreEqual(3, pr2.nearby_relations_count); Assert.AreEqual(1, pr3.nearby_relations_count); Assert.AreEqual(3, pr4.nearby_relations_count); Assert.AreEqual(3, pr5.nearby_relations_count); test_community.accept_deltaMass_peaks(prs2, new List <ProteoformRelation>()); Assert.AreEqual(2, SaveState.lollipop.ee_peaks.Count); Assert.AreEqual(1, SaveState.lollipop.ee_peaks.Where(peak => peak.Accepted).Count()); Assert.AreEqual(3, SaveState.lollipop.ee_peaks.Where(peak => peak.Accepted).First().grouped_relations.Count()); test_community.experimental_proteoforms = new ExperimentalProteoform[] { pf3, pf4, pf5, pf6, pf7 }; test_community.construct_families(); Assert.AreEqual(2, test_community.families.Count); Assert.AreEqual("", test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf3)).accession_list); Assert.AreEqual(2, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf3)).proteoforms.Count); Assert.AreEqual(2, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf3)).experimental_proteoforms.Count); Assert.AreEqual(0, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf3)).theoretical_proteoforms.Count); Assert.AreEqual("", test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf5)).accession_list); Assert.AreEqual(3, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf5)).proteoforms.Count); Assert.AreEqual(3, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf5)).experimental_proteoforms.Count); Assert.AreEqual(0, test_community.families.FirstOrDefault(f => f.proteoforms.Contains(pf5)).theoretical_proteoforms.Count); }
public void 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); } }
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); } }
public void test_accept_from_presets() { Sweet.lollipop = new Lollipop(); ProteoformCommunity test_community = new ProteoformCommunity(); Sweet.lollipop.target_proteoform_community = test_community; Sweet.lollipop.theoretical_database.uniprotModifications = new Dictionary <string, List <Modification> > { { "unmodified", new List <Modification>() { ConstructorsForTesting.get_modWithMass("unmodified", 0) } } }; //Testing the acceptance of peaks. The FDR is tested above, so I'm not going to work with that here. //Four proteoforms, three relations (linear), middle one isn't accepted; should give 2 families Sweet.lollipop.min_peak_count_ee = 2; ExperimentalProteoform pf3 = ConstructorsForTesting.ExperimentalProteoform("E1"); ExperimentalProteoform pf4 = ConstructorsForTesting.ExperimentalProteoform("E2"); ExperimentalProteoform pf5 = ConstructorsForTesting.ExperimentalProteoform("E3"); ExperimentalProteoform pf6 = ConstructorsForTesting.ExperimentalProteoform("E4"); ProteoformComparison comparison34 = ProteoformComparison.ExperimentalExperimental; ProteoformComparison comparison45 = ProteoformComparison.ExperimentalExperimental; ProteoformComparison comparison56 = ProteoformComparison.ExperimentalExperimental; ProteoformRelation pr2 = new ProteoformRelation(pf3, pf4, comparison34, 0, TestContext.CurrentContext.TestDirectory); ProteoformRelation pr3 = new ProteoformRelation(pf4, pf5, comparison45, 0, TestContext.CurrentContext.TestDirectory); ProteoformRelation pr4 = new ProteoformRelation(pf5, pf6, comparison56, 0, TestContext.CurrentContext.TestDirectory); //Test display strings Assert.AreEqual("E1", pr2.connected_proteoforms[0].accession); Assert.AreEqual("E2", pr2.connected_proteoforms[1].accession); List <ProteoformRelation> prs2 = new List <ProteoformRelation> { pr2, pr3, pr4 }; foreach (ProteoformRelation pr in prs2) { pr.set_nearby_group(prs2, prs2.Select(r => r.InstanceId).ToList()); } Assert.AreEqual(3, pr2.nearby_relations_count); Assert.AreEqual(3, pr3.nearby_relations_count); Assert.AreEqual(3, pr4.nearby_relations_count); Sweet.lollipop.theoretical_database.all_possible_ptmsets = new List <PtmSet> { new PtmSet(new List <Ptm> { new Ptm(-1, ConstructorsForTesting.get_modWithMass("unmodified", 0)) }) }; Sweet.lollipop.theoretical_database.possible_ptmset_dictionary = Sweet.lollipop.theoretical_database.make_ptmset_dictionary(); Sweet.unaccept_peak_action(pr2); using (StreamWriter file = new StreamWriter(Path.Combine(TestContext.CurrentContext.TestDirectory, "method.xml"))) file.WriteLine(Sweet.save_method()); Sweet.open_method(Path.Combine(TestContext.CurrentContext.TestDirectory, "method.xml"), string.Join(Environment.NewLine, File.ReadAllLines(Path.Combine(TestContext.CurrentContext.TestDirectory, "method.xml"))), true, out string warning); Sweet.lollipop.ee_peaks = test_community.accept_deltaMass_peaks(prs2, new List <ProteoformRelation>()); Assert.AreEqual(1, Sweet.lollipop.ee_peaks.Count); DeltaMassPeak peak = Sweet.lollipop.ee_peaks[0]; Assert.IsFalse(peak.Accepted); // <-- even though it's above the threshold Assert.AreEqual(3, peak.grouped_relations.Count); Assert.AreEqual(3, pr2.peak.peak_relation_group_count); Assert.AreEqual(0, pr2.peak.DeltaMass); Assert.AreEqual("[unmodified]", peak.possiblePeakAssignments_string); //Test that the relations in the peak are added to each of the proteoforms referenced in the peak Assert.True(pf3.relationships.Contains(pr2)); Assert.True(pf4.relationships.Contains(pr2) && pf4.relationships.Contains(pr3)); Assert.True(pf5.relationships.Contains(pr3) && pf5.relationships.Contains(pr4)); }
public void 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 }
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 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); } }