Example #1
0
        public void load_save_unlocalized()
        {
            Loaders.LoadElements();
            TheoreticalProteoformDatabase tpd  = new TheoreticalProteoformDatabase();
            List <Modification>           mods = PtmListLoader.ReadModsFromFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Mods", "ptmlist.txt"), out List <(Modification, string)> filteredModificationsWithWarnings).ToList();

            foreach (Modification m in mods)
            {
                if (!Sweet.lollipop.modification_ranks.TryGetValue(Math.Round((double)m.MonoisotopicMass, 5), out int x))
                {
                    Sweet.lollipop.modification_ranks.Add(Math.Round((double)m.MonoisotopicMass, 5), -1);
                }
            }
            tpd.unlocalized_lookup = tpd.make_unlocalized_lookup(mods);
            tpd.load_unlocalized_names(Path.Combine(TestContext.CurrentContext.TestDirectory, "Mods", "stored_mods.modnames"));
            tpd.save_unlocalized_names(Path.Combine(TestContext.CurrentContext.TestDirectory, "Mods", "fake_stored_mods.modnames"));
            Modification firstAcetyl = mods.FirstOrDefault(x => x.OriginalId.StartsWith("N-acetyl"));

            Assert.AreNotEqual(firstAcetyl.OriginalId, tpd.unlocalized_lookup[firstAcetyl].id);

            //Test amending
            mods.AddRange(PtmListLoader.ReadModsFromFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Mods", "intact_mods.txt"), out filteredModificationsWithWarnings).OfType <Modification>());
            Sweet.lollipop.modification_ranks = mods.DistinctBy(m => m.MonoisotopicMass).ToDictionary(m => Math.Round((double)m.MonoisotopicMass, 5), m => - 1);
            tpd.unlocalized_lookup            = tpd.make_unlocalized_lookup(mods.OfType <Modification>());
            tpd.amend_unlocalized_names(Path.Combine(TestContext.CurrentContext.TestDirectory, "Mods", "fake_stored_mods.modnames"));
        }
Example #2
0
        public void parallel_enter_theoreticals_doesnt_crash()
        {
            TheoreticalProteoformDatabase db = new TheoreticalProteoformDatabase();

            db.populate_aa_mass_dictionary();
            List <Modification>          var = new List <Modification>();
            List <TheoreticalProteoform> ts  = new List <TheoreticalProteoform>();
            ProteinWithGoTerms           p   = ConstructorsForTesting.make_a_theoretical().ExpandedProteinList.First();

            Parallel.Invoke(
                () => db.EnterTheoreticalProteformFamily("SEQ", p, p.OneBasedPossibleLocalizedModifications, p.Accession, ts, 1, var),
                () => db.EnterTheoreticalProteformFamily("SEQ", p, p.OneBasedPossibleLocalizedModifications, p.Accession, ts, 1, var)
                );
        }
Example #3
0
        public void group_by_mass()
        {
            TheoreticalProteoformDatabase tpd = new TheoreticalProteoformDatabase();
            List <TheoreticalProteoform>  pfs_with_mass_redundancy = new List <TheoreticalProteoform>
            {
                ConstructorsForTesting.make_a_theoretical("", 100.0, 1), // bundled
                ConstructorsForTesting.make_a_theoretical("", 100.0, 1), // bundled
                ConstructorsForTesting.make_a_theoretical("", 100.1, 1), // different mass
                ConstructorsForTesting.make_a_theoretical("", 100.0, 2)  // still gets bundled even if different lysine count
            };

            TheoreticalProteoformGroup[] x = tpd.group_proteoforms_by_mass(pfs_with_mass_redundancy);
            Assert.AreEqual(2, x.Length);
        }
Example #4
0
        public void load_save_unlocalized()
        {
            TheoreticalProteoformDatabase tpd = new TheoreticalProteoformDatabase();

            tpd.ready_to_make_database(TestContext.CurrentContext.TestDirectory);
            List <ModificationWithMass> mods = PtmListLoader.ReadModsFromFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Mods", "variable.txt")).OfType <ModificationWithMass>().ToList();

            SaveState.lollipop.modification_ranks = mods.ToDictionary(m => m.monoisotopicMass, m => - 1);
            tpd.unlocalized_lookup = tpd.make_unlocalized_lookup(mods);
            tpd.load_unlocalized_names(Path.Combine(TestContext.CurrentContext.TestDirectory, "Mods", "stored_mods.modnames"));
            tpd.save_unlocalized_names(Path.Combine(TestContext.CurrentContext.TestDirectory, "Mods", "fake_stored_mods.modnames"));
            Assert.AreNotEqual(mods.First().id, tpd.unlocalized_lookup.Values.First().id);

            //Test amending
            mods.AddRange(PtmListLoader.ReadModsFromFile(Path.Combine(TestContext.CurrentContext.TestDirectory, "Mods", "intact_mods.txt")).OfType <ModificationWithMass>());
            SaveState.lollipop.modification_ranks = mods.DistinctBy(m => m.monoisotopicMass).ToDictionary(m => m.monoisotopicMass, m => - 1);
            tpd.unlocalized_lookup = tpd.make_unlocalized_lookup(mods.OfType <ModificationWithMass>());
            tpd.amend_unlocalized_names(Path.Combine(TestContext.CurrentContext.TestDirectory, "Mods", "fake_stored_mods.modnames"));
        }
Example #5
0
        public void load_unlocalized_doesntcrash()
        {
            TheoreticalProteoformDatabase tpd = new TheoreticalProteoformDatabase();

            tpd.load_unlocalized_names(Path.Combine(TestContext.CurrentContext.TestDirectory, "asdfghjkl", "fake.txt"));
        }
Example #6
0
        public void test_not_ready_to_make_db_doesnt_crash()
        {
            TheoreticalProteoformDatabase tpd = new TheoreticalProteoformDatabase();

            tpd.get_theoretical_proteoforms(TestContext.CurrentContext.TestDirectory);
        }