/// <summary> /// Finds the XIC based on the m/z and scan parameters. /// </summary> /// <param name="mz"></param> /// <param name="scan"></param> /// <returns></returns> public List <XYData> FindXic(double mz, int scan, bool shouldSmooth) { LcmsFeatureTarget target = new LcmsFeatureTarget(); target.ID = 0; target.MZ = mz; target.ScanLCTarget = scan; target.ElutionTimeUnit = Globals.ElutionTimeUnit.ScanNum; m_run.CurrentMassTag = target; var result = m_run.ResultCollection.GetTargetedResult(m_run.CurrentMassTag); double chromPeakGeneratorTolInPPM = MzPpmWindow; Globals.ChromatogramGeneratorMode chromGeneratorMode = Globals.ChromatogramGeneratorMode.MZ_BASED; var chromGen = new PeakChromatogramGenerator(chromPeakGeneratorTolInPPM, chromGeneratorMode); chromGen.NETWindowWidthForNonAlignedData = Convert.ToSingle(NetWindow); int pointsToSmooth = 5; var chromSmoother = new SavitzkyGolaySmoother(pointsToSmooth, 2); double chromPeakDetectorPeakBR = 1; double chromPeakDetectorSigNoise = 1; var chromPeakDetector = new ChromPeakDetector(chromPeakDetectorPeakBR, chromPeakDetectorSigNoise); ChromPeakSelectorParameters chromPeakSelectorParameters = new ChromPeakSelectorParameters(); var chromPeakSelector = new BasicChromPeakSelector(chromPeakSelectorParameters); //this generates an extracted ion chromatogram // Since we are not using the built in generator, chromGen.Execute(m_run.ResultCollection); //this smooths the data - very important step! if (shouldSmooth) { chromSmoother.Execute(m_run.ResultCollection); } //this detects peaks within an extracted ion chromatogram chromPeakDetector.Execute(m_run.ResultCollection); //this selects the peak chromPeakSelector.Parameters.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget; chromPeakSelector.Execute(m_run.ResultCollection); //Here's the chromatogram data... List <XYData> data = new List <XYData>(); for (int i = 0; i < m_run.XYData.Xvalues.Length; i++) { XYData datum = new XYData(m_run.XYData.Xvalues[i], m_run.XYData.Yvalues[i]); data.Add(datum); } return(data); }
private TargetBase ConvertTextToDataObject(List <string> processedData) { var target = new LcmsFeatureTarget(); target.DatabaseName = LookupData(processedData, datasetHeaders); target.ID = ParseIntField(LookupData(processedData, targetIDHeaders)); target.ChargeState = (short)ParseIntField(LookupData(processedData, chargeStateHeaders)); target.ChargeStateTargets = new List <int>(); var lowerChargeState = ParseIntField(LookupData(processedData, chargeStateLowerHeaders)); var upperChargeState = ParseIntField(LookupData(processedData, chargeStateUpperHeaders)); if (lowerChargeState == -1 || upperChargeState == -1) { target.ChargeStateTargets.Add(target.ChargeState); } else { for (var i = lowerChargeState; i <= upperChargeState; i++) { target.ChargeStateTargets.Add(i); } } target.ScanLCTarget = ParseIntField(LookupData(processedData, scanHeaders)); target.ElutionTimeUnit = Globals.ElutionTimeUnit.ScanNum; target.MonoIsotopicMass = ParseDoubleField(LookupData(processedData, monomassHeaders)); target.MZ = target.MonoIsotopicMass / target.ChargeState + Globals.PROTON_MASS; target.FeatureToMassTagID = ParseIntField(LookupData(processedData, featureToMassTagIDHeaders)); target.EmpiricalFormula = LookupData(processedData, empiricalFormulaHeaders, String.Empty); target.Code = LookupData(processedData, peptideSequenceHeaders, String.Empty); //UMCIndex ScanStart ScanEnd ScanClassRep //NETClassRep UMCMonoMW UMCMWStDev UMCMWMin //UMCMWMax UMCAbundance ClassStatsChargeBasis // ChargeStateMin ChargeStateMax UMCMZForChargeBasis //UMCMemberCount UMCMemberCountUsedForAbu UMCAverageFit //MassShiftPPMClassRep PairIndex PairMemberType ExpressionRatio // //ExpressionRatioStDev ExpressionRatioChargeStateBasisCount //ExpressionRatioMemberBasisCount MultiMassTagHitCount //MassTagID MassTagMonoMW MassTagNET MassTagNETStDev SLiC Score //DelSLiC MemberCountMatchingMassTag IsInternalStdMatch PeptideProphetProbability Peptide return(target); }
protected virtual TargetCollection GetLcmsFeatureTargets(string targetsFilePath) { if (targetsFilePath.ToLower().Contains("_msgf")) { var iqTargetImporter = new BasicIqTargetImporter(targetsFilePath); var iqTargets = iqTargetImporter.Import(); var targetUtilities = new IqTargetUtilities(); var targetCollection = new TargetCollection(); targetCollection.TargetList = new List <TargetBase>(); foreach (var iqTarget in iqTargets) { if (iqTarget.QualityScore > MsgfFdrScoreCutoff) { continue; } targetUtilities.UpdateTargetMissingInfo(iqTarget); TargetBase oldStyleTarget = new LcmsFeatureTarget(); oldStyleTarget.ChargeState = (short)iqTarget.ChargeState; oldStyleTarget.Code = iqTarget.Code; oldStyleTarget.EmpiricalFormula = iqTarget.EmpiricalFormula; oldStyleTarget.ID = iqTarget.ID; oldStyleTarget.MZ = iqTarget.MZTheor; oldStyleTarget.MonoIsotopicMass = iqTarget.MonoMassTheor; oldStyleTarget.ScanLCTarget = iqTarget.ScanLC; oldStyleTarget.NormalizedElutionTime = (float)iqTarget.ElutionTimeTheor; oldStyleTarget.ElutionTimeUnit = DeconTools.Backend.Globals.ElutionTimeUnit.ScanNum; targetCollection.TargetList.Add(oldStyleTarget); } return(targetCollection); } var importer = new LcmsTargetFromFeaturesFileImporter(targetsFilePath); var lcmsTargetCollection = importer.Import(); return(lcmsTargetCollection); }
private void SetCurrentWorkflowTarget(TargetedResultDTO result) { TargetBase target = new LcmsFeatureTarget(); target.ChargeState = (short)result.ChargeState; target.ChargeStateTargets.Add(target.ChargeState); target.ElutionTimeUnit = DeconTools.Backend.Globals.ElutionTimeUnit.ScanNum; target.EmpiricalFormula = result.EmpiricalFormula; target.ID = (int)result.TargetID; target.IsotopicProfile = null; //workflow will determine this target.MZ = result.MonoMZ; target.MonoIsotopicMass = result.MonoMass; target.ScanLCTarget = result.ScanLC; Run.CurrentMassTag = target; }
private void ReadResultsFromDB(TargetCollection targetCollection, DbDataReader reader) { while (reader.Read()) { var result = new LcmsFeatureTarget(); result.ID = readInt(reader, "UMC_Ind"); result.FeatureToMassTagID = readInt(reader, "Mass_Tag_ID"); result.ChargeState = (short)readInt(reader, "Class_Stats_Charge_Basis"); result.MonoIsotopicMass = readDouble(reader, "Class_Mass"); result.MZ = result.MonoIsotopicMass / result.ChargeState + 1.00727649; result.NormalizedElutionTime = readFloat(reader, "ElutionTime"); result.ScanLCTarget = readInt(reader, "Scan_Max_Abundance"); result.ElutionTimeUnit = DeconTools.Backend.Globals.ElutionTimeUnit.ScanNum; targetCollection.TargetList.Add(result); } }
private void SetCurrentWorkflowTarget(SipperLcmsFeatureTargetedResultDTO result) { TargetBase target = new LcmsFeatureTarget(); target.ChargeState = (short)result.ChargeState; target.ChargeStateTargets.Add(target.ChargeState); target.ElutionTimeUnit = Globals.ElutionTimeUnit.ScanNum; target.EmpiricalFormula = result.EmpiricalFormula; target.ID = (int)result.TargetID; target.IsotopicProfile = null; //workflow will determine this target.MZ = result.MonoMZ; target.MonoIsotopicMass = result.MonoMass; target.ScanLCTarget = result.ScanLC; Run.CurrentMassTag = target; }
public void Test1() { var testFile = @"D:\Data\Orbitrap\BrianIQTesting\QC_Shew_11_02_pt5-b_6Jun11_Sphinx_11-03-27.RAW"; var peaksTestFile = @"D:\Data\Orbitrap\BrianIQTesting\QC_Shew_11_02_pt5-b_6Jun11_Sphinx_11-03-27_peaks.txt"; var run = RunUtilities.CreateAndLoadPeaks(testFile, peaksTestFile); var target = new LcmsFeatureTarget(); target.ID = 0; target.MZ = 715.39214; target.ScanLCTarget = 7343; target.ElutionTimeUnit = Globals.ElutionTimeUnit.ScanNum; run.CurrentMassTag = target; var result = run.ResultCollection.GetTargetedResult(run.CurrentMassTag); double chromPeakGeneratorTolInPPM = 20; var chromGeneratorMode = Globals.ChromatogramGeneratorMode.MZ_BASED; var chromGen = new PeakChromatogramGenerator(chromPeakGeneratorTolInPPM, chromGeneratorMode); // If we want to use the Execute Command //BLL .1 and .5 NET windows work. .02 NET window does not BR and SN was set to 1 however) chromGen.ChromWindowWidthForNonAlignedData = .02F; var pointsToSmooth = 5; var chromSmoother = new SavitzkyGolaySmoother(pointsToSmooth, 2); //BLL We also tried to set the BR and SIG NOISE to 0. This did not work var chromPeakDetectorPeakBR = 0.5; var chromPeakDetectorSigNoise = 0.5; var chromPeakDetector = new ChromPeakDetector(chromPeakDetectorPeakBR, chromPeakDetectorSigNoise); var chromPeakSelectorParameters = new ChromPeakSelectorParameters(); chromPeakSelectorParameters.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget; var chromPeakSelector = new BasicChromPeakSelector(chromPeakSelectorParameters); var smartChromPeakParameters = new SmartChromPeakSelectorParameters(); var smartChromPeakSelector = new SmartChromPeakSelector(smartChromPeakParameters); //this generates an extracted ion chromatogram // Since we are not using the built in generator, chromGen.Execute(run.ResultCollection); //this smooths the data - very important step! //BLL. This didnt work for me when we first started, instead of using the NET window above. //chromGen.GenerateChromatogram(run, // target.ScanLCTarget - 300, // target.ScanLCTarget + 300, // target.MZ, // chromPeakGeneratorTolInPPM); chromSmoother.Execute(run.ResultCollection); //this detects peaks within an extracted ion chromatogram chromPeakDetector.Execute(run.ResultCollection); //this selects the peak chromPeakSelector.Execute(run.ResultCollection); //smartChromPeakSelector.Execute(run.ResultCollection); //TestUtilities.DisplayXYValues(run.XYData); TestUtilities.DisplayPeaks(run.PeakList); Console.WriteLine("Number of peaks detected = " + run.PeakList.Count); Console.WriteLine("Selected peak= " + result.ChromPeakSelected); }
public TargetCollection Import(out Dictionary <int, PrsmData> prsmData) { StreamReader reader; prsmData = new Dictionary <int, PrsmData>(); if (!File.Exists(_filename)) { throw new FileNotFoundException("Input file not found: " + _filename); } try { reader = new StreamReader(_filename); } catch (Exception ex) { throw new IOException("There was a problem importing from the file.", ex); } var targets = new TargetCollection(); // Group LcmsFeatureTargets by their code var proteinSpeciesGroups = new Dictionary <string, List <LcmsFeatureTarget> >(); using (var sr = reader) { if (sr.Peek() == -1) { sr.Close(); throw new InvalidDataException("There is no data in the file we are trying to read."); } var columnHeaders = sr.ReadLine().Split('\t').ToList(); var columnMapping = GetColumnMapping(columnHeaders); var lineCounter = 0; //used for tracking which line is being processed. //read and process each line of the file while (sr.Peek() > -1) { ++lineCounter; _dataRowsProcessed = lineCounter; var processedData = sr.ReadLine().Split('\t').ToList(); //ensure that processed line is the same size as the header line if (processedData.Count != columnHeaders.Count) { throw new InvalidDataException("Data in row #" + lineCounter.ToString(CultureInfo.InvariantCulture) + "is invalid - \nThe number of columns does not match that of the header line"); } // Get Prsm_ID int prsmId; if (!int.TryParse(processedData[columnMapping[PRSM_ID_HEADER]], out prsmId)) { throw new InvalidDataException("Could not parse Prsm ID."); } // Get scan int scanLcTarget; if (!int.TryParse(processedData[columnMapping[SCAN_HEADER]], out scanLcTarget)) { throw new InvalidDataException("Could not parse scan number."); } // Get charge state short chargeState; if (!short.TryParse(processedData[columnMapping[CHARGE_HEADER]], out chargeState)) { throw new InvalidDataException("Could not parse charge."); } // Get code var code = processedData[columnMapping[PEPTIDE_HEADER]]; string empiricalFormula; // Modified species, try to get empirical formula if (code.Contains("(")) { empiricalFormula = GetEmpiricalFormulaForSequenceWithMods(code); // Unknown modification in sequence, skip if (String.IsNullOrEmpty(empiricalFormula)) { ++_dataRowsSkippedUnknownMods; continue; } } else { empiricalFormula = _peptideUtils.GetEmpiricalFormulaForPeptideSequence(code); } // Get monoisotopic mass var monoisotopicMass = EmpiricalFormulaUtilities.GetMonoisotopicMassFromEmpiricalFormula(empiricalFormula); // Get Protein_mass double proteinMass; if (!double.TryParse(processedData[columnMapping[PROTEIN_MASS_HEADER]], out proteinMass)) { throw new InvalidDataException("Could not parse protein mass."); } // Get protein name var proteinName = processedData[columnMapping[PROTEIN_NAME_HEADER]]; // Get score double eValueDbl; if (!double.TryParse(processedData[columnMapping[E_VALUE_HEADER]], out eValueDbl)) { if (processedData[columnMapping[E_VALUE_HEADER]].ToLower() == "Infinity") { eValueDbl = float.MaxValue; } else { throw new InvalidDataException("Could not parse e-value."); } } float eValue; if (eValueDbl > float.MaxValue) { eValue = float.MaxValue; } else { eValue = (float)eValueDbl; } // Make Prsm prsmData.Add(prsmId, new PrsmData { ProteinMass = proteinMass, ProteinName = proteinName, EValue = eValue }); // Create target var target = new LcmsFeatureTarget { FeatureToMassTagID = prsmId, ID = -1, ElutionTimeUnit = DeconTools.Backend.Globals.ElutionTimeUnit.ScanNum, ScanLCTarget = scanLcTarget, Code = code, EmpiricalFormula = empiricalFormula, MonoIsotopicMass = monoisotopicMass, ChargeState = chargeState, MZ = monoisotopicMass / chargeState + DeconTools.Backend.Globals.PROTON_MASS, }; if (!proteinSpeciesGroups.ContainsKey(code)) { proteinSpeciesGroups.Add(code, new List <LcmsFeatureTarget>()); } proteinSpeciesGroups[code].Add(target); /* * // Create range * const int maxOffset = 0; * * for (short offset = -maxOffset; offset <= maxOffset; offset++) * { * // Create new target * var newCharge = (short) (chargeState + offset); * var targetCopy = new LcmsFeatureTarget(target) * { * ID = ++idCounter, * ChargeState = newCharge, * MZ = target.MonoIsotopicMass / newCharge + DeconTools.Backend.Globals.PROTON_MASS * }; * // Add target * targets.TargetIDList.Add(idCounter); * targets.TargetList.Add(targetCopy); * } */ } sr.Close(); } // Loop through each protein species group and add in the missing charge states var idCounter = 0; foreach (var keyValuePair in proteinSpeciesGroups) { var targetGroup = AddChargeStates(keyValuePair.Value, EXTEND_CHARGE_RANGE); var chargeStates = new List <short> { 0 }; // Add all targets in group and IDs to list foreach (var target in targetGroup) { if (!chargeStates.Contains(target.ChargeState)) { chargeStates.Add(target.ChargeState); target.ID = ++idCounter; targets.TargetList.Add(target); targets.TargetIDList.Add(idCounter); } } } return(targets); }
/// <summary> /// Finds the XIC based on the m/z and scan parameters. /// </summary> /// <param name="mz"></param> /// <param name="scan"></param> /// <returns></returns> public List<PNNLOmics.Data.XYData> FindXic(double mz, int scan, bool shouldSmooth) { LcmsFeatureTarget target = new LcmsFeatureTarget(); target.ID = 0; target.MZ = mz; target.ScanLCTarget = scan; target.ElutionTimeUnit = Globals.ElutionTimeUnit.ScanNum; m_run.CurrentMassTag = target; var result = m_run.ResultCollection.GetTargetedResult(m_run.CurrentMassTag); double chromPeakGeneratorTolInPPM = MzPpmWindow; Globals.ChromatogramGeneratorMode chromGeneratorMode = Globals.ChromatogramGeneratorMode.MZ_BASED; var chromGen = new PeakChromatogramGenerator( chromPeakGeneratorTolInPPM, chromGeneratorMode); chromGen.NETWindowWidthForNonAlignedData = Convert.ToSingle(NetWindow); int pointsToSmooth = 5; var chromSmoother = new SavitzkyGolaySmoother(pointsToSmooth, 2); double chromPeakDetectorPeakBR = 1; double chromPeakDetectorSigNoise = 1; var chromPeakDetector = new ChromPeakDetector( chromPeakDetectorPeakBR, chromPeakDetectorSigNoise); ChromPeakSelectorParameters chromPeakSelectorParameters = new ChromPeakSelectorParameters(); var chromPeakSelector = new BasicChromPeakSelector(chromPeakSelectorParameters); //this generates an extracted ion chromatogram // Since we are not using the built in generator, chromGen.Execute(m_run.ResultCollection); //this smooths the data - very important step! if (shouldSmooth) { chromSmoother.Execute(m_run.ResultCollection); } //this detects peaks within an extracted ion chromatogram chromPeakDetector.Execute(m_run.ResultCollection); //this selects the peak chromPeakSelector.Parameters.PeakSelectorMode = Globals.PeakSelectorMode.ClosestToTarget; chromPeakSelector.Execute(m_run.ResultCollection); //Here's the chromatogram data... List<PNNLOmics.Data.XYData> data = new List<PNNLOmics.Data.XYData>(); for (int i = 0; i < m_run.XYData.Xvalues.Length; i++) { PNNLOmics.Data.XYData datum = new PNNLOmics.Data.XYData(m_run.XYData.Xvalues[i], m_run.XYData.Yvalues[i]); data.Add(datum); } return data; }