public MassTagDatabase LoadDatabase()
        {
            var database = new MassTagDatabase();
            var massTags = new List<MassTagLight>();
            var masstagMap = new Dictionary<int, List<Protein>>();

            //TODO: Put into base table file reader
            var lines = File.ReadAllLines(DatabasePath);

            var delimiters = new[] {"\t"};

            for (var i = 1; i < lines.Length; i++)
            {
                var data = lines[i].Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                var tag = new MassTagLight();
                if (data.Length > 4)
                {
                    tag.Id = Convert.ToInt32(data[0]);
                    tag.PeptideSequence = data[1];
                    tag.MassMonoisotopic = Convert.ToDouble(data[2]);
                    tag.Net = Convert.ToDouble(data[3]);
                    tag.DriftTime = Convert.ToDouble(data[4]);
                }
                massTags.Add(tag);
            }

            database.AddMassTagsAndProteins(massTags, masstagMap);
            return database;
        }
Exemple #2
0
        public MassTagDatabase LoadDatabase()
        {
            var database   = new MassTagDatabase();
            var massTags   = new List <MassTagLight>();
            var masstagMap = new Dictionary <int, List <Protein> >();

            //TODO: Put into base table file reader
            var lines = File.ReadAllLines(DatabasePath);

            var delimiters = new[] { "\t" };

            for (var i = 1; i < lines.Length; i++)
            {
                var data = lines[i].Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                var tag  = new MassTagLight();
                if (data.Length > 4)
                {
                    tag.Id = Convert.ToInt32(data[0]);
                    tag.PeptideSequence  = data[1];
                    tag.MassMonoisotopic = Convert.ToDouble(data[2]);
                    tag.Net       = Convert.ToDouble(data[3]);
                    tag.DriftTime = Convert.ToDouble(data[4]);
                }
                massTags.Add(tag);
            }

            database.AddMassTagsAndProteins(massTags, masstagMap);
            return(database);
        }
        /// <summary>
        ///     Loads the mass tag database from the underlying database system.
        /// </summary>
        /// <returns></returns>
        public virtual MassTagDatabase LoadDatabase()
        {
            var database = new MassTagDatabase();
            var tags = LoadMassTags();
            var proteinMap = LoadProteins();

            database.AddMassTagsAndProteins(tags, proteinMap);

            return database;
        }
Exemple #4
0
        /// <summary>
        ///     Loads the mass tag database from the underlying database system.
        /// </summary>
        /// <returns></returns>
        public virtual MassTagDatabase LoadDatabase()
        {
            var database   = new MassTagDatabase();
            var tags       = LoadMassTags();
            var proteinMap = LoadProteins();

            database.AddMassTagsAndProteins(tags, proteinMap);

            return(database);
        }
        public MassTagDatabase LoadDatabase()
        {
            var database = new MassTagDatabase();

            var sink = new MAGEMetaSampleDatabaseSink();
            var reader = new DelimitedFileReader();

            reader.Delimiter = ",";
            reader.FilePath = Path;

            var pipeline = ProcessingPipeline.Assemble("MetaSample", reader, sink);
            pipeline.RunRoot(null);

            var tags =
                sink.MassTags.FindAll(
                    delegate(MassTagLight x) { return x.ObservationCount >= m_options.MinimumObservationCountFilter; });

            database.AddMassTagsAndProteins(tags, new Dictionary<int, List<Protein>>());

            // Fill in logic to read new type of mass tag database.
            return database;
        }
