/// <summary> /// Gets an XIC using the <see cref="InformedProteomicsReader" />. /// </summary> /// <param name="feature">The feature to get the XIC for.</param> /// <returns>The XIC.</returns> private List <List <MSFeatureLight> > GetXic(UMCLight feature) { var xics = new List <List <MSFeatureLight> >(); var ipr = this.rawProvider.GetScanSummaryProvider(feature.GroupId) as InformedProteomicsReader; if (ipr != null) { var lcms = ipr.LcMsRun; for (int charge = feature.MinCharge; charge <= feature.MaxCharge; charge++) { var mz = (feature.MassMonoisotopicAligned + charge * Constants.Proton) / charge; var xic = lcms.GetFullPrecursorIonExtractedIonChromatogram(mz, new Tolerance(10, ToleranceUnit.Ppm)) .Where(xicP => xicP.ScanNum >= feature.ScanStart && xicP.ScanNum <= feature.ScanEnd) .ToList(); var msFeatures = xic.Select( xicPoint => new MSFeatureLight { GroupId = feature.GroupId, Scan = xicPoint.ScanNum, Net = ipr.GetScanSummary(xicPoint.ScanNum).Net, Abundance = xicPoint.Intensity, ChargeState = charge, }).ToList(); xics.Add(msFeatures); } } return(xics); }
private List <UMCLight> GetClusterData(string path) { var data = File.ReadLines(path).ToList(); // Remove the header data.RemoveAt(0); var features = new List <UMCLight>(); foreach (var line in data) { var lineData = line.Split(new[] { "\t" }, StringSplitOptions.RemoveEmptyEntries).ToList(); var feature = new UMCLight(); feature.ClusterId = Convert.ToInt32(lineData[0]); feature.GroupId = Convert.ToInt32(lineData[1]); feature.Id = Convert.ToInt32(lineData[2]); feature.MassMonoisotopicAligned = Convert.ToDouble(lineData[3]); feature.Net = Convert.ToDouble(lineData[4]); feature.DriftTime = Convert.ToDouble(lineData[5]); feature.ChargeState = Convert.ToInt32(lineData[6]); features.Add(feature); } return(features); }
public UMCTreeViewModel(UMCLight feature, UMCCollectionTreeViewModel parent) { m_feature = feature; m_parent = parent; var information = SingletonDataProviders.GetDatasetInformation(m_feature.GroupId); if (information != null) { Name = information.DatasetName; } else { Name = string.Format("Dataset {0}", m_feature.GroupId); } AddStatistic("Id", m_feature.Id); AddStatistic("Dataset Id", m_feature.GroupId); AddStatistic("Mass", m_feature.MassMonoisotopicAligned, "N2"); AddStatistic("NET", m_feature.Net, "N2"); if (m_feature.DriftTime > 0) { AddStatistic("Drift Time", m_feature.DriftTime, "N2"); } AddStatistic("Charge", m_feature.ChargeState); }
public void CalculateStatisticsMultipleNet(ClusterCentroidRepresentation representation) { var cluster = new UMCClusterLight(); cluster.UmcList = new List <UMCLight>(); var umc = new UMCLight(); umc.MassMonoisotopicAligned = 100; umc.Net = 100; umc.DriftTime = 100; umc.ChargeState = 2; umc.Abundance = 100; cluster.UmcList.Add(umc); var umc2 = new UMCLight(); umc2.MassMonoisotopicAligned = 100; umc2.Net = 200; umc2.DriftTime = 100; umc2.ChargeState = 2; umc2.Abundance = 100; cluster.UmcList.Add(umc2); cluster.CalculateStatistics(representation); Assert.AreEqual(150, cluster.Net); }
public IDictionary <int, IList <MSFeatureLight> > CreateXic(UMCLight feature, double massError, ISpectraProvider provider) { var features = new Dictionary <int, IList <MSFeatureLight> >(); var chargeFeatures = feature.CreateChargeMap(); // For each UMC... foreach (var charge in chargeFeatures.Keys) { // Find the mininmum and maximum features var msFeatures = CreateXic(chargeFeatures[charge], massError, provider); features.Add(charge, new List <MSFeatureLight>()); foreach (var newFeature in msFeatures) { // Here we ask if this is a new MS Feature or old... if (!chargeFeatures.ContainsKey(newFeature.Scan)) { // Otherwise add the new feature newFeature.MassMonoisotopic = feature.MassMonoisotopic; newFeature.DriftTime = feature.DriftTime; newFeature.GroupId = feature.GroupId; } features[charge].Add(newFeature); } } return(features); }
private void UpdateCharges(UMCLight feature) { Charges.Clear(); m_scanMaps = feature.CreateChargeMap(); foreach (var charge in m_scanMaps.Keys) { double mz = 0; var minScan = int.MaxValue; var maxScan = int.MinValue; double maxIntensity = 0; foreach (var msFeature in m_scanMaps[charge]) { minScan = Math.Min(minScan, msFeature.Scan); maxScan = Math.Max(maxScan, msFeature.Scan); if (maxIntensity >= msFeature.Abundance) { continue; } maxIntensity = msFeature.Abundance; mz = msFeature.Mz; } Charges.Add(new ChargeStateViewModel(charge, mz, minScan, maxScan)); } if (Charges.Count <= 0) { return; } SelectedCharge = Charges[0]; }
public void CalculateStatisticsTestSingleUmc(double umcMass, double umcNet, float umcDriftTime, int umcCharge, int umcAbundance, ClusterCentroidRepresentation representation) { var cluster = new UMCClusterLight { UmcList = new List <UMCLight>() }; var umc = new UMCLight { MassMonoisotopicAligned = umcMass, Net = umcNet, DriftTime = umcDriftTime, ChargeState = umcCharge, Abundance = umcAbundance }; cluster.UmcList.Add(umc); cluster.CalculateStatistics(representation); Assert.AreEqual(umc.MassMonoisotopicAligned, cluster.MassMonoisotopic, "Monoisotopic Mass"); Assert.AreEqual(umc.Net, cluster.Net, "NET"); Assert.AreEqual(umc.DriftTime, cluster.DriftTime, "Drift Time"); Assert.AreEqual(umc.ChargeState, cluster.ChargeState, "Charge State"); }
private static void ConvertToUMCLight(List <double> referenceTimes, List <double> experimentalTimes, out List <UMCLight> experimentalTimesAsUMC, out List <UMCLight> referenceTimesAsUMC, int multiplier) { referenceTimesAsUMC = new List <UMCLight>(); experimentalTimesAsUMC = new List <UMCLight>(); for (int i = 0; i < experimentalTimes.Count; i++) { UMCLight referencePoint = new UMCLight(); UMCLight experimentalPoint = new UMCLight(); referencePoint.Net = Math.Round(referenceTimes[i] * multiplier); //experimentalPoint.Net = experimentalTimes[i]*multiplier; //referencePoint.Scan = Convert.ToInt32(referenceTimes[i]*multiplier); //scan needs to be populated experimentalPoint.Scan = Convert.ToInt32(Math.Round(experimentalTimes[i] * multiplier, 0)); experimentalPoint.ScanStart = Convert.ToInt32(Math.Round(experimentalTimes[i] * multiplier, 0)); experimentalPoint.ScanEnd = Convert.ToInt32(Math.Round(experimentalTimes[i] * multiplier, 0)); referencePoint.Mz = 1000 + i; experimentalPoint.Mz = 1000 + i; //this is needed referencePoint.MassMonoisotopic = 1000 + i; experimentalPoint.MassMonoisotopic = 1000 + i; referenceTimesAsUMC.Add(referencePoint); experimentalTimesAsUMC.Add(experimentalPoint); } }
public void CalibrateFeature(UMCLight feature) { var mass = feature.MassMonoisotopic; var ppmShift = this.GetPredictedValue(feature.Mz); var newMass = mass - (mass * ppmShift) / 1000000; feature.MassMonoisotopicAligned = newMass; feature.MassMonoisotopic = newMass; }
/// <summary> /// /// </summary> /// <param name="feature"></param> /// <param name="basisFunction"></param> public void FitChromatograms(UMCLight feature, BasisFunctionBase basisFunction) { foreach (var charge in feature.ChargeStateChromatograms.Keys) { var gram = feature.ChargeStateChromatograms[charge]; FitChromatograms(gram, basisFunction); } }
/// <summary> /// Warp the feature's separation value by the alignment function for the given separation value type. /// </summary> /// <param name="feature">The feature to warp.</param> public UMCLight GetWarpedFeature(UMCLight feature) { var warpedFeature = new UMCLight(feature); var separationValue = feature.GetSeparationValue(this.SeparationType); var warpedValue = this.WarpValue(separationValue); warpedFeature.SetSeparationValue(this.SeparationType, warpedValue); return(feature); }
public UMCLight GetWarpedFeature(UMCLight feature) { var calibratedFeature = new UMCLight(feature); foreach (var calibration in this.Calibrations) { calibration.CalibrateFeature(calibratedFeature); } return(calibratedFeature); }
/// <summary> /// Reconstruct the MS/MS for a feature. /// Requires that the features's LCMS and MS features have been reconstructed. /// </summary> /// <param name="umc">The feature to reconstruct.</param> public static void ReconstructUMCMsMs(this UMCLight umc, ISpectraProvider provider, bool getPeaks = true) { foreach (var msFeature in umc.Features) { var fragmentationSpectra = provider.GetMSMSSpectra( msFeature.Scan, msFeature.Mz, false); msFeature.MSnSpectra.AddRange(fragmentationSpectra); } }
protected void OnFeatureSelected(UMCLight feature) { if (FeatureSelected != null) { if (feature == null) { return; } FeatureSelected(this, new FeatureSelectedEventArgs(feature)); } }
public static bool HasMsMs(this UMCLight feature) { foreach (var msFeature in feature.MsFeatures) { bool hasMsMs = msFeature.HasMsMs(); if (hasMsMs) { return(true); } } return(false); }
public void WriteFeatures(string path, List <UMCLight> features, List <UMCLight> adjustedFeatures) { Dictionary <int, UMCLight> map = new Dictionary <int, UMCLight>(); adjustedFeatures.ForEach(x => map.Add(x.ID, x)); using (TextWriter writer = File.CreateText(path)) { writer.WriteLine("Feature ID, Feature Count, Scan, Scan Adj, Delta Scan, NET, NET Adj, Delta NET, Charge, H-Negative, H-Positive, HasMSMS"); foreach (UMCLight feature in features) { bool contained = map.ContainsKey(feature.ID); if (contained) { UMCLight adjusted = map[feature.ID]; double hPositive = 0; double hNegative = 0; foreach (int charge in adjusted.HNegative.Keys) { hPositive = adjusted.HPositive[charge]; hNegative = adjusted.HNegative[charge]; bool hasMSMS = feature.HasMsMs(); int value = 0; if (hasMSMS) { value = 1; } writer.WriteLine("{9}, {10},{0},{1},{2},{3},{4},{5},{6},{7},{8},{11}", feature.Scan, adjusted.Scan, feature.Scan - adjusted.Scan, feature.RetentionTime, adjusted.RetentionTime, feature.RetentionTime - adjusted.RetentionTime, charge, hNegative, hPositive, feature.ID, feature.MSFeatures.Count, value ); } } } } }
/// <summary> /// For a given List of UMCLights, warp the alignee features to the baseline. /// </summary> /// <param name="features"></param> public void SetAligneeDatasetFeatures(List <UMCLight> features) { var mtFeatures = new List <UMCLight> { Capacity = features.Count }; _minAligneeDatasetScan = int.MaxValue; _maxAligneeDatasetScan = int.MinValue; _minAligneeDatasetTime = double.MaxValue; _maxAligneeDatasetTime = double.MinValue; _minAligneeDatasetMz = double.MaxValue; _maxAligneeDatasetMz = double.MinValue; for (var index = 0; index < features.Count; index++) { var feature = features[index]; // Note: We are using ScanStart for the NET of the feature // This is to avoid odd effects from broad or tailing LC-MS features var mtFeature = new UMCLight { MassMonoisotopic = feature.MassMonoisotopic, MassMonoisotopicAligned = feature.MassMonoisotopicAligned, MassMonoisotopicOriginal = feature.MassMonoisotopicOriginal, Net = Convert.ToDouble(feature.ScanStart), Mz = feature.Mz, Abundance = feature.Abundance, Id = feature.Id, DriftTime = feature.DriftTime }; //mtFeature.MonoMassOriginal = features[index].MassMonoisotopic; // For if we want to split alignment at given M/Z range // Only allow feature to be aligned if we're splitting the alignment in MZ // AND if we are within the specified boundary //if (ValidateAlignmentBoundary(Options.AlignSplitMZs, mtFeature.Mz, boundary)) //{ mtFeatures.Add(mtFeature); _maxAligneeDatasetScan = Math.Max(_maxAligneeDatasetScan, feature.Scan); _minAligneeDatasetScan = Math.Min(_minAligneeDatasetScan, feature.Scan); _maxAligneeDatasetTime = Math.Max(_maxAligneeDatasetTime, feature.DriftTime); _minAligneeDatasetTime = Math.Min(_minAligneeDatasetTime, feature.DriftTime); _maxAligneeDatasetMz = Math.Max(_maxAligneeDatasetMz, feature.Mz); _minAligneeDatasetMz = Math.Min(_minAligneeDatasetMz, feature.Mz); //} } _lcmsWarp.SetFeatures(mtFeatures); }
public static Dictionary<int, List<MSFeatureLight>> BuildChargeMap(UMCLight feature) { var chargeMap = new Dictionary<int, List<MSFeatureLight>>(); foreach (var msFeature in feature.MsFeatures) { if (!chargeMap.ContainsKey(msFeature.ChargeState)) { chargeMap.Add(msFeature.ChargeState, new List<MSFeatureLight>()); } chargeMap[msFeature.ChargeState].Add(msFeature); } return chargeMap; }
/// <summary> /// Creates SIC's mapped by charge state for the MS Features in the feature. /// </summary> /// <param name="feature"></param> /// <returns></returns> public static Dictionary <int, List <XYZData> > CreateChargeSICForMonoMass(this UMCLight feature) { var chargeMap = feature.CreateChargeMap(); var sicMap = new Dictionary <int, List <XYZData> >(); foreach (var charge in chargeMap.Keys) { chargeMap[charge].Sort(delegate(MSFeatureLight x, MSFeatureLight y) { return(x.Scan.CompareTo(y.Scan)); } ); var data = chargeMap[charge].ConvertAll(x => new XYZData(x.Scan, x.Abundance, x.MassMonoisotopicAligned)); sicMap.Add(charge, data); } return(sicMap); }
public FeaturePoint(UMCLight umcLight, GetNet getNet) { this.UMCLight = umcLight; var etStart = getNet(umcLight.ScanStart); var etEnd = getNet(umcLight.ScanEnd); this.Rectangle = new RectangleF { X = etStart, Y = (float)umcLight.MassMonoisotopicAligned, Width = etEnd - etStart, Height = 1 }; }
public void TestLamarcheGridApp(string csvPath) { //Read a csv file, put the data into a new UMCLight for each one var csvFileText = File.ReadAllLines(csvPath); var csvDataList = new List <UMCLight> { Capacity = csvFileText.Length }; foreach (var line in csvFileText) { var parsedLine = line.Split(','); var umcDataMember = new UMCLight(); //put the data from the parsed line into the umcDataMember in the appropriate fashion csvDataList.Add(umcDataMember); } //Create clusters from the data read in from the file UMCClusterLight cluster = null; var filteredClusters = new List <UMCClusterLight>(); if (!Filter(cluster)) { //Save the cluster filteredClusters.Add(cluster); } //Read a mtdb file using MACore or sqliteDb var databasePath = @"C:\UnitTestFolder\MSGFPlus\blah.db"; //Either read from console, or entered at program execution // Console.ReadLine(databasePath) or databasePath = args[2] var database = ReadDatabase(databasePath); var stacAdapter = new STACAdapter <UMCClusterLight>(); var matchList = stacAdapter.PerformPeakMatching(filteredClusters, database); string writePath = null; // As with databasePath, could either be read from console, or entered at program execution // Console.ReadLine(writePath) or, if(args.Length >= 4){ writePath = args[3]; } // If writePath isn't entered, then it writes to a default file, defined inside the WriteData method WriteData(matchList, writePath); }
/// <summary> /// Reconstructions a UMC /// </summary> /// <param name="feature"></param> /// <param name="providers"></param> public static void ReconstructUMC(this UMCLight feature, FeatureDataAccessProviders providers, bool getMsMs) { // This is easy to grab all ms features for this feature. var msFeatures = providers.MSFeatureCache.FindByFeatureId(feature.GroupId, feature.Id); foreach (var msFeature in msFeatures) { feature.AddChildFeature(msFeature); } if (getMsMs) { feature.ReconstructMSFeature(providers, getMsMs); } }
public List <UMCLight> FindByCharge(int charge) { var features = new List <UMCLight>(); var featurecount = 0; var cuont = 0; using (var connection = new SQLiteConnection(string.Format("Data Source = {0}", DatabasePath), true)) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = string.Format("SELECT * FROM T_LCMS_FEATURES WHERE CHARGE = {0}", charge); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var values = new object[20]; reader.GetValues(values); var feature = new UMCLight(); feature.ChargeState = Convert.ToInt32(values[11]); feature.MassMonoisotopicAligned = Convert.ToDouble(values[5]); feature.Net = Convert.ToDouble(values[6]); feature.DriftTime = Convert.ToDouble(values[15]); feature.AbundanceSum = Convert.ToInt64(values[14]); feature.Abundance = Convert.ToInt64(values[13]); feature.GroupId = Convert.ToInt32(values[1]); feature.Id = Convert.ToInt32(values[0]); features.Add(feature); featurecount++; if (featurecount > 100000) { cuont++; Logger.PrintMessage(string.Format("\tLoaded {0}00000 features", cuont)); featurecount = 0; } } } } connection.Close(); } return(features); }
public void TestDistanceDistributions(string path, DistanceMetric dist) { var features = ReadFeatures(path); var clusterer = new UMCAverageLinkageClusterer <UMCLight, UMCClusterLight> { ShouldTestClustersWithinTolerance = false, Parameters = { CentroidRepresentation = ClusterCentroidRepresentation.Mean, DistanceFunction = DistanceFactory <UMCLight> .CreateDistanceFunction(dist), OnlyClusterSameChargeStates = true, Tolerances = { Mass = 10, DriftTime = .3, Net = .03 } } }; var clusters = clusterer.Cluster(features); var distances = new List <double>(); foreach (var cluster in clusters) { var centroid = new UMCLight(); centroid.MassMonoisotopicAligned = cluster.MassMonoisotopic; centroid.Net = cluster.Net; centroid.DriftTime = cluster.DriftTime; var func = clusterer.Parameters.DistanceFunction; foreach (var feature in cluster.Features) { var distance = func(feature, centroid); distances.Add(distance); } distances.Sort(); var sum = 0; foreach (var distance in distances) { sum++; Console.WriteLine("{0},{1}", distance, sum); } } }
/// <summary> /// Creates an Xic for a feature based on individual charge states. /// </summary> /// <param name="rawPath">Path to the raw file.</param> /// <param name="peaksPath">Path to the peaks file.</param> /// <param name="feature">Feature to target</param> public Dictionary <int, Chromatogram> CreateXicForChargeStates(UMCLight feature, bool shouldSmooth) { Dictionary <int, Chromatogram> chromatograms = new Dictionary <int, Chromatogram>(); Dictionary <int, List <XYZData> > charges = feature.CreateChargeSIC(); XicFinder finder = new XicFinder(); feature.ChargeStateChromatograms.Clear(); // foreach (int charge in charges.Keys) { // This is the current XIC - but it's not that great List <XYZData> xicMz = charges[charge]; // Finds the maximum point in the XIC, we'll use this as our target, it most likely contains // the exact point that we'll want to use to help identify the feature. var maxPoint = xicMz.Where(u => u.Y == xicMz.Max(x => x.Y)).Select(u => new { u.X, u.Y, u.Z }).FirstOrDefault(); int targetScan = Convert.ToInt32(maxPoint.X); double targetMz = maxPoint.Z; // Find the Xic based on the target point, this may include other peaks List <XYData> totalXic = null; try { totalXic = FindXic(targetMz, targetScan, shouldSmooth); if (totalXic.Count > 1) { // Then find a specific Xic based on the target scan. List <XYData> specificXic = finder.FindTarget(totalXic, targetScan); // Add the targeted Xic to the charge state map so that we can create Xic's for each charge state. Chromatogram gram = new Chromatogram(specificXic, maxPoint.Z, charge); chromatograms.Add(charge, gram); } } catch (PreconditionException) { // This would mean that the charge state didnt have enough features in it. } } return(chromatograms); }
public List<UMCLight> FindByCharge(int charge) { var features = new List<UMCLight>(); var featurecount = 0; var cuont = 0; using (var connection = new SQLiteConnection(string.Format("Data Source = {0}", DatabasePath), true)) { connection.Open(); using (var command = connection.CreateCommand()) { command.CommandText = string.Format("SELECT * FROM T_LCMS_FEATURES WHERE CHARGE = {0}", charge); using (var reader = command.ExecuteReader()) { while (reader.Read()) { var values = new object[20]; reader.GetValues(values); var feature = new UMCLight(); feature.ChargeState = Convert.ToInt32(values[11]); feature.MassMonoisotopicAligned = Convert.ToDouble(values[5]); feature.Net = Convert.ToDouble(values[6]); feature.DriftTime = Convert.ToDouble(values[15]); feature.AbundanceSum = Convert.ToInt64(values[14]); feature.Abundance = Convert.ToInt64(values[13]); feature.GroupId = Convert.ToInt32(values[1]); feature.Id = Convert.ToInt32(values[0]); features.Add(feature); featurecount++; if (featurecount > 100000) { cuont ++; Logger.PrintMessage(string.Format("\tLoaded {0}00000 features", cuont)); featurecount = 0; } } } } connection.Close(); } return features; }
public void TestLamarcheGridApp(string csvPath) { //Read a csv file, put the data into a new UMCLight for each one var csvFileText = File.ReadAllLines(csvPath); var csvDataList = new List<UMCLight> {Capacity = csvFileText.Length}; foreach (var line in csvFileText) { var parsedLine = line.Split(','); var umcDataMember = new UMCLight(); //put the data from the parsed line into the umcDataMember in the appropriate fashion csvDataList.Add(umcDataMember); } //Create clusters from the data read in from the file UMCClusterLight cluster = null; var filteredClusters = new List<UMCClusterLight>(); if (!Filter(cluster)) { //Save the cluster filteredClusters.Add(cluster); } //Read a mtdb file using MACore or sqliteDb var databasePath = @"C:\UnitTestFolder\MSGFPlus\blah.db"; //Either read from console, or entered at program execution // Console.ReadLine(databasePath) or databasePath = args[2] var database = ReadDatabase(databasePath); var stacAdapter = new STACAdapter<UMCClusterLight>(); var matchList = stacAdapter.PerformPeakMatching(filteredClusters, database); string writePath = null; // As with databasePath, could either be read from console, or entered at program execution // Console.ReadLine(writePath) or, if(args.Length >= 4){ writePath = args[3]; } // If writePath isn't entered, then it writes to a default file, defined inside the WriteData method WriteData(matchList, writePath); }
/// <summary> /// Creates an Xic for a feature based on individual charge states. /// </summary> /// <param name="rawPath">Path to the raw file.</param> /// <param name="peaksPath">Path to the peaks file.</param> /// <param name="feature">Feature to target</param> public Dictionary <int, List <Chromatogram> > CreateXicForIsotopes(UMCLight feature, bool shouldSmooth) { Dictionary <int, List <Chromatogram> > chromatograms = new Dictionary <int, List <Chromatogram> >(); Dictionary <int, List <XYZData> > charges = feature.CreateChargeSIC(); XicFinder finder = new XicFinder(); feature.IsotopeChromatograms.Clear(); foreach (int charge in charges.Keys) { /// Creates a list of Xic's for a given chromatogram. List <Chromatogram> grams = new List <Chromatogram>(); chromatograms.Add(charge, grams); // This is the current XIC - but it's not that great List <XYZData> xicMz = charges[charge]; // Finds the maximum point in the XIC, we'll use this as our target, it most likely contains // the exact point that we'll want to use to help identify the feature. var maxPoint = xicMz.Where(u => u.Y == xicMz.Max(x => x.Y)).Select(u => new { u.X, u.Y, u.Z }).FirstOrDefault(); int targetScan = Convert.ToInt32(maxPoint.X); double targetMz = maxPoint.Z; List <XYData> isotopicProfile = CreateIsotopicProfile(targetMz, targetScan, charge); foreach (XYData isotope in isotopicProfile) { // Find the Xic based on the target point, this may include other peaks List <XYData> totalXic = FindXic(targetMz, targetScan, shouldSmooth); // Then find a specific Xic based on the target scan. List <XYData> targetIsotopeXic = finder.FindTarget(totalXic, targetScan); // Add the targeted Xic to the charge state map so that we can create Xic's for each charge state. Chromatogram gram = new Chromatogram(targetIsotopeXic, maxPoint.Z, charge); grams.Add(gram); } chromatograms[charge] = grams; } feature.IsotopeChromatograms = chromatograms; return(chromatograms); }
private void OnSpectrumSelected(UMCLight feature) { if (SpectrumSelected != null) { Peptide peptide = null; if (m_feature.Peptides != null && m_feature.Peptides.Count > 0) { peptide = m_feature.Peptides[0]; } var args = new IdentificationFeatureSelectedEventArgs( m_feature, peptide, feature); SpectrumSelected(this, args); } }
protected virtual bool AreClustersWithinTolerance(UMCLight clusterX, UMCLight clusterY, double massTolerance, double netTolerance, double driftTolerance) { // Calculate differences var massDiff = Math.Abs(FeatureLight.ComputeMassPPMDifference(clusterX.MassMonoisotopicAligned, clusterY.MassMonoisotopicAligned)); var netDiff = Math.Abs(clusterX.Net - clusterY.Net); var driftDiff = Math.Abs(clusterX.DriftTime - clusterY.DriftTime); // Return true only if all differences are within tolerance if (massDiff <= massTolerance && netDiff <= netTolerance && driftDiff <= driftTolerance) { return(true); } return(false); }
public void TestCppSetReferenceFeatures(string baselinePath) { Console.WriteLine(@"I'm Testing!"); var rawBaselineData = File.ReadAllLines(baselinePath); var baseline = new List<UMCLight>(); foreach (var line in rawBaselineData) { if (line != "") { var parsed = line.Split(','); var data = new UMCLight { Net = Convert.ToDouble(parsed[0]), ChargeState = Convert.ToInt32(parsed[1]), Mz = Convert.ToDouble(parsed[2]), Scan = Convert.ToInt32(parsed[3]), MassMonoisotopic = Convert.ToDouble(parsed[4]), MassMonoisotopicAligned = Convert.ToDouble(parsed[5]), Id = Convert.ToInt32(parsed[6]) }; baseline.Add(data); } } var oldStyle = new MultiAlignEngine.Alignment.clsAlignmentProcessor(); var oldBaseline = baseline.Select(baseData => new MultiAlignEngine.Features.clsUMC { Net = baseData.Net, MZForCharge = baseData.Mz, Scan = baseData.Scan, Mass = baseData.MassMonoisotopic, MassCalibrated = baseData.MassMonoisotopicAligned, Id = baseData.Id }).ToList(); oldStyle.SetReferenceDatasetFeatures(oldBaseline); Console.WriteLine(@"Done testing"); }
public void TestCppSetReferenceFeatures(string baselinePath) { Console.WriteLine(@"I'm Testing!"); var rawBaselineData = File.ReadAllLines(baselinePath); var baseline = new List <UMCLight>(); foreach (var line in rawBaselineData) { if (line != "") { var parsed = line.Split(','); var data = new UMCLight { Net = Convert.ToDouble(parsed[0]), ChargeState = Convert.ToInt32(parsed[1]), Mz = Convert.ToDouble(parsed[2]), Scan = Convert.ToInt32(parsed[3]), MassMonoisotopic = Convert.ToDouble(parsed[4]), MassMonoisotopicAligned = Convert.ToDouble(parsed[5]), Id = Convert.ToInt32(parsed[6]) }; baseline.Add(data); } } var oldStyle = new MultiAlignEngine.Alignment.clsAlignmentProcessor(); var oldBaseline = baseline.Select(baseData => new MultiAlignEngine.Features.clsUMC { Net = baseData.Net, MZForCharge = baseData.Mz, Scan = baseData.Scan, Mass = baseData.MassMonoisotopic, MassCalibrated = baseData.MassMonoisotopicAligned, Id = baseData.Id }).ToList(); oldStyle.SetReferenceDatasetFeatures(oldBaseline); Console.WriteLine(@"Done testing"); }
public void TestChargeStateSplit(string path) { var data = File.ReadAllLines(path); var map = new Dictionary <int, List <MSFeatureLight> >(); for (var i = 1; i < data.Length; i++) { var feature = new MSFeatureLight(); var msFeatureData = data[i].Split(','); feature.ChargeState = Convert.ToInt32(msFeatureData[0]); feature.MassMonoisotopic = Convert.ToDouble(msFeatureData[1]); feature.Scan = Convert.ToInt32(msFeatureData[2]); feature.Abundance = Convert.ToInt64(msFeatureData[3]); if (!map.ContainsKey(feature.ChargeState)) { map.Add(feature.ChargeState, new List <MSFeatureLight>()); } map[feature.ChargeState].Add(feature); } var features = new List <UMCLight>(); foreach (var charge in map.Keys) { var feature = new UMCLight(); foreach (var msFeature in map[charge]) { feature.AddChildFeature(msFeature); } feature.CalculateStatistics(ClusterCentroidRepresentation.Median); features.Add(feature); } var finder = new MsFeatureTreeClusterer <MSFeatureLight, UMCLight>(); var comparison = finder.CompareMonoisotopic(features[0], features[1]); Assert.AreNotEqual(comparison, 0); }
/// <summary> /// Creates a charge map for a given ms feature list. /// </summary> /// <param name="feature"></param> /// <returns></returns> public static Dictionary <int, List <MSFeatureLight> > CreateChargeMap(this UMCLight feature) { var chargeMap = new Dictionary <int, List <MSFeatureLight> >(); foreach (var msFeature in feature.MsFeatures) { if (!chargeMap.ContainsKey(msFeature.ChargeState)) { chargeMap.Add(msFeature.ChargeState, new List <MSFeatureLight>()); } chargeMap[msFeature.ChargeState].Add(msFeature); } var newChargeMap = new Dictionary <int, List <MSFeatureLight> >(); foreach (var charge in chargeMap.Keys) { var ordered = chargeMap[charge].OrderBy(x => x.Scan); newChargeMap.Add(charge, ordered.ToList()); } return(newChargeMap); }
private void SetFeature(UMCLight feature) { if (feature == null) { return; } var info = SingletonDataProviders.GetDatasetInformation(feature.GroupId); if (info != null) { SelectedFeatureName = info.DatasetName; } var model = new XicViewModel(new List <UMCLight> { feature }, "XIC"); model.PointClicked += model_PointClicked; XicModel = model; UpdateCharges(feature); }
private void SetFeature(UMCLight feature) { if (feature == null) return; var info = SingletonDataProviders.GetDatasetInformation(feature.GroupId); if (info != null) { SelectedFeatureName = info.DatasetName; } var model = new XicViewModel(new List<UMCLight> { feature }, "XIC"); model.PointClicked += model_PointClicked; XicModel = model; UpdateCharges(feature); }
public IdentificationFeatureSelectedEventArgs(MSSpectra spectrum, Peptide id, UMCLight feature) { Feature = feature; Spectrum = spectrum; Peptide = id; }
private void UpdateCharges(UMCLight feature) { Charges.Clear(); m_scanMaps = feature.CreateChargeMap(); foreach (var charge in m_scanMaps.Keys) { double mz = 0; var minScan = int.MaxValue; var maxScan = int.MinValue; double maxIntensity = 0; foreach (var msFeature in m_scanMaps[charge]) { minScan = Math.Min(minScan, msFeature.Scan); maxScan = Math.Max(maxScan, msFeature.Scan); if (maxIntensity >= msFeature.Abundance) continue; maxIntensity = msFeature.Abundance; mz = msFeature.Mz; } Charges.Add(new ChargeStateViewModel(charge, mz, minScan, maxScan)); } if (Charges.Count <= 0) return; SelectedCharge = Charges[0]; }
protected void OnFeatureSelected(UMCLight feature) { if (FeatureSelected != null) { if (feature == null) return; FeatureSelected(this, new FeatureSelectedEventArgs(feature)); } }
/// <summary> /// Creates an Xic for a feature based on individual charge states. /// </summary> /// <param name="rawPath">Path to the raw file.</param> /// <param name="peaksPath">Path to the peaks file.</param> /// <param name="feature">Feature to target</param> public Dictionary<int, List<Chromatogram>> CreateXicForIsotopes(UMCLight feature, bool shouldSmooth) { Dictionary<int, List<Chromatogram>> chromatograms = new Dictionary<int, List<Chromatogram>>(); Dictionary<int, List<XYZData>> charges = feature.CreateChargeSIC(); XicFinder finder = new XicFinder(); feature.IsotopeChromatograms.Clear(); foreach (int charge in charges.Keys) { /// Creates a list of Xic's for a given chromatogram. List<Chromatogram> grams = new List<Chromatogram>(); chromatograms.Add(charge, grams); // This is the current XIC - but it's not that great List<XYZData> xicMz = charges[charge]; // Finds the maximum point in the XIC, we'll use this as our target, it most likely contains // the exact point that we'll want to use to help identify the feature. var maxPoint = xicMz.Where(u => u.Y == xicMz.Max(x => x.Y)).Select(u => new { u.X, u.Y, u.Z }).FirstOrDefault(); int targetScan = Convert.ToInt32(maxPoint.X); double targetMz = maxPoint.Z; List<PNNLOmics.Data.XYData> isotopicProfile = CreateIsotopicProfile(targetMz, targetScan, charge); foreach (PNNLOmics.Data.XYData isotope in isotopicProfile) { // Find the Xic based on the target point, this may include other peaks List<PNNLOmics.Data.XYData> totalXic = FindXic(targetMz, targetScan, shouldSmooth); // Then find a specific Xic based on the target scan. List<PNNLOmics.Data.XYData> targetIsotopeXic = finder.FindTarget(totalXic, targetScan); // Add the targeted Xic to the charge state map so that we can create Xic's for each charge state. Chromatogram gram = new Chromatogram(targetIsotopeXic, maxPoint.Z, charge); grams.Add(gram); } chromatograms[charge] = grams; } feature.IsotopeChromatograms = chromatograms; return chromatograms; }
public void TestDistanceDistributions(string path, DistanceMetric dist) { var features = ReadFeatures(path); var clusterer = new UMCAverageLinkageClusterer<UMCLight, UMCClusterLight> { ShouldTestClustersWithinTolerance = false, Parameters = { CentroidRepresentation = ClusterCentroidRepresentation.Mean, DistanceFunction = DistanceFactory<UMCLight>.CreateDistanceFunction(dist), OnlyClusterSameChargeStates = true, Tolerances = { Mass = 10, DriftTime = .3, Net = .03 } } }; var clusters = clusterer.Cluster(features); var distances = new List<double>(); foreach (var cluster in clusters) { var centroid = new UMCLight(); centroid.MassMonoisotopicAligned = cluster.MassMonoisotopic; centroid.Net = cluster.Net; centroid.DriftTime = cluster.DriftTime; var func = clusterer.Parameters.DistanceFunction; foreach (var feature in cluster.Features) { var distance = func(feature, centroid); distances.Add(distance); } distances.Sort(); var sum = 0; foreach (var distance in distances) { sum++; Console.WriteLine("{0},{1}", distance, sum); } } }
public void TestChargeStateSplit(string path) { var data = File.ReadAllLines(path); var map = new Dictionary<int, List<MSFeatureLight>>(); for (var i = 1; i < data.Length; i++) { var feature = new MSFeatureLight(); var msFeatureData = data[i].Split(','); feature.ChargeState = Convert.ToInt32(msFeatureData[0]); feature.MassMonoisotopic = Convert.ToDouble(msFeatureData[1]); feature.Scan = Convert.ToInt32(msFeatureData[2]); feature.Abundance = Convert.ToInt64(msFeatureData[3]); if (!map.ContainsKey(feature.ChargeState)) { map.Add(feature.ChargeState, new List<MSFeatureLight>()); } map[feature.ChargeState].Add(feature); } var features = new List<UMCLight>(); foreach (var charge in map.Keys) { var feature = new UMCLight(); foreach (var msFeature in map[charge]) { feature.AddChildFeature(msFeature); } feature.CalculateStatistics(ClusterCentroidRepresentation.Median); features.Add(feature); } var finder = new MsFeatureTreeClusterer<MSFeatureLight, UMCLight>(); var comparison = finder.CompareMonoisotopic(features[0], features[1]); Assert.AreNotEqual(comparison, 0); }
/// <summary> /// Scores a feature and adjusts its abundance accordingly. /// </summary> /// <param name="feature"></param> /// <returns></returns> public void ScoreFeature(UMCLight feature) { // Get the basis function of interest var basisFunction = BasisFunctionFactory.BasisFunctionSelector(BasisFunction); var integrator = NumericalIntegrationFactory.CreateIntegrator(IntegrationType); // Evaluate every charge state XIC. foreach (var charge in feature.ChargeStateChromatograms.Keys) { var gram = feature.ChargeStateChromatograms[charge]; var totalPoints = gram.Points.Count; if (totalPoints > 1) { // Convert the data types, not sure why this has to be done... // Should just using the XYData points var x = new List<double>(); var y = new List<double>(); foreach (var xyData in gram.Points) { x.Add(xyData.X); y.Add(xyData.Y); } // First solve for the function var coefficients = basisFunction.Coefficients; var solver = new LevenburgMarquadtSolver(); var report = solver.Solve(x, y, ref coefficients); gram.FitPoints = new List<XYData>(); foreach (var datum in gram.Points) { var yValue = basisFunction.Evaluate(coefficients, datum.X); gram.FitPoints.Add(new XYData(datum.X, yValue)); } var totalSamples = 4*Math.Abs(gram.EndScan - gram.StartScan); // Then integrate the function // Let's integrate with 4x the number of scans gram.Area = integrator.Integrate(basisFunction, coefficients, Convert.ToDouble(gram.StartScan), Convert.ToDouble(gram.EndScan), totalSamples); } } // Then calculate all of the fits for each foreach (var charge in feature.IsotopeChromatograms.Keys) { foreach (var gram in feature.IsotopeChromatograms[charge]) { var totalPoints = gram.Points.Count; if (totalPoints > 1) { // Convert the data types, not sure why this has to be done... // Should just using the XYData points var x = new List<double>(); var y = new List<double>(); foreach (var xyData in gram.Points) { x.Add(xyData.X); y.Add(xyData.Y); } // First solve for the function var coefficients = basisFunction.Coefficients; var solver = new LevenburgMarquadtSolver(); solver.Solve(x, y, ref coefficients); gram.FitPoints = new List<XYData>(); foreach (var datum in gram.Points) { var yValue = basisFunction.Evaluate(coefficients, datum.X); gram.FitPoints.Add(new XYData(datum.X, yValue)); } var totalSamples = 4*Math.Abs(gram.EndScan - gram.StartScan); // Then integrate the function // Let's integrate with 4x the number of scans gram.Area = integrator.Integrate(basisFunction, coefficients, Convert.ToDouble(gram.StartScan), Convert.ToDouble(gram.EndScan), totalSamples); } } } }
public List<UMCClusterLight> ReadClusters(string path) { var clusters = new List<UMCClusterLight>(); var data = File.ReadLines(path).ToList(); var isClusters = true; var i = 1; var clusterMap = new Dictionary<int, UMCClusterLight>(); while (i < data.Count && isClusters) { isClusters = !(data[i].ToLower().Contains("dataset")); if (isClusters) { var cluster = new UMCClusterLight(); var lineData = data[i].Split(','); cluster.Id = Convert.ToInt32(lineData[0]); cluster.MassMonoisotopic = Convert.ToDouble(lineData[1]); cluster.Net = Convert.ToDouble(lineData[2]); cluster.Net = Convert.ToDouble(lineData[2]); cluster.DriftTime = Convert.ToDouble(lineData[3]); cluster.ChargeState = Convert.ToInt32(lineData[4]); if (!clusterMap.ContainsKey(cluster.Id)) { clusterMap.Add(cluster.Id, cluster); } clusters.Add(cluster); } i = i + 1; } i = i + 1; while (i < data.Count) { var line = data[i]; var lineData = line.Split(','); if (line.Length > 6) { var clusterID = Convert.ToInt32(lineData[0]); var feature = new UMCLight { GroupId = Convert.ToInt32(lineData[1]), Id = Convert.ToInt32(lineData[2]), MassMonoisotopic = Convert.ToDouble(lineData[3]), Net = Convert.ToDouble(lineData[4]), NetAligned = Convert.ToDouble(lineData[4]), DriftTime = Convert.ToDouble(lineData[5]), ChargeState = Convert.ToInt32(lineData[6]) }; if (clusterMap.ContainsKey(clusterID)) { clusterMap[clusterID].AddChildFeature(feature); } } i = i + 1; } return clusters; }
/// <summary> /// Correct for the drift times. /// </summary> /// <param name="features"></param> /// <param name="baselineFeatures"></param> /// <param name="options"></param> public KeyValuePair<DriftTimeAlignmentResults<UMCLight, UMCLight>, DriftTimeAlignmentResults<UMCLight, UMCLight>> AlignDriftTimes(List<UMCLight> features, List<UMCLight> baselineFeatures, DriftTimeAlignmentOptions options) { UpdateStatus("Correcting drift times."); var baselineUmCs = new List<UMCLight>(); var aligneeUmCs = new List<UMCLight>(); UpdateStatus("Mapping data structures."); var featureIdMap = new Dictionary<int, UMCLight>(); foreach (var feature in features) { var umc = new UMCLight { MassMonoisotopicAligned = feature.MassMonoisotopicAligned, NetAligned = feature.NetAligned, DriftTime = Convert.ToSingle(feature.DriftTime), Id = feature.Id, ChargeState = feature.ChargeState }; aligneeUmCs.Add(umc); featureIdMap.Add(feature.Id, feature); } foreach (var feature in baselineFeatures) { var umc = new UMCLight { MassMonoisotopicAligned = feature.MassMonoisotopicAligned, NetAligned = feature.Net, DriftTime = Convert.ToSingle(feature.DriftTime), Id = feature.Id, ChargeState = feature.ChargeState }; baselineUmCs.Add(umc); } // filter based on charge state. var chargeMax = options.MaxChargeState; var chargeMin = options.MinChargeState; UpdateStatus(string.Format("Filtering Features Min Charge: {0} <= charge <= Max Charge {1}", chargeMin, chargeMax)); var filteredQuery = from feature in aligneeUmCs where feature.ChargeState <= chargeMax && feature.ChargeState >= chargeMin select feature; var filteredUmCs = filteredQuery.ToList(); UpdateStatus("Finding Aligned Matches and correcting drift times."); var alignedResults = DriftTimeAlignment<UMCLight, UMCLight>.AlignObservedEnumerable(aligneeUmCs, filteredUmCs, baselineUmCs, options.MassPPMTolerance, options.NETTolerance); DriftTimeAlignmentResults<UMCLight, UMCLight> offsetResults = null; if (options.ShouldPerformOffset) { UpdateStatus("Adjusting drift time offsets."); var aligneeData = aligneeUmCs; if (!options.ShouldUseAllObservationsForOffsetCalculation) { UpdateStatus("Using only filtered matches for offset correction."); aligneeData = filteredUmCs; } else { UpdateStatus("Using all feature matches for offset correction."); } offsetResults = DriftTimeAlignment<UMCLight, UMCLight>.CorrectForOffset(aligneeData, baselineUmCs, options.MassPPMTolerance, options.NETTolerance, options.DriftTimeTolerance); } UpdateStatus("Remapping data structures for persistence to database."); foreach (var umc in aligneeUmCs) { featureIdMap[umc.Id].DriftTime = umc.DriftTimeAligned; } var pair = new KeyValuePair <DriftTimeAlignmentResults<UMCLight, UMCLight>, DriftTimeAlignmentResults<UMCLight, UMCLight>>( alignedResults, offsetResults); return pair; }
public FeatureSelectedEventArgs(UMCLight feature) { Feature = feature; }
protected virtual bool AreClustersWithinTolerance(UMCLight clusterX, UMCLight clusterY, double massTolerance, double netTolerance, double driftTolerance) { // Calculate differences var massDiff = Math.Abs(FeatureLight.ComputeMassPPMDifference(clusterX.MassMonoisotopicAligned, clusterY.MassMonoisotopicAligned)); var netDiff = Math.Abs(clusterX.Net - clusterY.Net); var driftDiff = Math.Abs(clusterX.DriftTime - clusterY.DriftTime); // Return true only if all differences are within tolerance if (massDiff <= massTolerance && netDiff <= netTolerance && driftDiff <= driftTolerance) { return true; } return false; }
public void TestCreateDummyDatabase(string databasePath, int totalDatasets, int totalClusters) { File.Delete(databasePath); NHibernateUtil.ConnectToDatabase(databasePath, true); IDatasetDAO datasetCache = new DatasetDAOHibernate(); IUmcClusterDAO clusterCache = new UmcClusterDAOHibernate(); IUmcDAO featureCache = new UmcDAOHibernate(); // Creating a dataset Console.WriteLine("Creating dummy datasets"); var datasets = new List<DatasetInformation>(); var total = totalDatasets; for (var i = 0; i < total; i++) { var dataset = new DatasetInformation(); dataset.DatasetId = i; dataset.DatasetName = "test" + i; datasets.Add(dataset); } datasetCache.AddAll(datasets); datasets.Clear(); datasets = datasetCache.FindAll(); // Create features Console.WriteLine("Creating features"); var features = new List<UMCLight>(); var clusters = new List<UMCClusterLight>(); var x = new Random(); var featureId = 0; for (var i = 0; i < totalClusters; i++) { var N = x.Next(1, total); var charge = x.Next(1, 10); var hash = new HashSet<int>(); var net = x.NextDouble(); var mass = 400 + (1600*x.NextDouble()); var dt = 60*x.NextDouble(); for (var j = 0; j < N; j++) { var did = -1; do { did = x.Next(0, total); if (!hash.Contains(did)) { hash.Add(did); break; } } while (true); var feature = new UMCLight { GroupId = did, Id = featureId++, ChargeState = charge, MassMonoisotopic = FeatureLight.ComputeDaDifferenceFromPPM(mass, 3) }; feature.MassMonoisotopicAligned = feature.MassMonoisotopic; feature.Net = net + 0.03 * x.NextDouble(); feature.NetAligned = feature.Net; feature.Net = feature.Net; feature.DriftTime = dt; feature.AbundanceSum = x.Next(100, 200); feature.Abundance = feature.Abundance; feature.ClusterId = -1; features.Add(feature); } } featureCache.AddAll(features); }
public UMCTreeViewModel(UMCLight feature) : this(feature, null) { }
public void TestClusterGeneration(string databasePath, string crossPath, int charge, int minimumClusterSize) { File.Delete(databasePath); NHibernateUtil.ConnectToDatabase(databasePath, true); IDatasetDAO datasetCache = new DatasetDAOHibernate(); IUmcClusterDAO clusterCache = new UmcClusterDAOHibernate(); IUmcDAO featureCache = new UmcDAOHibernate(); // Creating a dataset Console.WriteLine("Creating dummy datasets"); var datasets = new List<DatasetInformation>(); var total = 10; for (var i = 0; i < total; i++) { var dataset = new DatasetInformation(); dataset.DatasetId = i; dataset.DatasetName = "test" + i; datasets.Add(dataset); } datasetCache.AddAll(datasets); datasets.Clear(); datasets = datasetCache.FindAll(); // Create features Console.WriteLine("Creating features"); var features = new List<UMCLight>(); var clusters = new List<UMCClusterLight>(); var x = new Random(); var featureId = 0; for (var i = 0; i < 100; i++) { var cluster = new UMCClusterLight(); cluster.Id = i; cluster.AmbiguityScore = i; cluster.Tightness = i; var N = x.Next(1, total); cluster.Id = i; cluster.ChargeState = charge; var hash = new HashSet<int>(); for (var j = 0; j < N; j++) { var did = -1; do { did = x.Next(0, total); if (!hash.Contains(did)) { hash.Add(did); break; } } while (true); var feature = new UMCLight(); feature.GroupId = did; feature.Id = featureId++; feature.ChargeState = charge; feature.MassMonoisotopic = x.NextDouble(); feature.Net = x.NextDouble(); feature.AbundanceSum = x.Next(100, 200); feature.Abundance = feature.Abundance; feature.ClusterId = cluster.Id; cluster.AddChildFeature(feature); features.Add(feature); } cluster.CalculateStatistics(ClusterCentroidRepresentation.Mean); clusters.Add(cluster); } featureCache.AddAll(features); clusterCache.AddAll(clusters); clusters = clusterCache.FindAll(); Console.WriteLine("Find all clusters"); clusters = clusterCache.FindByCharge(charge); WriteClusters(datasets, clusters, minimumClusterSize, charge, crossPath, databasePath, 300000); }
public List<UMCLight> ReadFeatures(string path) { var features = new List<UMCLight>(); var data = File.ReadLines(path).ToList(); var isClusters = true; var i = 1; while (i < data.Count && isClusters) { isClusters = !(data[i].ToLower().Contains("dataset")); i = i + 1; } i = i + 1; while (i < data.Count) { var line = data[i]; var lineData = line.Split(','); if (line.Length > 6) { var clusterID = Convert.ToInt32(lineData[0]); var feature = new UMCLight { GroupId = Convert.ToInt32(lineData[1]), Id = Convert.ToInt32(lineData[2]), MassMonoisotopicAligned = Convert.ToDouble(lineData[3]), Net = Convert.ToDouble(lineData[4]) }; feature.MassMonoisotopic = feature.MassMonoisotopicAligned; feature.NetAligned = Convert.ToDouble(lineData[4]); feature.Net = feature.NetAligned; feature.DriftTime = Convert.ToDouble(lineData[5]); feature.ChargeState = Convert.ToInt32(lineData[6]); features.Add(feature); } i = i + 1; } return features; }
/// <summary> /// Creates an Xic for a feature based on individual charge states. /// </summary> /// <param name="rawPath">Path to the raw file.</param> /// <param name="peaksPath">Path to the peaks file.</param> /// <param name="feature">Feature to target</param> public Dictionary<int, Chromatogram> CreateXicForChargeStates(UMCLight feature, bool shouldSmooth) { Dictionary<int, Chromatogram> chromatograms = new Dictionary<int, Chromatogram>(); Dictionary<int, List<XYZData>> charges = feature.CreateChargeSIC(); XicFinder finder = new XicFinder(); feature.ChargeStateChromatograms.Clear(); // foreach (int charge in charges.Keys) { // This is the current XIC - but it's not that great List<XYZData> xicMz = charges[charge]; // Finds the maximum point in the XIC, we'll use this as our target, it most likely contains // the exact point that we'll want to use to help identify the feature. var maxPoint = xicMz.Where( u => u.Y == xicMz.Max(x=>x.Y)).Select(u=> new { u.X, u.Y, u.Z}).FirstOrDefault(); int targetScan = Convert.ToInt32(maxPoint.X); double targetMz = maxPoint.Z; // Find the Xic based on the target point, this may include other peaks List<PNNLOmics.Data.XYData> totalXic = null; try { totalXic = FindXic(targetMz, targetScan, shouldSmooth); if (totalXic.Count > 1) { // Then find a specific Xic based on the target scan. List<PNNLOmics.Data.XYData> specificXic = finder.FindTarget(totalXic, targetScan); // Add the targeted Xic to the charge state map so that we can create Xic's for each charge state. Chromatogram gram = new Chromatogram(specificXic, maxPoint.Z, charge); chromatograms.Add(charge, gram); } } catch (PreconditionException) { // This would mean that the charge state didnt have enough features in it. } } return chromatograms; }
public void Delete(UMCLight t) { throw new NotImplementedException(); }