Ejemplo n.º 1
0
        /// <summary>
        /// This function exports a detailed protein modification report.
        /// </summary>
        public void exportProteinReport(Set <string> loci, StreamWriter writer)
        {
            if (loci.Count == 0)
            {
                return;
            }
            Map <string, Map <string, int> > table = new Map <string, Map <string, int> >();
            Set <string> allSources = new Set <string>();

            foreach (var locus in loci)
            {
                foreach (var peptide in proteins[locus].peptides)
                {
                    foreach (var interp in proteins[locus].interpretations[peptide])
                    {
                        foreach (var variant in proteins[locus].variants[interp])
                        {
                            string key = locus + "," + interp;
                            foreach (var spectrum in proteins[locus].spectra[variant])
                            {
                                string sourceName = spectrum.id.source.group.name;
                                allSources.Add(sourceName);
                                ++table[key][sourceName];
                                SourceGroupList parentGroups = new SourceGroupList();
                                foreach (var parent in spectrum.id.source.group.getAllParentGroupPaths())
                                {
                                    allSources.Add(parent);
                                    ++table[key][parent];
                                }
                            }
                        }
                    }
                }
            }
            writer.Write("Protein,peptide");
            foreach (var source in allSources)
            {
                writer.Write("," + source);
            }
            writer.WriteLine();
            foreach (var keys in table)
            {
                StringBuilder line = new StringBuilder();
                line.Append(keys.Key);
                foreach (var source in allSources)
                {
                    line.Append("," + table[keys.Key][source]);
                }
                writer.WriteLine(line.ToString());
            }
            writer.Flush();
        }
Ejemplo n.º 2
0
        public void exportPeptideReport(Set <string> loci, StreamWriter writer)
        {
            if (loci.Count == 0)
            {
                return;
            }
            // Interpretation to variant map
            Map <string, Set <VariantInfo> > uniqueVariants = new Map <string, Set <VariantInfo> >();
            // Interpretation to protein ID map
            Map <string, Set <ProteinInstanceInfo> > varToProteinMap = new Map <string, Set <ProteinInstanceInfo> >();
            // Variant to spectrum map
            Map <VariantInfo, Set <SpectrumInfo> > varToSpecMap = new Map <VariantInfo, Set <SpectrumInfo> >();

            foreach (var locus in loci)
            {
                foreach (var peptide in proteins[locus].peptides)
                {
                    foreach (var interp in proteins[locus].interpretations[peptide])
                    {
                        foreach (var variant in proteins[locus].variants[interp])
                        {
                            uniqueVariants[variant.ToInsPecTStyle()].Add(variant);
                            foreach (var spectrum in proteins[locus].spectra[variant])
                            {
                                varToSpecMap[variant].Add(spectrum);
                            }
                            foreach (var protein in variant.peptide.proteins.Values)
                            {
                                varToProteinMap[interp].Add(protein);
                            }
                        }
                    }
                }
            }

            Map <string, Map <string, int> > table = new Map <string, Map <string, int> >();
            Set <string> allSources = new Set <string>();

            foreach (var interp in uniqueVariants.Keys)
            {
                foreach (var variant in uniqueVariants[interp])
                {
                    foreach (var spectrum in varToSpecMap[variant])
                    {
                        string sourceName = spectrum.id.source.group.name;
                        allSources.Add(sourceName);
                        ++table[interp][sourceName];
                        SourceGroupList parentGroups = new SourceGroupList();
                        foreach (var parent in spectrum.id.source.group.getAllParentGroupPaths())
                        {
                            allSources.Add(parent);
                            ++table[interp][parent];
                        }
                    }
                }
            }

            writer.Write("Peptide,Protein,Alternatives");
            foreach (var source in allSources)
            {
                writer.Write("," + source);
            }
            writer.WriteLine();
            foreach (var keys in table)
            {
                StringBuilder line = new StringBuilder();
                line.Append(keys.Key);
                Set <ProteinInstanceInfo> .Enumerator proIter = varToProteinMap[keys.Key].GetEnumerator();
                proIter.MoveNext();
                ProteinInstanceInfo first = proIter.Current;
                line.Append("," + first.protein.locus);
                StringBuilder alts = new StringBuilder();
                while (proIter.MoveNext())
                {
                    alts.Append(proIter.Current.protein.locus + ";");
                }
                line.Append("," + alts.ToString());
                foreach (var source in allSources)
                {
                    line.Append("," + table[keys.Key][source]);
                }
                writer.WriteLine(line.ToString());
            }
            writer.Flush();
        }