Exemple #6
0
        public MassTagDatabase LoadDatabase()
        {
            var database = new MassTagDatabase();


            var sink   = new MAGEMetaSampleDatabaseSink();
            var reader = new DelimitedFileReader();

            reader.Delimiter = ",";
            reader.FilePath  = Path;

            var pipeline = ProcessingPipeline.Assemble("MetaSample", reader, sink);

            pipeline.RunRoot(null);



            var tags = sink.MassTags.Where(x => x.ObservationCount >= m_options.MinimumObservationCountFilter);

            database.AddMassTagsAndProteins(tags.ToList(), new Dictionary <int, List <Protein> >());

            // Fill in logic to read new type of mass tag database.
            return(database);
        }
        public MassTagDatabase LoadDatabase()
        {
            var database = new MassTagDatabase();

            //Implement the loading / reading of the MTDB Framework objects.

            var reader          = new SqLiteTargetDatabaseReader();
            var mtdbDatabase    = reader.ReadDb(m_path);
            var massTags        = new List<MassTagLight>();

            // Mapping objects to create unique proteins and for the mass tag database to load only those proteins for
            // the given consensus targets/mass tags.
            var proteinMap          = new Dictionary<int, Protein>();
            var massTagProteinMap   = new Dictionary<int, List<Protein>>();

            if (mtdbDatabase == null)
                return database;

            foreach (var target in mtdbDatabase.ConsensusTargets)
            {
                // Copy the consensus data into a mass tag light.
                var tag = new MassTagLight
                {
                    Id = target.Id,
                    MassMonoisotopic = target.TheoreticalMonoIsotopicMass,
                    NetAverage = target.AverageNet,
                    NetPredicted = target.PredictedNet,
                    PeptideSequence = target.Sequence,
                    NetStandardDeviation = target.StdevNet
                };

                // Here we create unique proteins for the mass tag copying information from the consensus target proteins.
                var proteinsForMassTag = new List<Protein>();
                foreach (var targetProtein in target.Proteins)
                {
                    if (!proteinMap.ContainsKey(targetProtein.Id))
                    {
                        var newProtein = new Protein
                        {
                            Id = targetProtein.Id,
                            Name = targetProtein.ProteinName,
                            ResidueStartPosition = targetProtein.ResidueStart,
                            ResidueEndPosition = targetProtein.ResidueEnd
                        };
                        //TODO: Do something about the cleavage state and terminus state of a protein loaded from MTDBCreator database.
                        //protein.CleavageState = ??
                        //protein.TerminusState = ??

                        proteinMap.Add(newProtein.Id, newProtein);
                    }

                    var protein = proteinMap[targetProtein.Id];
                    proteinsForMassTag.Add(protein);
                }

                massTagProteinMap.Add(tag.Id, proteinsForMassTag);
                massTags.Add(tag);
            }

            database.AddMassTagsAndProteins(massTags, massTagProteinMap);
            return database;
        }
        public MassTagDatabase LoadDatabase()
        {
            var database = new MassTagDatabase {Name = ""};

            UpdateStatus("Loading all of the mass tags.");
            // Get all of the mass tags
            var massTags = Provider.FindAll();

            UpdateStatus("Loading all of the tag to protein references.");
            // Then get all of the mass tag to protein maps
            IGenericDAO<MassTagToProteinMap> tagToProteinMapCache = new GenericDAOHibernate<MassTagToProteinMap>();
            var maps = tagToProteinMapCache.FindAll();

            // Then get all of the proteins
            UpdateStatus("Loading all of the protein data.");
            IProteinDAO proteinCache = new ProteinDAO();
            var proteins = proteinCache.FindAll();

            UpdateStatus("Indexing the protein data for faster assembly.");
            var proteinMap = new Dictionary<int, Protein>();
            foreach (var p in proteins)
            {
                if (!proteinMap.ContainsKey(p.ProteinId))
                {
                    proteinMap.Add(p.ProteinId, p);
                }
            }

            var matchedMaps = new Dictionary<int, List<MassTagToProteinMap>>();

            foreach (var singleMap in maps)
            {
                if (!matchedMaps.ContainsKey(singleMap.MassTagId))
                {
                    matchedMaps.Add(singleMap.MassTagId, new List<MassTagToProteinMap>());
                }
                matchedMaps[singleMap.MassTagId].Add(singleMap);
            }

            UpdateStatus("Re-mapping the proteins to the mass tags.");
            var massTagProteinMap = new Dictionary<int, List<Protein>>();

            // Then map them.
            foreach (var tag in massTags)
            {
                var id = tag.Id;

                if (!massTagProteinMap.ContainsKey(id))
                {
                    massTagProteinMap.Add(id, new List<Protein>());
                }

                var matches = new List<MassTagToProteinMap>();

                if (matchedMaps.ContainsKey(id))
                {
                    matches = matchedMaps[id];
                }

                var newProteins = new List<Protein>();
                foreach (var mtMap in matches)
                {
                    if (proteinMap.ContainsKey(mtMap.ProteinId))
                    {
                        newProteins.Add(proteinMap[mtMap.ProteinId]);
                    }
                }
                massTagProteinMap[id].AddRange(newProteins);
            }

            UpdateStatus("Building the in memory mass tag database.");
            database.AddMassTagsAndProteins(massTags, massTagProteinMap);
            database.AllProteins = proteins;

            var totalMassTags = database.MassTags.Count;
            UpdateStatus("Loaded " + totalMassTags + " mass tags.");

            return database;
        }
