public static void IndexUimfFile(string uimfFileLocation) { bool indexed = false; using (var uimfReader = new DataReader(uimfFileLocation)) { if (uimfReader.DoesContainBinCentricData()) { indexed = true; Console.WriteLine("Bin centric data found in dataset {0}.", uimfFileLocation); } else { Console.WriteLine("No bin centric data found for file {0}.", uimfFileLocation); } uimfReader.Dispose(); } if (!indexed) { Console.WriteLine("Creating bin centric data for {0}.", uimfFileLocation); using (DataWriter dataWriter = new DataWriter(uimfFileLocation)) { dataWriter.CreateBinCentricTables(); dataWriter.Dispose(); } } }
public void TestCreateBinCentricTables() { DataReaderTests.DataReaderTests.PrintMethodName(System.Reflection.MethodBase.GetCurrentMethod()); var fiSource = new FileInfo(FileRefs.BinCentricTest1); if (!fiSource.Exists) { return; } var fiTarget = DuplicateUIMF(fiSource, "_BinCentric"); if (fiTarget == null) { return; } var executingAssembly = System.Reflection.Assembly.GetExecutingAssembly(); using (var uimfWriter = new DataWriter(fiTarget.FullName, executingAssembly)) { uimfWriter.CreateBinCentricTables(); } Console.WriteLine("Added bin centric tables to " + fiTarget.FullName); }
/// <summary> /// /// </summary> /// <param name="uimf"></param> /// <param name="frameNumber"></param> /// <param name="xicMz"></param> /// <param name="tolerance"></param> /// <param name="getMsms"></param> /// <returns></returns> private IEnumerable <KeyValuePair <double, double> > GetXicInfo( DataReader uimf, int frameNumber, double xicMz, double tolerance, bool getMsms) { const DataReader.ToleranceType Tolerance = DataReader.ToleranceType.PPM; var frametype = getMsms ? DataReader.FrameType.MS2 : DataReader.FrameType.MS1; if (!uimf.DoesContainBinCentricData()) { Console.WriteLine(uimf.UimfFilePath + " Does not have bin centric data which is required to get XiC"); Console.WriteLine("starting to create it, this may take some time"); var fileName = uimf.UimfFilePath; uimf.Dispose(); // why is this being disposed -- this is INSIDE a using statement! SAP 4/4/2016 using (var dataWriter = new DataWriter(fileName)) { dataWriter.CreateBinCentricTables(); } uimf = new DataReader(fileName); // WHY IS THIS BEING SET?! This is inside a using statement! Console.WriteLine("Finished Creating bin centric tables for " + uimf.UimfFilePath); } var data = new List <KeyValuePair <double, double> >(); try { var xic = uimf.GetXic(xicMz, tolerance, frametype, Tolerance); var frameData = xic.Where(point => point.ScanLc == frameNumber - 1); // I think this is more readable with a regular loop than a very long linq query foreach (var intensityPoint in frameData) { var driftTime = uimf.GetDriftTime(intensityPoint.ScanLc + 1, intensityPoint.ScanIms, true); data.Add(new KeyValuePair <double, double>(driftTime, intensityPoint.Intensity)); } } catch (Exception) { Console.Error.WriteLine("Unable to get XiC on first attempt for " + uimf.UimfFilePath); } return(data); }
public SaturationDetector(string uimfFileLocation) { _uimfReader = new DataReader(uimfFileLocation); _smoother = new SavitzkyGolaySmoother(9, 2); _peakDetector = new ChromPeakDetector(0.0001, 0.0001); _theoreticalFeatureGenerator = new JoshTheorFeatureGenerator(); if (!_uimfReader.DoesContainBinCentricData()) { DataWriter dataWriter = new DataWriter(uimfFileLocation); dataWriter.CreateBinCentricTables(); } IterativeTFFParameters msFeatureFinderParameters = new IterativeTFFParameters { MinimumRelIntensityForForPeakInclusion = 0.0000000001, PeakDetectorMinimumPeakBR = 0, PeakDetectorPeakBR = 5.00000000000002, PeakBRStep = 0.25, PeakDetectorSigNoiseRatioThreshold = 0.00000000001, ToleranceInPPM = 50 }; _msFeatureFinder = new IterativeTFF(msFeatureFinderParameters); }
/// <summary> /// Initializes a new instance of the <see cref="LibraryMatchWorkflow"/> class. /// </summary> /// <param name="uimfFileLocation"> /// The UIMF file location. /// </param> /// <param name="outputDirectory"> /// The output directory. /// </param> /// <param name="resultFileName"> /// The result file name. /// </param> /// <param name="parameters"> /// The parameters. /// </param> public LibraryMatchWorkflow(string uimfFileLocation, string outputDirectory, string resultFileName, LibraryMatchParameters parameters) { this.uimfReader = new DataReader(uimfFileLocation); // Append bin-centric table to the uimf if not present. if (!this.uimfReader.DoesContainBinCentricData()) { DataWriter dataWriter = new DataWriter(uimfFileLocation); dataWriter.CreateBinCentricTables(); } this.Parameters = parameters; this.smoother = new SavitzkyGolaySmoother(parameters.NumPointForSmoothing, 2); this.NumberOfFrames = this.uimfReader.GetGlobalParams().NumFrames; this.NumberOfScans = this.uimfReader.GetFrameParams(1).Scans; this.DatasetName = Path.GetFileNameWithoutExtension(uimfFileLocation); this.Parameters = parameters; this.ResultFileName = resultFileName; if (outputDirectory == string.Empty) { outputDirectory = Directory.GetCurrentDirectory(); } if (!outputDirectory.EndsWith("\\")) { outputDirectory += "\\"; } if (!Directory.Exists(outputDirectory)) { try { Directory.CreateDirectory(outputDirectory); } catch (Exception) { Console.WriteLine("Failed to create directory."); throw; } } this.OutputPath = outputDirectory; Trace.Listeners.Clear(); ConsoleTraceListener consoleTraceListener = new ConsoleTraceListener(false); consoleTraceListener.TraceOutputOptions = TraceOptions.DateTime; string result = this.OutputPath + this.ResultFileName; this.resultFileWriter = File.AppendText(result); TextWriterTraceListener resultFileTraceListener = new TextWriterTraceListener(this.resultFileWriter) { Name = "this.DatasetName" + "_Result", TraceOutputOptions = TraceOptions.ThreadId | TraceOptions.DateTime }; Trace.Listeners.Add(consoleTraceListener); Trace.Listeners.Add(resultFileTraceListener); Trace.AutoFlush = true; }
/// <summary> /// Initializes a new instance of the <see cref="LcImsPeptideSearchWorkfow"/> class. /// </summary> /// <param name="uimfFileLocation"> /// The uimf file location. /// </param> /// <param name="parameters"> /// The parameters. /// </param> public LcImsPeptideSearchWorkfow(string uimfFileLocation, LcImsPeptideSearchParameters parameters) { this._buildWatershedStopWatch = new Stopwatch(); this._smoothStopwatch = new Stopwatch(); this._featureFindStopWatch = new Stopwatch(); this._featureFindCount = 0; this._pointCount = 0; this._uimfFileLocation = uimfFileLocation; this._uimfReader = new DataReader(uimfFileLocation); // Append bin-centric table to the uimf if not present. if (!this._uimfReader.DoesContainBinCentricData()) { DataWriter dataWriter = new DataWriter(uimfFileLocation); dataWriter.CreateBinCentricTables(); } this._parameters = parameters; this._smoother = new SavitzkyGolaySmoother(parameters.NumPointForSmoothing, 2); this._theoreticalFeatureGenerator = new JoshTheorFeatureGenerator(); this._leftOfMonoPeakLooker = new LeftOfMonoPeakLooker(); this._peakDetector = new ChromPeakDetector(0.0001, 0.0001); this._isotopicPeakFitScoreCalculator = new PeakLeastSquaresFitter(); IterativeTFFParameters msFeatureFinderParameters = new IterativeTFFParameters { MinimumRelIntensityForForPeakInclusion = 0.0001, PeakDetectorMinimumPeakBR = 0.0001, PeakDetectorPeakBR = 5.0002, PeakBRStep = 0.25, PeakDetectorSigNoiseRatioThreshold = 0.0001, ToleranceInPPM = parameters.MassToleranceInPpm }; this._msFeatureFinder = new IterativeTFF(msFeatureFinderParameters); this.NumberOfFrames = this._uimfReader.GetGlobalParams().NumFrames; this.NumberOfScans = this._uimfReader.GetFrameParams(1).Scans; }
/// <summary> /// Initializes a new instance of the <see cref="CrossSectionWorkfow"/> class. /// </summary> /// <param name="uimfFileLocation"> /// The uimf file location. /// </param> /// <param name="outputDirectory"> /// The output directory. /// </param> /// <param name="logFileName"> /// The log file name. /// </param> /// <param name="parameters"> /// The parameters. /// </param> public CrossSectionWorkfow(string uimfFileLocation, string outputDirectory, CrossSectionSearchParameters parameters) { this.uimfReader = new DataReader(uimfFileLocation); // Append bin-centric table to the uimf if not present. if (!this.uimfReader.DoesContainBinCentricData()) { DataWriter dataWriter = new DataWriter(uimfFileLocation); dataWriter.CreateBinCentricTables(); } this.Parameters = parameters; this.smoother = new SavitzkyGolaySmoother(parameters.NumPointForSmoothing, 5); this.theoreticalFeatureGenerator = new JoshTheorFeatureGenerator(); this.peakDetector = new ChromPeakDetector(0.0001, 0.0001); this.NumberOfFrames = this.uimfReader.GetGlobalParams().NumFrames; this.NumberOfScans = this.uimfReader.GetFrameParams(1).Scans; this.SampleCollectionDate = this.uimfReader.GetGlobalParams().GetValue(GlobalParamKeyType.DateStarted); this.DatasetName = Path.GetFileNameWithoutExtension(uimfFileLocation); this.OutputPath = outputDirectory; this.DatasetPath = uimfFileLocation; this.Parameters = parameters; if (outputDirectory == string.Empty) { outputDirectory = Directory.GetCurrentDirectory(); } if (!outputDirectory.EndsWith("\\")) { outputDirectory += "\\"; } if (!Directory.Exists(outputDirectory)) { try { Directory.CreateDirectory(outputDirectory); } catch (Exception) { Console.WriteLine("Failed to create directory."); throw; } } this.OutputPath = outputDirectory; }