public static ContentsRequest FindAssociations(object target, ContentsRequest request) { switch (request.Type) { case EVisualClass.SpecialAdvanced: case EVisualClass.SpecialMeta: case EVisualClass.SpecialAll: case EVisualClass.SpecialStatistic: IEnumerable <Column> cols = ColumnManager.GetColumns(request.Core, target).OrderBy(z => z.Special.Has(EColumn.Visible)); bool shortName; switch (request.Type) { case EVisualClass.SpecialAll: request.Text = "All data fields for {0}"; cols = cols.Where(z => !z.Special.Has(EColumn.Advanced)); shortName = false; break; case EVisualClass.SpecialStatistic: request.Text = "Statistics fields for {0}"; cols = cols.Where(z => !z.Special.Has(EColumn.Advanced) && z.Special.Has(EColumn.IsStatistic)); shortName = true; break; case EVisualClass.SpecialMeta: request.Text = "Meta-data fields for {0}"; cols = cols.Where(z => !z.Special.Has(EColumn.Advanced) && z.Special.Has(EColumn.IsMeta)); shortName = true; break; default: case EVisualClass.SpecialAdvanced: request.Text = "Internal data for {0}"; shortName = false; break; } foreach (var c in cols) { request.Add(new ColumnValuePair(c, target, ColumnManager.GetColumnColour(c), Resources.ListIconInformation, shortName)); } break; default: if (target is Associational) { ((Associational)target).OnFindAssociations(request); } break; } return(request); }
protected override void OnFindAssociations(ContentsRequest list) { switch (list.Type) { case EVisualClass.Adduct: list.Text = "Adduct for annotation {0}"; list.Add(this.Adduct); break; case EVisualClass.Annotation: ((Associational)this.Peak).FindAssociations(list); ((Associational)this.Compound).FindAssociations(list); list.Text = "Annotations with same peaks/compounds to {0}"; break; case EVisualClass.Assignment: ((Associational)this.Peak).FindAssociations(list); break; case EVisualClass.Cluster: ((Associational)this.Peak).FindAssociations(list); break; case EVisualClass.Compound: list.Text = "Compound for annotation {0}"; list.Add(this.Compound); break; case EVisualClass.Pathway: ((Associational)this.Peak).FindAssociations(list); ((Associational)this.Compound).FindAssociations(list); break; case EVisualClass.Peak: list.Text = "Peak for annotation {0}"; list.Add(this.Peak); break; } }
/// <summary> /// IMPELEMENTS IVisualisable /// </summary> protected override void OnFindAssociations(ContentsRequest request) { switch (request.Type) { case EVisualClass.Peak: request.Text = "Potential peaks for {0}"; foreach (var pp in this.Annotations) { request.Add(pp.Peak); } break; case EVisualClass.Cluster: request.Text = "Clusters representing potential peaks of {0}"; request.AddExtraColumn("Num. in compound", "Number of peaks in {0} in this cluster"); Counter <Cluster> counts = new Counter <Cluster>(); foreach (Annotation p in this.Annotations) { foreach (Cluster pat in p.Peak.FindAssignments(request.Core).Select(z => z.Cluster)) { counts.Increment(pat); // assume there is only one of each cluster per peak so the count holds } } request.AddRangeWithCounts(counts); break; case EVisualClass.Annotation: request.Text = "Annotations using {0}"; request.AddRange(this.Annotations); break; case EVisualClass.Compound: break; case EVisualClass.Adduct: break; case EVisualClass.Pathway: request.Text = "List of pathways implicating {0}"; request.AddRange(this.Pathways); break; default: break; } }
protected override void OnFindAssociations(ContentsRequest request) { switch (request.Type) { case EVisualClass.Peak: request.Add(this.Peak); request.Text = "Peak for {0}"; break; case EVisualClass.Cluster: request.Add(this.Cluster); request.Text = "Clusters for {0}"; break; case EVisualClass.Assignment: case EVisualClass.Compound: case EVisualClass.Adduct: case EVisualClass.Pathway: case EVisualClass.Annotation: default: break; } }
/// <summary> /// IMPLEMENTS IVisualisable /// </summary> protected override void OnFindAssociations(ContentsRequest request) { switch (request.Type) { case EVisualClass.Peak: request.Text = "Peaks with similar m/z to {0} (" + Maths.SignificantDigits((double)this.Mz, 5) + ")"; request.AddRange(this.SimilarPeaks); break; case EVisualClass.Cluster: request.Text = "Assigned clusters for {0}"; Assignment.AddHeaders(request); foreach (var ass in this.FindAssignments(request.Core)) { request.Add(ass.Cluster, ass.GetHeaders()); } break; case EVisualClass.Assignment: request.Text = "Assignments for {0}"; request.AddRange(this.FindAssignments(request.Core)); break; case EVisualClass.Compound: request.Text = "Potential compounds of {0}"; foreach (var annotation in this.Annotations) { request.Add(annotation.Compound); } break; case EVisualClass.Annotation: request.Text = "Annotations for {0}"; foreach (var annotation in this.Annotations) { request.Add(annotation); } break; case EVisualClass.Adduct: { request.Text = "Adducts of potential compounds for {0}"; HashSet <Adduct> counter = new HashSet <Adduct>(); foreach (var c in this.Annotations) { counter.Add(c.Adduct); } foreach (var kvp in counter) { request.Add(kvp); } } break; case EVisualClass.Pathway: { request.Text = "Pathways of potential compounds for {0}"; request.AddExtraColumn("Compounds", "Compounds in this pathway potentially represented by {0}."); Dictionary <Pathway, List <Compound> > counter = new Dictionary <Pathway, List <Compound> >(); foreach (var pc in this.Annotations) { foreach (var p in pc.Compound.Pathways) { counter.GetOrNew(p).Add(pc.Compound); } } foreach (var kvp in counter) { request.Add(kvp.Key, kvp.Value); } } break; default: break; } }
/// <summary> /// IMPLEMENTS Associational /// </summary> protected override void OnFindAssociations(ContentsRequest request) { switch (request.Type) { case EVisualClass.Peak: request.Text = "Peaks assigned to {0}"; Assignment.AddHeaders(request); foreach (Assignment assignment in this.Assignments.List) { request.Add(assignment.Peak, assignment.GetHeaders()); } break; case EVisualClass.Assignment: request.Text = "Assignments to {0}"; request.AddRange(this.Assignments.List); break; case EVisualClass.Cluster: request.Text = "Clusters with peaks also in {0}"; foreach (Cluster c in request.Core.Clusters.Where(c => c != this).Where(c => c.Assignments.Peaks.Any(this.Assignments.Peaks.Contains))) { request.Add(c); } break; case EVisualClass.Compound: { request.Text = "Potential compounds of peaks assigned to {0}"; request.AddExtraColumn("Overlapping Peaks", "Peaks potentially representing this compound also in {0}"); Dictionary <Compound, List <Peak> > counter = new Dictionary <Compound, List <Peak> >(); foreach (var peak in this.Assignments.Peaks) { foreach (var c in peak.Annotations) { counter.GetOrNew(c.Compound).Add(peak); } } foreach (var kvp in counter) { request.Add(kvp.Key, kvp.Value); } } break; case EVisualClass.Adduct: { request.Text = "Adducts of potential compounds of peaks assigned to {0}"; request.AddExtraColumn("Overlapping Compounds", "Compounds potentially representing {0} with this adduct"); Dictionary <Adduct, List <Compound> > counter = new Dictionary <Adduct, List <Compound> >(); foreach (Annotation c in this.Assignments.Peaks.SelectMany(p => p.Annotations)) { counter.GetOrNew(c.Adduct).Add(c.Compound); } foreach (var kvp in counter) { request.Add(kvp.Key, kvp.Value); } } break; case EVisualClass.Pathway: { request.Text = "Pathways of potential compounds of peaks assigned to {0}"; request.AddExtraColumn("Overlapping Compounds", "Compounds in this pathway with peaks in {0}"); request.AddExtraColumn("Overlapping Peaks", "Peaks potentially representing compounds in this pathway in {0}"); Dictionary <Pathway, HashSet <Compound> > compounds = new Dictionary <Pathway, HashSet <Compound> >(); Dictionary <Pathway, HashSet <Peak> > peaks = new Dictionary <Pathway, HashSet <Peak> >(); foreach (Peak peak in this.Assignments.Peaks) // peaks in cluster { foreach (Annotation annotation in peak.Annotations) // compounds in peak { foreach (Pathway pathway in annotation.Compound.Pathways) // pathways in compound { compounds.GetOrNew(pathway).Add(annotation.Compound); // pathway += compound peaks.GetOrNew(pathway).Add(peak); // pathway += peak } } } foreach (var kvp in compounds) { // Pathway, compound, peaks request.Add(kvp.Key, kvp.Value.ToArray(), peaks[kvp.Key].ToArray()); } } break; case EVisualClass.Annotation: request.Text = "Annotations for peaks in {0}"; request.AddRange(this.Assignments.Peaks.SelectMany(z => z.Annotations)); break; default: break; } }
/// <summary> /// IMPLEMENTS IVisualisable. /// </summary> protected override void OnFindAssociations(ContentsRequest list) { switch (list.Type) { case EVisualClass.Peak: list.Text = "Peaks marked with {0}"; list.AddRange(list.Core.Peaks.Where(z => z.UserFlags.Contains(this))); break; case EVisualClass.Cluster: list.Text = "Clusters containing peaks marked with {0}"; list.AddExtraColumn("Flag count", "Number of peaks in this cluster with the comment flag " + this.ToString()); foreach (Cluster c in list.Core.Clusters) { if (c.CommentFlags.ContainsKey(this)) { list.Add(c, c.CommentFlags[this]); } } break; case EVisualClass.Pathway: list.Text = "Pathways containing compounds annotated with peaks marked with {0}"; foreach (Pathway c in list.Core.Pathways) { if (c.Compounds.Any(z => z.Annotations.Any(zz => zz.Peak.UserFlags.Contains(this)))) { list.Add(c); } } break; case EVisualClass.Annotation: list.Text = "Annotations for peaks peaks marked with {0}"; foreach (Annotation c in list.Core.Annotations) { if (c.Peak.UserFlags.Contains(this)) { list.Add(c); } } break; case EVisualClass.Assignment: list.Text = "Assignments for peaks peaks marked with {0}"; foreach (Assignment c in list.Core.Assignments) { if (c.Peak.UserFlags.Contains(this)) { list.Add(c); } } break; case EVisualClass.Compound: list.Text = "Compounds with annotations for peaks peaks marked with {0}"; foreach (Compound c in list.Core.Compounds) { if (c.Annotations.Any(z => z.Peak.UserFlags.Contains(this))) { list.Add(c); } } break; } }
/// <summary> /// IMPLEMENTS IVisualisable /// </summary> protected override void OnFindAssociations(ContentsRequest request) { switch (request.Type) { case EVisualClass.Peak: { request.Text = "Potential peaks of compounds in {0}"; request.AddExtraColumn("Compounds", "Compounds potentially representing this peak in {0}."); Dictionary <Peak, List <Compound> > dict = new Dictionary <Peak, List <Compound> >(); foreach (Compound c in this.Compounds) { foreach (Annotation p in c.Annotations) { dict.GetOrNew(p.Peak).Add(c); } } foreach (var kvp in dict) { request.Add(kvp.Key, kvp.Value); } } break; case EVisualClass.Annotation: request.Text = "Annotations with compounds in {0}"; foreach (Compound c in this.Compounds) { request.AddRange(c.Annotations); } break; case EVisualClass.Cluster: { request.Text = "Clusters representing potential peaks of compounds in {0}"; request.AddExtraColumn("Overlapping Peaks", "Number of peaks in this cluster in with compounds in {0}"); request.AddExtraColumn("Overlapping Compounds", "Number of compounds with peaks in this cluster with peaks also in {0}"); foreach (Cluster cluster in request.Core.Clusters) { var peaks = new HashSet <Peak>(); var comps = new HashSet <Compound>(); foreach (Peak peak in cluster.Assignments.Peaks) { foreach (Annotation comp in peak.Annotations) { comps.Add(comp.Compound); if (comp.Compound.Pathways.Contains(this)) { peaks.Add(peak); } } } if (peaks.Count != 0) { request.Add(cluster, peaks.ToArray(), comps.ToArray()); } } } break; case EVisualClass.Compound: { request.Text = "Compounds in {0}"; request.AddExtraColumn("Clusters", "Clusters"); // TODO: This is actually generic to all compounds and not related to this Pathway class foreach (Compound c in this.Compounds) { HashSet <Cluster> pats = new HashSet <Cluster>(); foreach (Annotation p in c.Annotations) { foreach (Cluster pat in p.Peak.FindAssignments(request.Core).Select(z => z.Cluster)) { pats.Add(pat); } } request.Add(c, (object)pats.ToArray()); } } break; case EVisualClass.Adduct: break; case EVisualClass.Pathway: { request.Text = "Pathways related to {0}"; request.AddRange(this.RelatedPathways); } break; default: break; } }