Exemple #9
0
        /// <summary>
        /// Load a Liquid lipd MS/MS search results file as a MultiAlign
        /// <see cref="MassTagDatabase" />.
        /// </summary>
        /// <returns>The resulting mass tag database.</returns>
        /// <exception cref="FormatException">
        /// Throws a format exception when there are missing headers, or
        /// a non-numeric value was found in a column that was expected to be numeric.
        /// </exception>
        public MassTagDatabase LoadDatabase()
        {
            var headers = new Dictionary <string, int>();

            var massTags = new List <MassTagLight>();

            // Mapping between protein (actually lipid) name, to protein object (currently represents lipids).
            var commonNameToProtein = new Dictionary <string, Protein>();

            int lipidId = 0;

            // Parse lines of file into mass tags.
            int lineCount = 0;

            foreach (var line in File.ReadLines(this.filePath))
            {
                var parts = line.Split('\t');
                if (lineCount++ == 0)
                {   // Header line, store header indices
                    for (int i = 0; i < parts.Length; i++)
                    {
                        headers.Add(parts[i], i);
                    }

                    // Make sure all of the headers we are expecting are actually in the file.
                    this.DetectMissingHeaders(headers);
                    continue;
                }

                var net  = Convert.ToDouble(parts[headers["NET"]]);
                var mz   = Convert.ToDouble(parts[headers["Exact m/z"]]);
                var mass = mz - Constants.Proton;

                var name    = parts[headers["Common Name"]];
                var formula = parts[headers["Formula"]];

                // Add lipid to mapping if it isn't already there
                if (!commonNameToProtein.ContainsKey(name))
                {
                    commonNameToProtein.Add(
                        name,
                        new Protein
                    {
                        Id               = lipidId++,
                        ChargeState      = 1,
                        ChemicalFormula  = formula,
                        MassMonoisotopic = mass,
                        Mz               = mz,
                        Name             = name,
                        Sequence         = formula,
                    });
                }

                // Data line, create mass tag
                massTags.Add(
                    new MassTagLight
                {                                            // TODO: We have lipid data now, we're not doing just proteomics anymore. We should have omic-independent names for this stuff.
                    Id                      = lineCount - 2, // Subtract 2 because i will be incremented once when it sees the headers, and once before it gets to this line
                    ProteinName             = name,
                    PeptideSequence         = formula,
                    Net                     = net,
                    NetAligned              = net,
                    NetAverage              = net,
                    NetPredicted            = net,
                    MassMonoisotopic        = mass,
                    MassMonoisotopicAligned = mass,
                    Mz                      = mz,
                });
            }

            // Mapping from masstags to proteins (actually lipids)
            var massTagToProtein = new Dictionary <int, List <Protein> >();

            // Create mappings.
            foreach (var massTag in massTags)
            {
                var protein = commonNameToProtein[massTag.ProteinName];

                massTagToProtein.Add(massTag.Id, new List <Protein>());
                massTagToProtein[massTag.Id].Add(protein);
            }

            // Finally, create the mass tag database.
            var massTagDatabase = new MassTagDatabase();

            massTagDatabase.AddMassTagsAndProteins(massTags, massTagToProtein);

            return(massTagDatabase);
        }
