本文整理汇总了C#中System.Collections.Set.Subtract方法的典型用法代码示例。如果您正苦于以下问题:C# Set.Subtract方法的具体用法?C# Set.Subtract怎么用?C# Set.Subtract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Collections.Set
的用法示例。
在下文中一共展示了Set.Subtract方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: assembleMinimumCoveringSet
public void assembleMinimumCoveringSet(ClusterInfo c)
{
if (c.proteinGroups.Count == 1) // degenerate case
{
foreach (ProteinGroupInfo proGroup in c.proteinGroups)
proGroup.uniquePeptideCount = int.MaxValue; // value is n/a
return;
}
/*Set<ResultInfo> clusterResults = new Set<ResultInfo>( c.results );
ProteinGroupList clusterGroups = new ProteinGroupList();
foreach( ProteinGroupInfo proGroup in c.proteinGroups )
clusterGroups.Add( proGroup );
//Console.WriteLine();
while( clusterResults.Count > 0 )
{
List<ProteinGroupInfo> minRemainingResults = new List<ProteinGroupInfo>();
int minRemainingResultCount = clusterResults.Count;
//int n = 0;
//Console.WriteLine( "groups: " + clusterGroups.Count + "; results: " + clusterResults.Count );
foreach( ProteinGroupInfo proGroup in clusterGroups )
{
//Console.Write( n++ + " of " + clusterGroups.Count + "\r" );
int count = clusterResults.Count;
foreach( ResultInfo r in proGroup.results )
if( clusterResults.Contains( r ) )
--count;
if( count <= minRemainingResultCount )
{
if( count < minRemainingResultCount )
minRemainingResults.Clear();
minRemainingResults.Add( proGroup );
}
}
ProteinGroupInfo mostGreedyGroup = minRemainingResults[0];
minRemainingResults.Clear();
int oldCount = clusterResults.Count;
clusterResults.Subtract( mostGreedyGroup.results );
if( clusterResults.Count >= oldCount )
{
Console.Error.WriteLine( "Something has gone terribly wrong!" );
System.Diagnostics.Process.GetCurrentProcess().Kill();
}
mostGreedyGroup.minSet = true;
clusterGroups.Remove( mostGreedyGroup );
}*/
// Get the results in the cluster
Set<ResultInfo> clusterResults = new Set<ResultInfo>(c.results);
// Get the protein groups in the cluster
ProteinGroupList clusterGroups = new ProteinGroupList();
foreach (ProteinGroupInfo proGroup in c.proteinGroups)
clusterGroups.Add(proGroup);
//Console.WriteLine();
// while there are results in the cluster
while (clusterResults.Count > 0)
{
// Maps the number of results to a protein group
Map<int, List<ProteinGroupInfo>> remainingResults = new Map<int, List<ProteinGroupInfo>>();
//int n = 0;
//Console.WriteLine( "groups: " + clusterGroups.Count + "; results: " + clusterResults.Count );
// Iterate through protein groups
foreach (ProteinGroupInfo proGroup in clusterGroups)
{
//Console.Write( n++ + " of " + clusterGroups.Count + "\n" );
// Get the number of results in the cluster
int count = clusterResults.Count;
// Iterate over the cluster results and see how
// many cluster group results can be explained
// by that protein group
foreach (ResultInfo r in proGroup.results)
{
if (clusterResults.Contains(r))
--count;
}
// Map the number of remaining results to that
// protein group
remainingResults[count].Add(proGroup);
}
// Take the first protein group that can explain the most results
ProteinGroupInfo mostGreedyGroup = remainingResults.Values[0][0];
// Subtract its results from the cluster results
mostGreedyGroup.uniquePeptideCount = clusterResults.Count - remainingResults.Keys[0];
clusterResults.Subtract(mostGreedyGroup.results);
// Remove the most greedy group from the cluster groups
clusterGroups.Remove(mostGreedyGroup);
}
}