public void TestWriteToDta() { PeakList <Peak> spectrum = new DtaFormat <Peak>().ReadFromFile(this.testDtaFile); var fi = new FileInfo(this.testDtaFile); string tmpFile = fi.DirectoryName + "\\a.1.1." + spectrum.PrecursorCharge + ".dta"; try { this.dtaFormat.WriteToFile(tmpFile, spectrum); PeakList <Peak> tmpSpectrum = this.dtaFormat.ReadFromFile(tmpFile); Assert.AreEqual(spectrum.PrecursorMZ, tmpSpectrum.PrecursorMZ, 0.001); Assert.AreEqual(spectrum.PrecursorCharge, tmpSpectrum.PrecursorCharge); Assert.AreEqual(spectrum.Count, tmpSpectrum.Count); } finally { new FileInfo(tmpFile).Delete(); } }
public override void WriteToFile(string targetDirectory, List <PeakList <T> > peakLists) { var dtaFormat = new DtaFormat <T>(); var di = new DirectoryInfo(targetDirectory); if (!di.Exists) { di.Create(); } Progress.SetRange(0, peakLists.Count); foreach (var pkl in peakLists) { Progress.Increment(1); if (Progress.IsCancellationPending()) { throw new UserTerminatedException(); } int oldcharge = pkl.PrecursorCharge; int[] charges = null; if (0 == oldcharge) { charges = new[] { 2, 3 }; } else { charges = new[] { pkl.PrecursorCharge }; } foreach (int charge in charges) { pkl.PrecursorCharge = charge; String dtaFilename = di.FullName + "\\" + pkl.GetSequestDtaName(); dtaFormat.WriteToFile(dtaFilename, pkl); } } }