public void InitializeByResult(IIdentifiedResult identifiedResult) { string oldProteinHeader = ProteinFormat == null?GetDefaultProteinHeader() : ProteinFormat.GetHeader(); InitializeProteinFormat(identifiedResult, oldProteinHeader); string oldPeptideHeader = PeptideFormat == null?GetDefaultPeptideHeader() : PeptideFormat.GetHeader(); InitializePeptideFormat(identifiedResult, oldPeptideHeader); }
public override void WriteToFile(string fileName, IIdentifiedResult identifiedResult) { CheckFormat(identifiedResult); List <IIdentifiedSpectrum> allSpectra = identifiedResult.GetSpectra(); for (int i = 0; i < allSpectra.Count; i++) { allSpectra[i].Id = i.ToString(); } string linkFilename = GetLinkFileName(fileName); HashSet <IIdentifiedSpectrum> spectra = new HashSet <IIdentifiedSpectrum>(); using (var linkWriter = new StreamWriter(linkFilename)) { linkWriter.WriteLine("PeptideId\tGroupId"); using (var sw = new StreamWriter(fileName)) { sw.WriteLine(ProteinFormat.GetHeader()); var groups = GetValidGroups(identifiedResult); foreach (IIdentifiedProteinGroup mpg in groups) { GroupWriter.WriteToStream(sw, mpg); var validSpectra = GetValidSpectra(mpg.GetSortedPeptides()); foreach (var spectrum in validSpectra) { linkWriter.WriteLine(spectrum.Id + "\t" + mpg.Index); } spectra.UnionWith(validSpectra); } } } var finalSpectra = from s in spectra orderby s.Id select s; string peptideFile = GetPeptideFileName(fileName); if (!PeptideFormat.GetHeader().Contains("Id\t")) { PeptideFormat = new PeptideLineFormat("Id\t" + PeptideFormat.GetHeader()); } using (var sw = new StreamWriter(peptideFile)) { WritePeptideHeader(sw); foreach (IIdentifiedSpectrum mph in finalSpectra) { WritePeptide(sw, mph); } } if (identifiedResult.Count > 0 && identifiedResult[0][0].Sequence != null) { string fastaFilename = fileName + ".fasta"; WriteFastaFile(fastaFilename, identifiedResult); } }