public MassTagMatchedViewModel(ClusterToMassTagMap match) { m_match = match; m_tag = match.MassTag; MatchedProteins = new ObservableCollection <ProteinViewModel>(); LoadProteinData(m_tag); }
public MassTagToClusterMatch(MassTagToCluster match, MassTagToClusterMatch parent) { m_match = match; m_parent = parent; Name = "Peptide: " + match.MassTag.PeptideSequence; AddString("Sequence", match.MassTag.PeptideSequence); AddStatistic("Proteins", match.MatchingProteins.Count); }
/// <summary> /// Reconstructs the mass tags and clusters joining tabled data. /// </summary> /// <param name="clusters"></param> /// <param name="matches"></param> /// <param name="database"></param> /// <returns></returns> public static Tuple <List <UMCClusterLightMatched>, List <MassTagToCluster> > MapMassTagsToClusters( this List <UMCClusterLight> clusters, List <ClusterToMassTagMap> matches, MassTagDatabase database) { var matchedClusters = new List <UMCClusterLightMatched>(); var matchedTags = new List <MassTagToCluster>(); // Maps a cluster ID to a cluster that was matched (or not in which case it will have zero matches). var clusterMap = new Dictionary <int, UMCClusterLightMatched>(); // Maps the mass tags to clusters, the second dictionary is for the conformations. var massTagMap = new Dictionary <int, Dictionary <int, MassTagToCluster> >(); // Index the clusters. foreach (var cluster in clusters) { if (!clusterMap.ContainsKey(cluster.Id)) { var matchedCluster = new UMCClusterLightMatched(); matchedCluster.Cluster = cluster; clusterMap.Add(cluster.Id, matchedCluster); } } if (database != null) { // Index the mass tags. foreach (var tag in database.MassTags) { if (!massTagMap.ContainsKey(tag.Id)) { massTagMap.Add(tag.Id, new Dictionary <int, MassTagToCluster>()); } if (!massTagMap[tag.Id].ContainsKey(tag.ConformationId)) { var matchedTag = new MassTagToCluster(); matchedTag.MassTag = tag; massTagMap[tag.Id].Add(tag.ConformationId, matchedTag); } } // Keeps track of all the proteins that we have mapped so far. var proteinList = new Dictionary <int, ProteinToMassTags>(); // Link up the protein data foreach (var massTagId in massTagMap.Keys) { foreach (var conformationID in massTagMap[massTagId].Keys) { var clusterTag = massTagMap[massTagId][conformationID]; // Here we make sure we link up the protein data too if (database.Proteins.ContainsKey(massTagId)) { // Get a list of the proteins this tag mapped to. var proteins = database.Proteins[massTagId]; // Then for each protein, wrap it with a proteintomasstag map, then // mapping the tag to the protein // and mapping the protein to the tags. foreach (var p in proteins) { if (!proteinList.ContainsKey(p.ProteinId)) { var tempProtein = new ProteinToMassTags(); tempProtein.Protein = p; proteinList.Add(p.ProteinId, tempProtein); } var protein = proteinList[p.ProteinId]; // Double link the data so we can go back and forth protein.MassTags.Add(clusterTag); clusterTag.MatchingProteins.Add(protein); } } } } } // Index and align matches foreach (var match in matches) { // Find the cluster map if (clusterMap.ContainsKey(match.ClusterId)) { var cluster = clusterMap[match.ClusterId]; cluster.ClusterMatches.Add(match); MassTagToCluster tag = null; if (massTagMap.ContainsKey(match.MassTagId)) { tag = massTagMap[match.MassTagId][match.ConformerId]; tag.Matches.Add(cluster); match.MassTag = tag; } } } foreach (var clusterId in clusterMap.Keys) { matchedClusters.Add(clusterMap[clusterId]); } foreach (var tagId in massTagMap.Keys) { foreach (var conformerId in massTagMap[tagId].Keys) { matchedTags.Add(massTagMap[tagId][conformerId]); } } var tuple = new Tuple <List <UMCClusterLightMatched>, List <MassTagToCluster> >(matchedClusters, matchedTags); return(tuple); }
private void LoadProteinData(MassTagToCluster tag) { MatchedProteins.Clear(); tag.MatchingProteins.ForEach(x => MatchedProteins.Add(new ProteinViewModel(x.Protein))); }
public MassTagToClusterMatch(MassTagToCluster match) : this(match, null) { }