public void WriteProteins(string outputFilepath, bool addDecoys) { var pd = new ProteomeData(); var pl = new ProteinListSimple(); var queryRows = session.CreateQuery("SELECT DISTINCT pro.Accession, pro.IsDecoy, pro.Description, pro.Sequence " + DataFilter.GetFilteredQueryString(DataFilter.FromProtein)) .List <object[]>(); foreach (var queryRow in queryRows) { if ((bool)queryRow[1] == false) // skip decoys from the query { pl.proteins.Add(new proteome.Protein((string)queryRow[0], pl.proteins.Count, (string)queryRow[2], (string)queryRow[3])); } } if (addDecoys) { foreach (var queryRow in queryRows) { if ((bool)queryRow[1] == false) // skip decoys from the query { pl.proteins.Add(new proteome.Protein("rev_" + (string)queryRow[0], pl.proteins.Count, String.Empty, // decoys have no description new string(((string)queryRow[3]).Reverse().ToArray()))); } } } pd.proteinList = pl; ProteomeDataFile.write(pd, outputFilepath); }
//read a fasta database //remove the reverse sequences //write forward sequences into a proteinList public static List<string> readDatabase(string database) { List<string> proteinList = new List<string>(); ProteomeDataFile foo = new ProteomeDataFile(database); ProteinList p1 = foo.proteinList; for (int i = 0; i < p1.size(); i++) { Protein pro = p1.protein(i, true); if (!pro.id.Contains("rev")) { string sequence = p1.protein(i, true).sequence; proteinList.Add(sequence); } } return proteinList; }
static void Main(string[] args) { Peptide peptideList = new Peptide(); List<string> peptideSeqList = new List<string>(); string file = "C:\\Users\\Dong\\Desktop\\test.pep.list"; TextReader tr = new StreamReader(file); string line; while ((line = tr.ReadLine()) != null) { string peptide; if (line.Contains(".")) { string[] strs = line.Split('.'); peptide = strs[1]; } else peptide = line; peptideSeqList.Add(peptide); } //remove duplicates of the peptides //make it a unique list peptideSeqList = removeDuplicate(peptideSeqList); //generate the peptide list //by putting the peptide foreach (var pep in peptideSeqList) { //something wrong here!!! peptideList.Add(1, ""); } //Pep2Pro pp = new Pep2Pro(); string database = "C:\\Users\\Dong\\Desktop\\yates.fasta"; ProteomeDataFile foo = new ProteomeDataFile(database); pwiz.CLI.proteome.ProteinList proteinList = foo.proteinList; List<Protein> finalProteinList = new List<Protein>(); for (int i = 0; i < proteinList.size(); i++) { Protein protein = proteinList.protein(i, true); if (!protein.id.Contains("Reverse")) { string sequence = protein.sequence; //Console.WriteLine(protein.index); foreach (var pep in peptideSeqList) { if (sequence.Contains(pep) && !finalProteinList.Contains(protein)) { finalProteinList.Add(protein); } } } } //test //results: got a protein list which corresponding all peptides //the "finalProteinList" is ready for filters. //Console.WriteLine(proteinList.size()); //Console.WriteLine(finalProteinList.Count); //filter by minDistinctPeptides //filter by filterByDistinctPeptides //filterByMinimumCoveringSet //done it! }