public override IEnumerable <string> Process(string filename) { CensusResultFormat crFormat = new CensusResultFormat(false); CensusResult cr = crFormat.ReadFromFile(filename); cr.Recalculate(); CensusResult result = new CensusResult(); result.Headers.AddRange(cr.Headers); foreach (CensusProteinItem cpi in cr.Proteins) { if (cpi.PeptideNumber >= uniqueCount) { result.Proteins.Add(cpi); } } string resultFilename = FileUtils.ChangeExtension(filename, "." + uniqueCount + new FileInfo(filename).Extension); crFormat.WriteToFile(resultFilename, result); return(new[] { resultFilename }); }
public void Test() { CensusResult cr; cr = new CensusResultFormat(true).ReadFromFile(TestContext.CurrentContext.TestDirectory + "/../../../data/census-g1-out.txt"); Assert.AreEqual(3, cr.Proteins.Count); Assert.AreEqual(271, cr.Proteins[0].Peptides.Count); cr = new CensusResultFormat(false).ReadFromFile(TestContext.CurrentContext.TestDirectory + "/../../../data/census-g1-out.txt"); Assert.AreEqual(2, cr.Proteins.Count); }
public void Test() { CensusResult cr; cr = new CensusResultFormat(true).ReadFromFile(@"../../../data/census-g1-out.txt"); Assert.AreEqual(3, cr.Proteins.Count); Assert.AreEqual(271, cr.Proteins[0].Peptides.Count); cr = new CensusResultFormat(false).ReadFromFile(@"../../../data/census-g1-out.txt"); Assert.AreEqual(2, cr.Proteins.Count); }
public override IEnumerable <string> Process(string targetFilename) { Dictionary <string, List <CensusPeptideItem> > peptideMap = new Dictionary <string, List <CensusPeptideItem> >(); CensusResultFormat crf = new CensusResultFormat(true, isLabelFree); Progress.SetRange(1, sourceFilenames.Length + 1); for (int i = 0; i < sourceFilenames.Length; i++) { string f = sourceFilenames[i]; Progress.SetMessage("Reading from " + f + "..."); Progress.SetPosition(i + 1); List <CensusPeptideItem> peptides = crf.ReadPeptides(f); foreach (CensusPeptideItem cpi in peptides) { if (!peptideMap.ContainsKey(cpi.Sequence)) { peptideMap[cpi.Sequence] = new List <CensusPeptideItem>(); } peptideMap[cpi.Sequence].Add(cpi); } } List <string> sequences = new List <string>(peptideMap.Keys); sequences.Sort(delegate(string seq1, string seq2) { int result = peptideMap[seq2].Count - peptideMap[seq1].Count; if (0 == result) { result = seq1.CompareTo(seq2); } return(result); }); Progress.SetMessage("Writing to " + targetFilename + "..."); using (var sw = new StreamWriter(targetFilename)) { sw.WriteLine("PLINE\tSEQUENCE\tS_INT/R_INT\tINT(S)\tINT(R)"); sw.WriteLine(crf.PeptideFormat.GetHeader()); foreach (string seq in sequences) { List <CensusPeptideItem> items = peptideMap[seq]; double sInt = 0.0; double rInt = 0.0; foreach (CensusPeptideItem item in items) { sInt += item.SampleIntensity; rInt += item.ReferenceIntensity; } double ratio; if (rInt != 0.0) { ratio = sInt / rInt; } else { ratio = 0.0; } sw.WriteLine(MyConvert.Format("P\t{0}\t{1:0.00}\t{2:0.0}\t{3:0.0}", seq, ratio, sInt, rInt)); foreach (CensusPeptideItem item in items) { sw.WriteLine(crf.PeptideFormat.GetString(item)); } } } Progress.SetMessage("Write to " + targetFilename + " finished."); Progress.SetPosition(sourceFilenames.Length + 1); return(new[] { targetFilename }); }
public override IEnumerable <string> Process(string targetFilename) { Dictionary <string, CensusProteinItem> proteinMap = new Dictionary <string, CensusProteinItem>(); CensusResultFormat crf = new CensusResultFormat(true, isLabelFree); Progress.SetRange(1, sourceFilenames.Length + 1); for (int i = 0; i < sourceFilenames.Length; i++) { string f = sourceFilenames[i]; Progress.SetMessage("Reading from " + f + "..."); Progress.SetPosition(i + 1); CensusResult cr = crf.ReadFromFile(f); foreach (CensusProteinItem cpi in cr.Proteins) { if (!proteinMap.ContainsKey(cpi.Locus)) { proteinMap[cpi.Locus] = cpi; } else { proteinMap[cpi.Locus].Peptides.AddRange(cpi.Peptides); } } } List <CensusProteinItem> proteins = new List <CensusProteinItem>(proteinMap.Values); foreach (CensusProteinItem cpi in proteins) { cpi.Recalculate(); cpi.Peptides.Sort(delegate(CensusPeptideItem a, CensusPeptideItem b) { int result = a.Sequence.CompareTo(b.Sequence); if (0 == result) { result = a.Filename.Charge.CompareTo(b.Filename.Charge); } if (0 == result) { result = a.Filename.LongFileName.CompareTo(b.Filename.LongFileName); } return(result); }); } proteins.Sort(delegate(CensusProteinItem a, CensusProteinItem b) { int result = b.PeptideNumber - a.PeptideNumber; if (0 == result) { result = b.SpectraCount - a.SpectraCount; } if (0 == result) { result = a.Locus.CompareTo(b.Locus); } return(result); }); CensusResult target = new CensusResult(); target.Headers = CensusUtils.ReadHeaders(sourceFilenames[0]); target.Proteins = proteins; Progress.SetMessage("Writing to " + targetFilename + "..."); crf.WriteToFile(targetFilename, target); Progress.SetMessage("Write to " + targetFilename + " finished."); Progress.SetPosition(sourceFilenames.Length + 1); return(new[] { targetFilename }); }