Ejemplo n.º 3
0
        public void exportPeptideReport(Set<string> loci, StreamWriter writer)
        {
            if(loci.Count == 0)
                return;
            // Interpretation to variant map
            Map<string,Set<VariantInfo>> uniqueVariants = new Map<string,Set<VariantInfo>>();
            // Interpretation to protein ID map
            Map<string,Set<ProteinInstanceInfo>> varToProteinMap = new Map<string,Set<ProteinInstanceInfo>>();
            // Variant to spectrum map
            Map<VariantInfo, Set<SpectrumInfo>> varToSpecMap = new Map<VariantInfo,Set<SpectrumInfo>>();
            foreach(var locus in loci)
                foreach (var peptide in proteins[locus].peptides)
                    foreach (var interp in proteins[locus].interpretations[peptide])
                        foreach (var variant in proteins[locus].variants[interp])
                        {
                            uniqueVariants[variant.ToInsPecTStyle()].Add(variant);
                            foreach (var spectrum in proteins[locus].spectra[variant])
                                varToSpecMap[variant].Add(spectrum);
                            foreach (var protein in variant.peptide.proteins.Values)
                                varToProteinMap[interp].Add(protein);
                        }

            Map<string, Map<string, int>> table = new Map<string, Map<string, int>>();
            Set<string> allSources = new Set<string>();
            foreach(var interp in uniqueVariants.Keys) 
                foreach(var variant in uniqueVariants[interp]) 
                    foreach(var spectrum in varToSpecMap[variant])
                    {
                        string sourceName = spectrum.id.source.group.name;
                        allSources.Add(sourceName);
                        ++table[interp][sourceName];
                        SourceGroupList parentGroups = new SourceGroupList();
                        foreach (var parent in spectrum.id.source.group.getAllParentGroupPaths())
                        {
                            allSources.Add(parent);
                            ++table[interp][parent];
                        }
                    }

            writer.Write("Peptide,Protein,Alternatives");
            foreach (var source in allSources)
                writer.Write("," + source);
            writer.WriteLine();
            foreach ( var keys in table)
            {
                StringBuilder line = new StringBuilder();
                line.Append(keys.Key);
                Set<ProteinInstanceInfo>.Enumerator proIter = varToProteinMap[keys.Key].GetEnumerator();
                proIter.MoveNext();
                ProteinInstanceInfo first = proIter.Current;
                line.Append(","+first.protein.locus);
                StringBuilder alts = new StringBuilder();
                while(proIter.MoveNext())
                    alts.Append(proIter.Current.protein.locus+";");
                line.Append(","+alts.ToString());
                foreach (var source in allSources)
                {
                    line.Append("," + table[keys.Key][source]);
                }
                writer.WriteLine(line.ToString());
            }
            writer.Flush();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// This function exports a detailed protein modification report.
        /// </summary>
        public void exportProteinReport(Set<string> loci, StreamWriter writer)
        {
            
            if(loci.Count == 0)
                return;
            Map<string, Map<string, int>> table = new Map<string, Map<string, int>>();
            Set<string> allSources = new Set<string>();
            foreach (var locus in loci)
                foreach (var peptide in proteins[locus].peptides)
                    foreach (var interp in proteins[locus].interpretations[peptide])
                        foreach (var variant in proteins[locus].variants[interp])
                        {
                            string key = locus + "," + interp;
                            foreach (var spectrum in proteins[locus].spectra[variant])
                            {
                                string sourceName = spectrum.id.source.group.name;
                                allSources.Add(sourceName);
                                ++table[key][sourceName];
                                SourceGroupList parentGroups = new SourceGroupList();
                                foreach (var parent in spectrum.id.source.group.getAllParentGroupPaths())
                                {
                                    allSources.Add(parent);
                                    ++table[key][parent];
                                }

                            }
                        }
            writer.Write("Protein,peptide");
            foreach(var source in allSources)
                writer.Write(","+source);
            writer.WriteLine();
            foreach(var keys in table) 
            {
                StringBuilder line = new StringBuilder();
                line.Append(keys.Key);
                foreach(var source in allSources)
                {
                    line.Append("," + table[keys.Key][source]);
                }
                writer.WriteLine(line.ToString());
            }
            writer.Flush();
        }