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); }
public void CacheFeatures(IList <UMCLight> features, IProgress <ProgressData> progress = null) { // 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++); var progData = new ProgressData(progress); var internalProgress = new Progress <ProgressData>(pd => progData.Report(pd.Percent)); ////if (msmsFeatures.Count > 0) ////{ //// progData.StepRange(1); //// Providers.MSnFeatureCache.AddAll(msmsFeatures, internalProgress); ////} ////if (matches.Count > 0) ////{ //// progData.StepRange(2); //// Providers.MSFeatureToMSnFeatureCache.AddAll(matches, internalProgress); ////} if (sequenceMaps.Count > 0) { progData.StepRange(3); Providers.SequenceMsnMapCache.AddAll(sequenceMaps, internalProgress); } if (mappedPeptides.Count > 0) { progData.StepRange(4); Providers.DatabaseSequenceCache.AddAll(mappedPeptides, internalProgress); } ////if (msFeatures.Count > 0) ////{ //// progData.StepRange(99); //// Providers.MSFeatureCache.DeleteByDatasetId(msFeatures[0].GroupId); //// Providers.MSFeatureCache.AddAllStateless(msFeatures, internalProgress); ////} if (features.Count > 0) { progData.StepRange(100); Providers.FeatureCache.DeleteByDataset(features[0].GroupId); Providers.FeatureCache.AddAllStateless(features, internalProgress); } }