예제 #1
0
        private static void LoadGlycans()
        {
            OGlycanLocations = new List <string>();
            NGlycanLocations = new List <string>();

            foreach (var glycanFile in Directory.GetFiles(Path.Combine(DataDir, @"Glycan_Mods", @"OGlycan")))
            {
                OGlycanLocations.Add(glycanFile);
            }

            foreach (var glycanFile in Directory.GetFiles(Path.Combine(DataDir, @"Glycan_Mods", @"NGlycan")))
            {
                NGlycanLocations.Add(glycanFile);
            }

            //Add Glycan mod into AllModsKnownDictionary, currently this is for MetaDraw.
            //The reason why not include Glycan into modification database is for users to apply their own database.
            foreach (var path in OGlycanLocations)
            {
                var og = GlycanDatabase.LoadGlycan(path, false, false);
                foreach (var g in og)
                {
                    var ogmod = Glycan.OGlycanToModification(g);
                    if (!AllModsKnownDictionary.ContainsKey(ogmod.IdWithMotif))
                    {
                        AllModsKnownDictionary.Add(ogmod.IdWithMotif, ogmod);
                    }
                }
            }
            foreach (var path in NGlycanLocations)
            {
                var og = GlycanDatabase.LoadGlycan(path, false, false);
                foreach (var g in og)
                {
                    var ogmod = Glycan.OGlycanToModification(g);
                    if (!AllModsKnownDictionary.ContainsKey(ogmod.IdWithMotif))
                    {
                        AllModsKnownDictionary.Add(ogmod.IdWithMotif, ogmod);
                    }
                }
            }
        }