Exemple #10
0
        public MassTagDatabase LoadDatabase()
        {
            var database = new MassTagDatabase();

            //Implement the loading / reading of the MTDB Framework objects.

            var reader       = new SqLiteTargetDatabaseReader();
            var mtdbDatabase = reader.ReadDb(m_path);
            var massTags     = new List <MassTagLight>();

            // Mapping objects to create unique proteins and for the mass tag database to load only those proteins for
            // the given consensus targets/mass tags.
            var proteinMap        = new Dictionary <int, Protein>();
            var massTagProteinMap = new Dictionary <int, List <Protein> >();

            if (mtdbDatabase == null)
            {
                return(database);
            }

            foreach (var target in mtdbDatabase.ConsensusTargets)
            {
                // Copy the consensus data into a mass tag light.
                var tag = new MassTagLight
                {
                    Id = target.Id,
                    MassMonoisotopic     = target.TheoreticalMonoIsotopicMass,
                    NetAverage           = target.AverageNet,
                    NetPredicted         = target.PredictedNet,
                    PeptideSequence      = target.Sequence,
                    NetStandardDeviation = target.StdevNet
                };


                // Here we create unique proteins for the mass tag copying information from the consensus target proteins.
                var proteinsForMassTag = new List <Protein>();
                foreach (var targetProtein in target.Proteins)
                {
                    if (!proteinMap.ContainsKey(targetProtein.Id))
                    {
                        var newProtein = new Protein
                        {
                            Id   = targetProtein.Id,
                            Name = targetProtein.ProteinName,
                            ResidueStartPosition = targetProtein.ResidueStart,
                            ResidueEndPosition   = targetProtein.ResidueEnd
                        };
                        //TODO: Do something about the cleavage state and terminus state of a protein loaded from MTDBCreator database.
                        //protein.CleavageState = ??
                        //protein.TerminusState = ??

                        proteinMap.Add(newProtein.Id, newProtein);
                    }

                    var protein = proteinMap[targetProtein.Id];
                    proteinsForMassTag.Add(protein);
                }

                massTagProteinMap.Add(tag.Id, proteinsForMassTag);
                massTags.Add(tag);
            }

            database.AddMassTagsAndProteins(massTags, massTagProteinMap);
            return(database);
        }
Exemple #11
0
        public MassTagDatabase LoadDatabase()
        {
            var database = new MassTagDatabase {
                Name = ""
            };

            UpdateStatus("Loading all of the mass tags.");
            // Get all of the mass tags
            var massTags = Provider.FindAll();


            UpdateStatus("Loading all of the tag to protein references.");
            // Then get all of the mass tag to protein maps
            IGenericDAO <MassTagToProteinMap> tagToProteinMapCache = new GenericDAOHibernate <MassTagToProteinMap>();
            var maps = tagToProteinMapCache.FindAll();

            // Then get all of the proteins
            UpdateStatus("Loading all of the protein data.");
            IProteinDAO proteinCache = new ProteinDAO();
            var         proteins     = proteinCache.FindAll();

            UpdateStatus("Indexing the protein data for faster assembly.");
            var proteinMap = new Dictionary <int, Protein>();

            foreach (var p in proteins)
            {
                if (!proteinMap.ContainsKey(p.ProteinId))
                {
                    proteinMap.Add(p.ProteinId, p);
                }
            }

            var matchedMaps = new Dictionary <int, List <MassTagToProteinMap> >();

            foreach (var singleMap in maps)
            {
                if (!matchedMaps.ContainsKey(singleMap.MassTagId))
                {
                    matchedMaps.Add(singleMap.MassTagId, new List <MassTagToProteinMap>());
                }
                matchedMaps[singleMap.MassTagId].Add(singleMap);
            }

            UpdateStatus("Re-mapping the proteins to the mass tags.");
            var massTagProteinMap = new Dictionary <int, List <Protein> >();

            // Then map them.
            foreach (var tag in massTags)
            {
                var id = tag.Id;

                if (!massTagProteinMap.ContainsKey(id))
                {
                    massTagProteinMap.Add(id, new List <Protein>());
                }

                var matches = new List <MassTagToProteinMap>();

                if (matchedMaps.ContainsKey(id))
                {
                    matches = matchedMaps[id];
                }

                var newProteins = new List <Protein>();
                foreach (var mtMap in matches)
                {
                    if (proteinMap.ContainsKey(mtMap.ProteinId))
                    {
                        newProteins.Add(proteinMap[mtMap.ProteinId]);
                    }
                }
                massTagProteinMap[id].AddRange(newProteins);
            }

            UpdateStatus("Building the in memory mass tag database.");
            database.AddMassTagsAndProteins(massTags, massTagProteinMap);
            database.AllProteins = proteins;

            var totalMassTags = database.MassTags.Count;

            UpdateStatus("Loaded " + totalMassTags + " mass tags.");

            return(database);
        }