Exemple #1
0
        internal ScoringGraph(AminoAcid[] aminoAcidSequence, Composition sequenceComposition, ScoringGraphNode rootNode,
                              int minPrecursorCharge, int maxPrecursorCharge)
        {
            _aminoAcidSequence   = aminoAcidSequence;
            _sequenceComposition = sequenceComposition;
            _rootNode            = rootNode;
            _minPrecursorCharge  = minPrecursorCharge;
            _maxPrecursorCharge  = maxPrecursorCharge;

            _precursorIon = new Dictionary <int, Ion>();
            for (var precursorCharge = _minPrecursorCharge; precursorCharge <= _maxPrecursorCharge; precursorCharge++)
            {
                _precursorIon[precursorCharge] = new Ion(_sequenceComposition, precursorCharge);
            }

            // store all nodes in an array
            var nodes = new HashSet <ScoringGraphNode>();

            var curNodes = new HashSet <ScoringGraphNode> {
                _rootNode
            };

            while (curNodes.Any())
            {
                var newNodes = new HashSet <ScoringGraphNode>();
                foreach (var node in curNodes)
                {
                    if (nodes.Add(node))    // if node is new
                    {
                        foreach (var nextNode in node.GetNextNodes())
                        {
                            newNodes.Add(nextNode);
                        }
                    }
                }
                curNodes = newNodes;
            }

            _nodes = nodes.ToArray();
        }
Exemple #2
0
        private double GetProductIonScore(ScoringGraphNode node, ImsScorer imsScorer, Feature precursorFeature)
        {
            //Console.Write("Offset: " + node.Offset);
            double cutScore = 0;

            if (node.Index > 1 && node.Index <= _aminoAcidSequence.Length - 3)
            {
                var nTermAA = _aminoAcidSequence[node.Index].Residue;
                var cTermAA = _aminoAcidSequence[node.Index + 1].Residue;
                cutScore = imsScorer.GetCutScore(nTermAA, cTermAA, node.Composition, precursorFeature);
                //Console.WriteLine(" " + _aminoAcidSequence[node.Offset].Residue + " " + node.Composition + " " + _aminoAcidSequence[node.Offset + 1].Residue + " " + cutScore);
            }
            //Console.WriteLine();

            if (node.Index > _aminoAcidSequence.Length - 3)
            {
                return(0);
            }
            var nextNodeScore = node.GetNextNodes().DefaultIfEmpty().Max(nextNode => GetProductIonScore(nextNode, imsScorer, precursorFeature));

            return(cutScore + nextNodeScore);
        }
Exemple #3
0
 internal ScoringGraph(AminoAcid[] aminoAcidSequence, Composition sequenceComposition, ScoringGraphNode rootNode)
     : this(aminoAcidSequence, sequenceComposition, rootNode, DefaultMinPrecursorCharge, DefaultMaxPrecursorCharge)
 {
 }
Exemple #4
0
 public void AddNextNode(ScoringGraphNode nextNode)
 {
     _nextNodes.Add(nextNode);
 }