public void OffsetFrequencyFunction() { var methodName = MethodBase.GetCurrentMethod().Name; TestUtils.ShowStarting(methodName); const string configFilePath = @"C:\Users\wilk011\Documents\DataFiles\OffsetFreqConfig.ini"; if (!File.Exists(configFilePath)) { Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, configFilePath); } InitTest(new ConfigFileReader(configFilePath)); foreach (var name in _names) { var tsvName = _preTsv.Replace("@", name); var rawName = _preRaw.Replace("@", name); var txtFiles = Directory.GetFiles(tsvName).ToList(); var rawFilesTemp = Directory.GetFiles(rawName).ToList(); var rawFiles = rawFilesTemp.Where(rawFile => Path.GetExtension(rawFile) == ".raw").ToList(); Assert.True(rawFiles.Count == txtFiles.Count); int tableCount = 1; if (_precursorCharge > 0) tableCount = _precursorCharge; var offsetFrequencyTables = new PrecursorOffsetFrequencyTable[tableCount]; for (int i = 0; i < tableCount; i++) { if (_precursorCharge > 0) offsetFrequencyTables[i] = new PrecursorOffsetFrequencyTable(_searchWidth/(i+1), i+1, _binWidth/(i+1)); else offsetFrequencyTables[i] = new PrecursorOffsetFrequencyTable(_searchWidth, i+1, _binWidth); } for (int i = 0; i < txtFiles.Count; i++) { string textFile = txtFiles[i]; string rawFile = rawFiles[i]; Console.WriteLine("{0}\t{1}", Path.GetFileName(textFile), Path.GetFileName(rawFile)); var lcms = new LazyLcMsRun(rawFile, _noiseFiltration, _noiseFiltration); var matchList = new SpectrumMatchList(lcms, txtFiles[i], DataFileFormat.IcBottomUp); for (int j = 0; j < tableCount; j++) { offsetFrequencyTables[j].AddMatches( _precursorCharge > 0 ? matchList.GetCharge(j + 1) : matchList); } } var offsetFrequencies = new List<Probability<double>>[tableCount]; for (int i = 0; i < tableCount; i++) { offsetFrequencies[i] = offsetFrequencyTables[i].GetProbabilities().ToList(); } var outFileName = _outFileName.Replace("@", name); for (int i = 0; i < tableCount; i++) { var chargeOutFileName = outFileName.Replace("*", (i + 1).ToString(CultureInfo.InvariantCulture)); using (var outFile = new StreamWriter(chargeOutFileName)) { outFile.WriteLine("Offset\tFound"); foreach (var offsetFrequency in offsetFrequencies[i]) { // int integerOffset = (int) Math.Round(offsetFrequency.Offset*_binWidth*(i + 1)); outFile.WriteLine("{0}\t{1}", offsetFrequency.Label, offsetFrequency.Prob); } } } } }
public void PrecursorOffsetFrequencyFunction() { var methodName = MethodBase.GetCurrentMethod().Name; TestUtils.ShowStarting(methodName); const string configFilePath = @"C:\Users\wilk011\Documents\DataFiles\PrecursorOffsetFreqConfig.ini"; if (!File.Exists(configFilePath)) { Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, configFilePath); } InitTest(new ConfigFileReader(configFilePath)); foreach (var name in _names) { var tsvName = _preTsv.Replace("@", name); var rawName = _preRaw.Replace("@", name); var txtFiles = Directory.GetFiles(tsvName).ToList(); var rawFilesTemp = Directory.GetFiles(rawName).ToList(); var rawFiles = rawFilesTemp.Where(rawFile => Path.GetExtension(rawFile) == ".raw").ToList(); Assert.True(rawFiles.Count == txtFiles.Count); var offsetFrequencyTables = new List<PrecursorOffsetFrequencyTable>[_precursorCharge]; for (int i = 0; i < _precursorCharge; i++) { offsetFrequencyTables[i] = new List<PrecursorOffsetFrequencyTable>(); for (int j = 1; j <= (i + 1); j++) { offsetFrequencyTables[i].Add(new PrecursorOffsetFrequencyTable(_searchWidth/j, j, _binWidth/j)); } } for (int i = 0; i < txtFiles.Count; i++) { string textFile = txtFiles[i]; string rawFile = rawFiles[i]; Console.WriteLine("{0}\t{1}", Path.GetFileName(textFile), Path.GetFileName(rawFile)); var lcms = new LazyLcMsRun(rawFile, _noiseFiltration, _noiseFiltration); var matchList = new SpectrumMatchList(lcms, txtFiles[i], DataFileFormat.IcBottomUp); for (int j = 0; j < _precursorCharge; j++) { var chargeMatches = matchList.GetCharge(j + 1); foreach (var offsetFrequencyTable in offsetFrequencyTables[j]) { offsetFrequencyTable.AddMatches(chargeMatches); } } } var outFileName = _outFileName.Replace("@", name); for (int i = 0; i < _precursorCharge; i++) { var chargeOutFileName = outFileName.Replace("*", (i + 1).ToString(CultureInfo.InvariantCulture)); using (var outFile = new StreamWriter(chargeOutFileName)) { outFile.Write("Offset\t"); var offsetFrequencyList = new List<List<Probability<double>>>(); for (int j = offsetFrequencyTables[i].Count-1; j >=0; j--) { offsetFrequencyList.Add(offsetFrequencyTables[i][j].GetProbabilities().ToList()); outFile.Write("{0}", (j+1)); if (j != 0) outFile.Write("\t"); } outFile.WriteLine(); for (int j = 0; j < offsetFrequencyList.First().Count; j++) { var offset = offsetFrequencyList.First()[j].Label; var integerOffset = Math.Round(offset*(1/_binWidth), 2); outFile.Write(integerOffset+"\t"); for (int k = 0; k < offsetFrequencyList.Count; k++) { outFile.Write(offsetFrequencyList[k][j].Prob); if (k != offsetFrequencyList.Count-1) outFile.Write("\t"); } outFile.WriteLine(); } } } } }
public void IonFrequencyFunction() { var methodName = MethodBase.GetCurrentMethod().Name; TestUtils.ShowStarting(methodName); const string configFilePath = @"C:\Users\wilk011\Documents\DataFiles\IonFreqConfig.ini"; if (!File.Exists(configFilePath)) { Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, configFilePath); } InitTest(new ConfigFileReader(configFilePath)); foreach (var name in _names) { var tsvName = _preTsv.Replace("@", name); var rawName = _preRaw.Replace("@", name); var txtFiles = Directory.GetFiles(tsvName).ToList(); var rawFilesTemp = Directory.GetFiles(rawName).ToList(); var rawFiles = rawFilesTemp.Where(rawFile => Path.GetExtension(rawFile) == ".raw").ToList(); Assert.True(rawFiles.Count == txtFiles.Count); int tableCount = 1; if (_precursorCharge > 0) { tableCount = _precursorCharge; } var ionFrequencyFunctions = new IonFrequencyTable[tableCount]; var decoyionFrequencyFunctions = new IonFrequencyTable[tableCount]; for (int i = 0; i < tableCount; i++) { ionFrequencyFunctions[i] = new IonFrequencyTable(_ionTypes, _defaultTolerance, _relativeIntensityThreshold, _combineCharges); decoyionFrequencyFunctions[i] = new IonFrequencyTable(_ionTypes, _defaultTolerance, _relativeIntensityThreshold, _combineCharges); } for (int i = 0; i < txtFiles.Count; i++) { string textFile = txtFiles[i]; string rawFile = rawFiles[i]; Console.WriteLine("{0}\t{1}", Path.GetFileName(textFile), Path.GetFileName(rawFile)); var lcms = new LazyLcMsRun(rawFile, NoiseFiltration, NoiseFiltration); var matchList = new SpectrumMatchList(lcms, txtFiles[i], DataFileFormat.IcBottomUp); SpectrumMatchList decoyMatchList = null; if (_useDecoy) { decoyMatchList = new SpectrumMatchList(lcms, txtFiles[i], DataFileFormat.IcBottomUp, 0, true); } for (int j = 0; j < tableCount; j++) { var matches = _precursorCharge > 0 ? matchList.GetCharge(j + 1) : matchList; matches.FilterSpectra(); ionFrequencyFunctions[j].AddMatches(matches); if (decoyMatchList != null) { var decoyMatches = _precursorCharge > 0 ? decoyMatchList.GetCharge(j + 1) : decoyMatchList; decoyMatches.FilterSpectra(); decoyionFrequencyFunctions[j].AddMatches(decoyMatches); } } } // Print Offset Frequency tables to output file var outFile = _outFileName.Replace("@", name); for (int i = 0; i < tableCount; i++) { string outFileName = outFile.Replace("*", (i + 1).ToString(CultureInfo.InvariantCulture)); var ionFrequencies = ionFrequencyFunctions[i].GetProbabilities(); var decoyionFrequencies = decoyionFrequencyFunctions[i].GetProbabilities(); using (var finalOutputFile = new StreamWriter(outFileName)) { finalOutputFile.Write("Ion\tTarget"); if (_useDecoy) { finalOutputFile.Write("\tDecoy"); } finalOutputFile.WriteLine(); for (int j = 0; j < ionFrequencies.Length; j++) { finalOutputFile.Write("{0}\t{1}", ionFrequencies[j].Label.Name, ionFrequencies[j].Prob); if (_useDecoy) { finalOutputFile.Write("\t{0}", decoyionFrequencies[j]); } finalOutputFile.WriteLine(); } } } } }
public void OffsetFrequencyFunction() { var methodName = MethodBase.GetCurrentMethod().Name; TestUtils.ShowStarting(methodName); const string configFilePath = @"C:\Users\wilk011\Documents\DataFiles\OffsetFreqConfig.ini"; if (!File.Exists(configFilePath)) { Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, configFilePath); } InitTest(new ConfigFileReader(configFilePath)); foreach (var name in _names) { var tsvName = _preTsv.Replace("@", name); var rawName = _preRaw.Replace("@", name); var txtFiles = Directory.GetFiles(tsvName).ToList(); var rawFilesTemp = Directory.GetFiles(rawName).ToList(); var rawFiles = rawFilesTemp.Where(rawFile => Path.GetExtension(rawFile) == ".raw").ToList(); Assert.True(rawFiles.Count == txtFiles.Count); int tableCount = 1; if (_precursorCharge > 0) { tableCount = _precursorCharge; } var offsetFrequencyTables = new PrecursorOffsetFrequencyTable[tableCount]; for (int i = 0; i < tableCount; i++) { if (_precursorCharge > 0) { offsetFrequencyTables[i] = new PrecursorOffsetFrequencyTable(_searchWidth / (i + 1), i + 1, _binWidth / (i + 1)); } else { offsetFrequencyTables[i] = new PrecursorOffsetFrequencyTable(_searchWidth, i + 1, _binWidth); } } for (int i = 0; i < txtFiles.Count; i++) { string textFile = txtFiles[i]; string rawFile = rawFiles[i]; Console.WriteLine("{0}\t{1}", Path.GetFileName(textFile), Path.GetFileName(rawFile)); var lcms = new LazyLcMsRun(rawFile, _noiseFiltration, _noiseFiltration); var matchList = new SpectrumMatchList(lcms, txtFiles[i], DataFileFormat.IcBottomUp); for (int j = 0; j < tableCount; j++) { offsetFrequencyTables[j].AddMatches( _precursorCharge > 0 ? matchList.GetCharge(j + 1) : matchList); } } var offsetFrequencies = new List <Probability <double> > [tableCount]; for (int i = 0; i < tableCount; i++) { offsetFrequencies[i] = offsetFrequencyTables[i].GetProbabilities().ToList(); } var outFileName = _outFileName.Replace("@", name); for (int i = 0; i < tableCount; i++) { var chargeOutFileName = outFileName.Replace("*", (i + 1).ToString(CultureInfo.InvariantCulture)); using (var outFile = new StreamWriter(chargeOutFileName)) { outFile.WriteLine("Offset\tFound"); foreach (var offsetFrequency in offsetFrequencies[i]) { // int integerOffset = (int) Math.Round(offsetFrequency.Offset*_binWidth*(i + 1)); outFile.WriteLine("{0}\t{1}", offsetFrequency.Label, offsetFrequency.Prob); } } } } }
public void PrecursorOffsetFrequencyFunction() { var methodName = MethodBase.GetCurrentMethod().Name; TestUtils.ShowStarting(methodName); const string configFilePath = @"C:\Users\wilk011\Documents\DataFiles\PrecursorOffsetFreqConfig.ini"; if (!File.Exists(configFilePath)) { Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, configFilePath); } InitTest(new ConfigFileReader(configFilePath)); foreach (var name in _names) { var tsvName = _preTsv.Replace("@", name); var rawName = _preRaw.Replace("@", name); var txtFiles = Directory.GetFiles(tsvName).ToList(); var rawFilesTemp = Directory.GetFiles(rawName).ToList(); var rawFiles = rawFilesTemp.Where(rawFile => Path.GetExtension(rawFile) == ".raw").ToList(); Assert.True(rawFiles.Count == txtFiles.Count); var offsetFrequencyTables = new List <PrecursorOffsetFrequencyTable> [_precursorCharge]; for (int i = 0; i < _precursorCharge; i++) { offsetFrequencyTables[i] = new List <PrecursorOffsetFrequencyTable>(); for (int j = 1; j <= (i + 1); j++) { offsetFrequencyTables[i].Add(new PrecursorOffsetFrequencyTable(_searchWidth / j, j, _binWidth / j)); } } for (int i = 0; i < txtFiles.Count; i++) { string textFile = txtFiles[i]; string rawFile = rawFiles[i]; Console.WriteLine("{0}\t{1}", Path.GetFileName(textFile), Path.GetFileName(rawFile)); var lcms = new LazyLcMsRun(rawFile, _noiseFiltration, _noiseFiltration); var matchList = new SpectrumMatchList(lcms, txtFiles[i], DataFileFormat.IcBottomUp); for (int j = 0; j < _precursorCharge; j++) { var chargeMatches = matchList.GetCharge(j + 1); foreach (var offsetFrequencyTable in offsetFrequencyTables[j]) { offsetFrequencyTable.AddMatches(chargeMatches); } } } var outFileName = _outFileName.Replace("@", name); for (int i = 0; i < _precursorCharge; i++) { var chargeOutFileName = outFileName.Replace("*", (i + 1).ToString(CultureInfo.InvariantCulture)); using (var outFile = new StreamWriter(chargeOutFileName)) { outFile.Write("Offset\t"); var offsetFrequencyList = new List <List <Probability <double> > >(); for (int j = offsetFrequencyTables[i].Count - 1; j >= 0; j--) { offsetFrequencyList.Add(offsetFrequencyTables[i][j].GetProbabilities().ToList()); outFile.Write("{0}", (j + 1)); if (j != 0) { outFile.Write("\t"); } } outFile.WriteLine(); for (int j = 0; j < offsetFrequencyList.First().Count; j++) { var offset = offsetFrequencyList.First()[j].Label; var integerOffset = Math.Round(offset * (1 / _binWidth), 2); outFile.Write(integerOffset + "\t"); for (int k = 0; k < offsetFrequencyList.Count; k++) { outFile.Write(offsetFrequencyList[k][j].Prob); if (k != offsetFrequencyList.Count - 1) { outFile.Write("\t"); } } outFile.WriteLine(); } } } } }
public void IonFrequencyFunction() { var methodName = MethodBase.GetCurrentMethod().Name; TestUtils.ShowStarting(methodName); const string configFilePath = @"C:\Users\wilk011\Documents\DataFiles\IonFreqConfig.ini"; if (!File.Exists(configFilePath)) { Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, configFilePath); } InitTest(new ConfigFileReader(configFilePath)); foreach (var name in _names) { var tsvName = _preTsv.Replace("@", name); var rawName = _preRaw.Replace("@", name); var txtFiles = Directory.GetFiles(tsvName).ToList(); var rawFilesTemp = Directory.GetFiles(rawName).ToList(); var rawFiles = rawFilesTemp.Where(rawFile => Path.GetExtension(rawFile) == ".raw").ToList(); Assert.True(rawFiles.Count == txtFiles.Count); int tableCount = 1; if (_precursorCharge > 0) tableCount = _precursorCharge; var ionFrequencyFunctions = new IonFrequencyTable[tableCount]; var decoyionFrequencyFunctions = new IonFrequencyTable[tableCount]; for (int i = 0; i < tableCount; i++) { ionFrequencyFunctions[i] = new IonFrequencyTable(_ionTypes, _defaultTolerance, _relativeIntensityThreshold, _combineCharges); decoyionFrequencyFunctions[i] = new IonFrequencyTable(_ionTypes, _defaultTolerance, _relativeIntensityThreshold, _combineCharges); } for (int i = 0; i < txtFiles.Count; i++) { string textFile = txtFiles[i]; string rawFile = rawFiles[i]; Console.WriteLine("{0}\t{1}", Path.GetFileName(textFile), Path.GetFileName(rawFile)); var lcms = new LazyLcMsRun(rawFile, NoiseFiltration, NoiseFiltration); var matchList = new SpectrumMatchList(lcms, txtFiles[i], DataFileFormat.IcBottomUp); SpectrumMatchList decoyMatchList = null; if (_useDecoy) decoyMatchList = new SpectrumMatchList(lcms, txtFiles[i], DataFileFormat.IcBottomUp, 0, true); for (int j = 0; j < tableCount; j++) { var matches = _precursorCharge > 0 ? matchList.GetCharge(j + 1) : matchList; matches.FilterSpectra(); ionFrequencyFunctions[j].AddMatches(matches); if (decoyMatchList != null) { var decoyMatches = _precursorCharge > 0 ? decoyMatchList.GetCharge(j + 1) : decoyMatchList; decoyMatches.FilterSpectra(); decoyionFrequencyFunctions[j].AddMatches(decoyMatches); } } } // Print Offset Frequency tables to output file var outFile = _outFileName.Replace("@", name); for (int i = 0; i < tableCount; i++) { string outFileName = outFile.Replace("*", (i + 1).ToString(CultureInfo.InvariantCulture)); var ionFrequencies = ionFrequencyFunctions[i].GetProbabilities(); var decoyionFrequencies = decoyionFrequencyFunctions[i].GetProbabilities(); using (var finalOutputFile = new StreamWriter(outFileName)) { finalOutputFile.Write("Ion\tTarget"); if (_useDecoy) finalOutputFile.Write("\tDecoy"); finalOutputFile.WriteLine(); for (int j=0;j<ionFrequencies.Length;j++) { finalOutputFile.Write("{0}\t{1}", ionFrequencies[j].Label.Name, ionFrequencies[j].Prob); if (_useDecoy) { finalOutputFile.Write("\t{0}", decoyionFrequencies[j]); } finalOutputFile.WriteLine(); } } } } }