示例#1
0
        public void SelectTargetsAndDecoys(out ScoredGroupPeaksSet targetScoredGroupPeaksSet, out ScoredGroupPeaksSet decoyScoredGroupPeaksSet)
        {
            targetScoredGroupPeaksSet = new ScoredGroupPeaksSet();
            decoyScoredGroupPeaksSet  = new ScoredGroupPeaksSet();
            foreach (var scoredGroupPeaks in _scoredGroupPeaksList)
            {
                var secondHighestPeak = scoredGroupPeaks.SecondHighestPeak;
                if (!secondHighestPeak.IsEmpty)
                {
                    var decoyScoredGroupPeaks = new ScoredGroupPeaks();
                    decoyScoredGroupPeaks.Add(secondHighestPeak);
                    decoyScoredGroupPeaksSet.Add(decoyScoredGroupPeaks);
                }

                // Copy all other peaks to target.
                var targetScoredGroupPeaks = new ScoredGroupPeaks();
                foreach (var peak in scoredGroupPeaks.ScoredPeaks)
                {
                    if (!ReferenceEquals(peak.Features, secondHighestPeak.Features))
                    {
                        targetScoredGroupPeaks.Add(peak);
                    }
                }
                targetScoredGroupPeaksSet.Add(targetScoredGroupPeaks);
            }
        }
示例#2
0
        public void SelectTargetsAndDecoys(out ScoredGroupPeaksSet targetScoredGroupPeaksSet, out ScoredGroupPeaksSet decoyScoredGroupPeaksSet)
        {
            targetScoredGroupPeaksSet = new ScoredGroupPeaksSet();
            decoyScoredGroupPeaksSet  = new ScoredGroupPeaksSet();
            foreach (var scoredGroupPeaks in _scoredGroupPeaksList)
            {
                var secondHighestPeak = scoredGroupPeaks.SecondHighestPeak;
                if (secondHighestPeak != null)
                {
                    var decoyScoredGroupPeaks = new ScoredGroupPeaks();
                    decoyScoredGroupPeaks.Add(secondHighestPeak);
                    decoyScoredGroupPeaksSet.Add(decoyScoredGroupPeaks);
                }

                // Copy all other peaks to target.
                var targetScoredGroupPeaks = new ScoredGroupPeaks();
                foreach (var peak in scoredGroupPeaks.ScoredPeaks)
                {
                    if (peak != secondHighestPeak)
                    {
                        targetScoredGroupPeaks.Add(peak);
                    }
                }
                targetScoredGroupPeaksSet.Add(targetScoredGroupPeaks);
            }
        }
示例#3
0
 public ScoredGroupPeaksSet(IEnumerable <IList <float[]> > groupList)
 {
     foreach (var group in groupList)
     {
         var scoredGroupPeaks = new ScoredGroupPeaks();
         foreach (var features in group)
         {
             scoredGroupPeaks.Add(new ScoredPeak(features));
         }
         _scoredGroupPeaksList.Add(scoredGroupPeaks);
     }
 }
示例#4
0
 public ScoredGroupPeaksSet(IEnumerable <IList <float[]> > groupList, int capacity)
 {
     _scoredGroupPeaksList = new List <ScoredGroupPeaks>(capacity);
     foreach (var group in groupList)
     {
         var scoredGroupPeaks = new ScoredGroupPeaks(group.Count);
         foreach (var features in group)
         {
             scoredGroupPeaks.Add(new ScoredPeak(features));
         }
         _scoredGroupPeaksList.Add(scoredGroupPeaks);
     }
 }
示例#5
0
 public void Add(ScoredGroupPeaks scoredGroupPeaks)
 {
     _scoredGroupPeaksList.Add(scoredGroupPeaks);
 }
        private void LoadData(
            string filePath,
            out ScoredGroupPeaksSet targetTransitionGroups,
            out ScoredGroupPeaksSet decoyTransitionGroups)
        {
            var data = new Data(filePath);

            // Find columns of interest in the data file header.
            var mainVarColumn = -1;
            var decoyColumn = -1;
            var transitionGroupIdColumn = -1;
            var varColumns = new List<int>();
            for (int i = 0; i < data.Header.Length; i++)
            {
                var heading = data.Header[i].Trim().ToLowerInvariant();
                if (heading.StartsWith("main_var"))         // Not L10N
                    mainVarColumn = i;
                else if (heading.StartsWith("var_"))        // Not L10N
                    varColumns.Add(i);
                else if (heading == "decoy")                // Not L10N
                    decoyColumn = i;
                else if (heading == "transition_group_id")  // Not L10N
                    transitionGroupIdColumn = i;
            }

            Assert.AreNotEqual(-1, mainVarColumn);
            Assert.AreNotEqual(-1, decoyColumn);
            Assert.AreNotEqual(-1, transitionGroupIdColumn);
            Assert.AreNotEqual(0, varColumns.Count);

            // Create transition groups to be filled from data file.
            targetTransitionGroups = new ScoredGroupPeaksSet();
            decoyTransitionGroups = new ScoredGroupPeaksSet();
            var featuresCount = varColumns.Count + 1;
            var transitionGroupDictionary = new Dictionary<string, ScoredGroupPeaks>();

            // Process each row containing features for a peak.
            for (int i = 0; i < data.Items.GetLength(0); i++)
            {
                ScoredGroupPeaks transitionGroup;
                var decoy = data.Items[i, decoyColumn].Trim().ToLower();
                var transitionGroupId = data.Items[i, transitionGroupIdColumn] + decoy; // Append decoy to make unique groups of decoy/target peaks.

                // The peak belongs to a transition group.  Have we seen this group before?
                if (!transitionGroupDictionary.ContainsKey(transitionGroupId))
                {
                    // Create a new transition group.
                    transitionGroup = new ScoredGroupPeaks { Id = transitionGroupId };
                    transitionGroupDictionary[transitionGroupId] = transitionGroup;

                    // Add the new group to the collection of decoy or target groups.
                    if (decoy == "1" || decoy == "true")    // Not L10N
                        decoyTransitionGroups.Add(transitionGroup);
                    else
                        targetTransitionGroups.Add(transitionGroup);
                }
                else
                {
                    // Retrieve a transition group that was created previously.
                    transitionGroup = transitionGroupDictionary[transitionGroupId];
                }

                // Parse feature values for this peak.
                var features = new float[featuresCount];
                features[0] = (float) double.Parse(data.Items[i, mainVarColumn], CultureInfo.InvariantCulture);
                for (int j = 0; j < varColumns.Count; j++)
                    features[j + 1] = (float) double.Parse(data.Items[i, varColumns[j]], CultureInfo.InvariantCulture);

                // Add the peak to its transition group.
                transitionGroup.Add(new ScoredPeak(features));
            }
        }