Exemplo n.º 1
0
        public static Crosslinker ParseCrosslinkerFromString(string line)
        {
            var  split     = line.Split('\t');
            bool cleavable = true;

            if (split[3] == "F")
            {
                cleavable = false;
            }

            Crosslinker crosslinker = new Crosslinker(
                crosslinkerName: split[0],
                crosslinkerModSites: split[1],
                crosslinkerModSites2: split[2],
                cleavable: cleavable,
                dissociationTypes: split[4],
                totalMass: double.Parse(split[5]),
                cleaveMassShort: double.Parse(split[6]),
                cleaveMassLong: double.Parse(split[7]),
                loopMass: double.Parse(split[5]),
                deadendMassH2O: double.Parse(split[8]),
                deadendMassNH2: double.Parse(split[9]),
                deadendMassTris: double.Parse(split[10]));

            return(crosslinker);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Deadend and loop crosslink are changed to a type of modification and searched as a modified peptide.
 /// </summary>
 /// <param name="crosslinker"></param>
 public static void GenerateCrosslinkModifications(Crosslinker crosslinker, out Modification TrisDeadEnd, out Modification H2ODeadEnd, out Modification NH2DeadEnd, out Modification Loop)
 {
     ModificationMotif.TryGetMotif("X", out var motif);
     TrisDeadEnd = new Modification(_originalId: "Tris Dead End", _modificationType: "Crosslink", _locationRestriction: "Anywhere.", _target: motif, _monoisotopicMass: crosslinker.DeadendMassTris);
     H2ODeadEnd  = new Modification(_originalId: "H2O Dead End", _modificationType: "Crosslink", _locationRestriction: "Anywhere.", _target: motif, _monoisotopicMass: crosslinker.DeadendMassH2O);
     NH2DeadEnd  = new Modification(_originalId: "NH2 Dead End", _modificationType: "Crosslink", _locationRestriction: "Anywhere.", _target: motif, _monoisotopicMass: crosslinker.DeadendMassNH2);
     Loop        = new Modification(_originalId: "Loop", _modificationType: "Crosslink", _locationRestriction: "Anywhere.", _target: motif, _monoisotopicMass: crosslinker.LoopMass);
 }
Exemplo n.º 3
0
        private static void LoadCrosslinkers()
        {
            _KnownCrosslinkers = new List <Crosslinker>();

            // 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));
            }
        }
Exemplo n.º 4
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)
            };
        }