/// <summary> /// Append a custom m/z value to CustomMZSearchValues /// </summary> /// <param name="mzSearchSpec"></param> public void AddMzSearchTarget(clsCustomMZSearchSpec mzSearchSpec) { if (CustomMZSearchValues.Count > 0) { RawTextMZList += ","; RawTextMZToleranceDaList += ","; RawTextScanOrAcqTimeCenterList += ","; RawTextScanOrAcqTimeToleranceList += ","; } RawTextMZList += mzSearchSpec.MZ.ToString(CultureInfo.InvariantCulture); RawTextMZToleranceDaList += mzSearchSpec.MZToleranceDa.ToString(CultureInfo.InvariantCulture); RawTextScanOrAcqTimeCenterList += mzSearchSpec.ScanOrAcqTimeCenter.ToString(CultureInfo.InvariantCulture); RawTextScanOrAcqTimeToleranceList += mzSearchSpec.ScanOrAcqTimeTolerance.ToString(CultureInfo.InvariantCulture); CustomMZSearchValues.Add(mzSearchSpec); }
public bool SetCustomSICListValues( eCustomSICScanTypeConstants eScanType, double mzToleranceDa, float scanOrAcqTimeToleranceValue, double[] mzList, double[] mzToleranceList, float[] scanOrAcqTimeCenterList, float[] scanOrAcqTimeToleranceList, string[] scanComments) { if (mzToleranceList.Length > 0 && mzToleranceList.Length != mzList.Length) { // Invalid Custom SIC comment list; number of entries doesn't match return(false); } if (scanOrAcqTimeCenterList.Length > 0 && scanOrAcqTimeCenterList.Length != mzList.Length) { // Invalid Custom SIC scan center list; number of entries doesn't match return(false); } if (scanOrAcqTimeToleranceList.Length > 0 && scanOrAcqTimeToleranceList.Length != mzList.Length) { // Invalid Custom SIC scan center list; number of entries doesn't match return(false); } if (scanComments.Length > 0 && scanComments.Length != mzList.Length) { // Invalid Custom SIC comment list; number of entries doesn't match return(false); } ResetMzSearchValues(); ScanToleranceType = eScanType; // This value is used if scanOrAcqTimeToleranceList is blank or for any entries in scanOrAcqTimeToleranceList() that are zero ScanOrAcqTimeTolerance = scanOrAcqTimeToleranceValue; if (mzList.Length == 0) { return(true); } for (var index = 0; index < mzList.Length; index++) { var mzSearchSpec = new clsCustomMZSearchSpec(mzList[index]); if (mzToleranceList.Length > index && mzToleranceList[index] > 0) { mzSearchSpec.MZToleranceDa = mzToleranceList[index]; } else { mzSearchSpec.MZToleranceDa = mzToleranceDa; } if (scanOrAcqTimeCenterList.Length > index) { mzSearchSpec.ScanOrAcqTimeCenter = scanOrAcqTimeCenterList[index]; } else { mzSearchSpec.ScanOrAcqTimeCenter = 0; } // Set to 0 to indicate that the entire file should be searched if (scanOrAcqTimeToleranceList.Length > index && scanOrAcqTimeToleranceList[index] > 0) { mzSearchSpec.ScanOrAcqTimeTolerance = scanOrAcqTimeToleranceList[index]; } else { mzSearchSpec.ScanOrAcqTimeTolerance = scanOrAcqTimeToleranceValue; } if (scanComments.Length > 0 && scanComments.Length > index) { mzSearchSpec.Comment = scanComments[index]; } else { mzSearchSpec.Comment = string.Empty; } AddMzSearchTarget(mzSearchSpec); } ValidateCustomSICList(); return(true); }
/// <summary> /// Parse parallel lists of custom m/z info /// </summary> /// <param name="mzList">Comma or tab separated list of m/z values</param> /// <param name="mzToleranceDaList">Comma or tab separated list of tolerances (in Da)</param> /// <param name="scanCenterList">Comma or tab separated list of scan centers</param> /// <param name="scanToleranceList">Comma or tab separated list of scan tolerances</param> /// <param name="scanCommentList">Comma or tab separated list of comments</param> /// <returns></returns> public bool ParseCustomSICList( string mzList, string mzToleranceDaList, string scanCenterList, string scanToleranceList, string scanCommentList) { var delimiters = new[] { ',', '\t' }; // Trim any trailing tab characters mzList = mzList.TrimEnd('\t'); mzToleranceDaList = mzToleranceDaList.TrimEnd('\t'); scanCenterList = scanCenterList.TrimEnd('\t'); scanToleranceList = scanToleranceList.TrimEnd('\t'); scanCommentList = scanCommentList.TrimEnd(delimiters); var mzValues = mzList.Split(delimiters).ToList(); var mzToleranceDa = mzToleranceDaList.Split(delimiters).ToList(); var scanCenters = scanCenterList.Split(delimiters).ToList(); var scanTolerances = scanToleranceList.Split(delimiters).ToList(); List <string> lstScanComments; if (scanCommentList.Length > 0) { lstScanComments = scanCommentList.Split(delimiters).ToList(); } else { lstScanComments = new List <string>(); } ResetMzSearchValues(); if (mzValues.Count <= 0) { // Nothing to parse; return true return(true); } for (var index = 0; index < mzValues.Count; index++) { if (!double.TryParse(mzValues[index], out var targetMz)) { continue; } var mzSearchSpec = new clsCustomMZSearchSpec(targetMz) { MZToleranceDa = 0, ScanOrAcqTimeCenter = 0, // Set to 0 to indicate that the entire file should be searched ScanOrAcqTimeTolerance = 0 }; if (scanCenters.Count > index) { if (clsUtilities.IsNumber(scanCenters[index])) { if (ScanToleranceType == eCustomSICScanTypeConstants.Absolute) { mzSearchSpec.ScanOrAcqTimeCenter = int.Parse(scanCenters[index]); } else { // Includes .Relative and .AcquisitionTime mzSearchSpec.ScanOrAcqTimeCenter = float.Parse(scanCenters[index]); } } } if (scanTolerances.Count > index) { if (clsUtilities.IsNumber(scanTolerances[index])) { if (ScanToleranceType == eCustomSICScanTypeConstants.Absolute) { mzSearchSpec.ScanOrAcqTimeTolerance = int.Parse(scanTolerances[index]); } else { // Includes .Relative and .AcquisitionTime mzSearchSpec.ScanOrAcqTimeTolerance = float.Parse(scanTolerances[index]); } } } if (mzToleranceDa.Count > index) { if (clsUtilities.IsNumber(mzToleranceDa[index])) { mzSearchSpec.MZToleranceDa = double.Parse(mzToleranceDa[index]); } } if (lstScanComments.Count > index) { mzSearchSpec.Comment = lstScanComments[index]; } else { mzSearchSpec.Comment = string.Empty; } AddMzSearchTarget(mzSearchSpec); } return(true); }