Esempio n. 1
0
        public void CreateMsnTest()
        {
            var msnFeatures = new MSnFeatureToMSFeatureDAOHibernate();

            var map = new MSFeatureToMSnFeatureMap();
            map.LCMSFeatureID = 0;
            map.MSDatasetID = 0;
            map.MSFeatureID = 0;
            map.MSMSFeatureID = 0;
            map.RawDatasetID = 0;

            msnFeatures.Add(map);
        }
Esempio n. 2
0
        public void CacheFeatures(IList<UMCLight> features)
        {
            // SpectraTracker - Makes sure that we only record a MS spectra once, before we cache
            // this keeps us from trying to put duplicate entries into the MS/MS data
            // table/container.
            var spectraTracker = new Dictionary<int, MSSpectra>();
            var msmsFeatures = new List<MSSpectra>();
            var mappedPeptides = new List<DatabaseSearchSequence>();
            var sequenceMaps = new List<SequenceToMsnFeature>();

            // This dictionary makes sure that the peptide was not seen already, since a peptide can be mapped multiple times...?
            var matches = new List<MSFeatureToMSnFeatureMap>();
            var msFeatures = new List<MSFeatureLight>();
            var peptideId = 0;

            // Next we may want to map our MSn features to our parents.  This would allow us to do traceback...
            foreach (var feature in features)
            {
                var totalMsMs = 0;
                var totalIdentified = 0;
                var datasetId = feature.GroupId;
                msFeatures.AddRange(feature.MsFeatures);

                // For Each MS Feature
                foreach (var msFeature in feature.MsFeatures)
                {
                    totalMsMs += msFeature.MSnSpectra.Count;
                    // For each MS / MS
                    foreach (var spectrum in msFeature.MSnSpectra)
                    {
                        var match = new MSFeatureToMSnFeatureMap
                        {
                            RawDatasetID = datasetId,
                            MSDatasetID = datasetId,
                            MSFeatureID = msFeature.Id,
                            MSMSFeatureID = spectrum.Id,
                            LCMSFeatureID = feature.Id
                        };
                        spectrum.GroupId = datasetId;
                        matches.Add(match);

                        if (spectraTracker.ContainsKey(spectrum.Id))
                            continue;

                        msmsFeatures.Add(spectrum);
                        spectraTracker.Add(spectrum.Id, spectrum);

                        // We are prepping the sequences that we found from peptides that were
                        // matched only, not all of the results.
                        // These maps here are made to help establish database search results to msms
                        // spectra
                        foreach (var peptide in spectrum.Peptides)
                        {
                            peptide.GroupId = datasetId;
                            var newPeptide = new DatabaseSearchSequence(peptide, feature.Id)
                            {
                                GroupId = datasetId,
                                Id = peptideId++
                            };
                            mappedPeptides.Add(newPeptide);

                            var sequenceMap = new SequenceToMsnFeature
                            {
                                UmcFeatureId = feature.Id,
                                DatasetId = msFeature.GroupId,
                                MsnFeatureId = spectrum.Id,
                                SequenceId = peptide.Id
                            };
                            sequenceMaps.Add(sequenceMap);
                        }

                        totalIdentified += spectrum.Peptides.Count;
                    }
                }

                feature.MsMsCount = totalMsMs;
                feature.IdentifiedSpectraCount = totalIdentified;
            }

            var count = 0;
            //TODO: Fix!!! make sure sequence maps are unique
            sequenceMaps.ForEach(x => x.Id = count++);

            if (msmsFeatures.Count > 0)
                Providers.MSnFeatureCache.AddAll(msmsFeatures);

            if (matches.Count > 0)
                Providers.MSFeatureToMSnFeatureCache.AddAll(matches);

            if (sequenceMaps.Count > 0)
                Providers.SequenceMsnMapCache.AddAll(sequenceMaps);

            if (mappedPeptides.Count > 0)
                Providers.DatabaseSequenceCache.AddAll(mappedPeptides);

            if (msFeatures.Count > 0)
                Providers.MSFeatureCache.AddAll(msFeatures);
            Providers.FeatureCache.AddAll(features);
        }