예제 #2
0
        static GlobalVariables()
        {
            MetaMorpheusVersion = typeof(GlobalVariables).Assembly.GetName().Version.ToString();

            if (MetaMorpheusVersion.Equals("1.0.0.0"))
            {
#if DEBUG
                MetaMorpheusVersion = "Not a release version. DEBUG.";
#else
                MetaMorpheusVersion = "Not a release version.";
#endif
            }
            else
            {
                // as of 0.0.277, AppVeyor appends the build number
                // this is intentional; it's to avoid conflicting AppVeyor build numbers
                // trim the build number off the version number for displaying/checking versions, etc
                var foundIndexes = new List <int>();
                for (int i = 0; i < MetaMorpheusVersion.Length; i++)
                {
                    if (MetaMorpheusVersion[i] == '.')
                    {
                        foundIndexes.Add(i);
                    }
                }
                MetaMorpheusVersion = MetaMorpheusVersion.Substring(0, foundIndexes.Last());
            }

            {
                var pathToProgramFiles = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
                if (!String.IsNullOrWhiteSpace(pathToProgramFiles) && AppDomain.CurrentDomain.BaseDirectory.Contains(pathToProgramFiles) && !AppDomain.CurrentDomain.BaseDirectory.Contains("Jenkins"))
                {
                    DataDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "MetaMorpheus");
                }
                else
                {
                    DataDir = AppDomain.CurrentDomain.BaseDirectory;
                }
            }

            ElementsLocation = Path.Combine(DataDir, @"Data", @"elements.dat");
            UsefulProteomicsDatabases.Loaders.LoadElements();

            AddSeparationTypes(new List <string> {
                { "HPLC" }, { "CZE" }
            });

            // load default crosslinkers
            string crosslinkerLocation = Path.Combine(DataDir, @"Data", @"Crosslinkers.tsv");
            AddCrosslinkers(Crosslinker.LoadCrosslinkers(crosslinkerLocation));

            // load custom crosslinkers
            string customCrosslinkerLocation = Path.Combine(DataDir, @"Data", @"CustomCrosslinkers.tsv");
            if (File.Exists(customCrosslinkerLocation))
            {
                AddCrosslinkers(Crosslinker.LoadCrosslinkers(customCrosslinkerLocation));
            }


            OGlycanLocations = new List <string>();
            foreach (var glycanFile in Directory.GetFiles(Path.Combine(DataDir, @"Glycan_Mods", @"OGlycan")))
            {
                OGlycanLocations.Add(glycanFile);
            }
            NGlycanLocations = new List <string>();
            foreach (var glycanFile in Directory.GetFiles(Path.Combine(DataDir, @"Glycan_Mods", @"NGlycan")))
            {
                NGlycanLocations.Add(glycanFile);
            }

            ExperimentalDesignFileName = "ExperimentalDesign.tsv";

            UnimodDeserialized = UsefulProteomicsDatabases.Loaders.LoadUnimod(Path.Combine(DataDir, @"Data", @"unimod.xml")).ToList();
            PsiModDeserialized = UsefulProteomicsDatabases.Loaders.LoadPsiMod(Path.Combine(DataDir, @"Data", @"PSI-MOD.obo.xml"));
            var formalChargesDictionary = UsefulProteomicsDatabases.Loaders.GetFormalChargesDictionary(PsiModDeserialized);
            UniprotDeseralized = UsefulProteomicsDatabases.Loaders.LoadUniprot(Path.Combine(DataDir, @"Data", @"ptmlist.txt"), formalChargesDictionary).ToList();

            foreach (var modFile in Directory.GetFiles(Path.Combine(DataDir, @"Mods")))
            {
                AddMods(UsefulProteomicsDatabases.PtmListLoader.ReadModsFromFile(modFile, out var errorMods), false);
            }

            AddMods(UniprotDeseralized.OfType <Modification>(), false);
            AddMods(UnimodDeserialized.OfType <Modification>(), false);

            // populate dictionaries of known mods/proteins for deserialization
            AllModsKnownDictionary = new Dictionary <string, Modification>();
            foreach (Modification mod in AllModsKnown)
            {
                if (!AllModsKnownDictionary.ContainsKey(mod.IdWithMotif))
                {
                    AllModsKnownDictionary.Add(mod.IdWithMotif, mod);
                }
                // no error thrown if multiple mods with this ID are present - just pick one
            }

            //Add Glycan mod into AllModsKnownDictionary, currently this is for MetaDraw.
            //The reason why not include Glycan into modification database is for users to apply their own database.
            foreach (var path in OGlycanLocations)
            {
                var og = GlycanDatabase.LoadGlycan(path, false, false);
                foreach (var g in og)
                {
                    var ogmod = Glycan.OGlycanToModification(g);
                    if (!AllModsKnownDictionary.ContainsKey(ogmod.IdWithMotif))
                    {
                        AllModsKnownDictionary.Add(ogmod.IdWithMotif, ogmod);
                    }
                }
            }
            foreach (var path in NGlycanLocations)
            {
                var og = GlycanDatabase.LoadGlycan(path, false, false);
                foreach (var g in og)
                {
                    var ogmod = Glycan.OGlycanToModification(g);
                    if (!AllModsKnownDictionary.ContainsKey(ogmod.IdWithMotif))
                    {
                        AllModsKnownDictionary.Add(ogmod.IdWithMotif, ogmod);
                    }
                }
            }

            RefreshAminoAcidDictionary();

            string settingsPath = Path.Combine(DataDir, @"settings.toml");
            if (!File.Exists(settingsPath))
            {
                Toml.WriteFile <GlobalSettings>(new GlobalSettings(), settingsPath);
            }

            GlobalSettings = Toml.ReadFile <GlobalSettings>(settingsPath);
            AllSupportedDissociationTypes = new Dictionary <string, DissociationType> {
                { DissociationType.CID.ToString(), DissociationType.CID },
                { DissociationType.ECD.ToString(), DissociationType.ECD },
                { DissociationType.ETD.ToString(), DissociationType.ETD },
                { DissociationType.HCD.ToString(), DissociationType.HCD },
                { DissociationType.EThcD.ToString(), DissociationType.EThcD },
                { DissociationType.Custom.ToString(), DissociationType.Custom },
                { DissociationType.LowCID.ToString(), DissociationType.LowCID }

                // TODO: allow reading from scan header (autodetect dissociation type)
            };
        }