示例#1
0
 public void AddEValueDist(ScoreDistribution otherDistribution, int deltaScore, double weight)
 {
     if (otherDistribution == null) return;
     
     for (var index = Math.Max(otherDistribution.MinScore, MinScore - deltaScore); index < otherDistribution.MaxScore; index++)
     {
         var delEValue = otherDistribution._eValueDistribution[index - otherDistribution.MinScore]*weight;
         _eValueDistribution[index + deltaScore - MinScore] += delEValue;
     }
 }
示例#2
0
        private ScoreDistribution GetScoreDistribution(int nodeIndex, ScoreDistribution[] gfTable)
        {
            var curNodeScore = _graph.GetNodeScore(nodeIndex);

            // determine MinScore and MaxScore
            var maxScore = (double)int.MinValue;
            var minScore = (double)int.MaxValue;

            var hasValidEdge = false;

            foreach (var edge in _graph.GetEdges(nodeIndex))
            {
                var prevNodeIndex         = edge.PrevNodeIndex;
                var prevScoreDistribution = gfTable[prevNodeIndex];
                if (prevScoreDistribution == null)
                {
                    continue;
                }
                var combinedScore = curNodeScore + _graph.GetEdgeScore(prevNodeIndex, nodeIndex);

                if (prevScoreDistribution.MaxScore + combinedScore > maxScore)
                {
                    maxScore = prevScoreDistribution.MaxScore + combinedScore;
                }
                if (prevScoreDistribution.MinScore + combinedScore < minScore)
                {
                    minScore = prevScoreDistribution.MinScore + combinedScore;
                }
                hasValidEdge = true;
            }

            if (!hasValidEdge)
            {
                return(null);               //new ScoreDistribution(0, 1);
            }
            // considering Target score for fast computing.....max 2 times faster but not useful at this point Scoredistriubtion
            //minScore = Math.Max(_targetScore - _maxAchievableScore[nodeIndex], minScore);

            // Compute scoring distribution for the current node
            var scoringDistribution = new ScoreDistribution((int)Math.Floor(minScore), (int)Math.Ceiling(maxScore));

            foreach (var edge in _graph.GetEdges(nodeIndex))
            {
                var prevScoreDistribution = gfTable[edge.PrevNodeIndex];
                if (prevScoreDistribution == null)
                {
                    continue;
                }
                var combinedScore = curNodeScore + _graph.GetEdgeScore(edge.PrevNodeIndex, nodeIndex);
                scoringDistribution.AddEValueDist(prevScoreDistribution, (int)Math.Round(combinedScore), edge.Weight);
            }
            return(scoringDistribution);
        }
示例#3
0
        public void AddEValueDist(ScoreDistribution otherDistribution, int deltaScore, double weight)
        {
            if (otherDistribution == null)
            {
                return;
            }

            for (var index = Math.Max(otherDistribution.MinScore, MinScore - deltaScore); index < otherDistribution.MaxScore; index++)
            {
                var delEValue = otherDistribution._eValueDistribution[index - otherDistribution.MinScore] * weight;
                _eValueDistribution[index + deltaScore - MinScore] += delEValue;
            }
        }
示例#4
0
        private ScoreDistribution GetScoreDistribution(int nodeIndex, ScoreDistribution[] gfTable)
        {
            var curNodeScore = _graph.GetNodeScore(nodeIndex);

            // determine MinScore and MaxScore
            var maxScore = (double) int.MinValue;
            var minScore = (double) int.MaxValue;

            var hasValidEdge = false;
            foreach (var edge in _graph.GetEdges(nodeIndex))
            {
                var prevNodeIndex = edge.PrevNodeIndex;
                var prevScoreDistribution = gfTable[prevNodeIndex];
                if (prevScoreDistribution == null) continue;
                var combinedScore = curNodeScore + _graph.GetEdgeScore(prevNodeIndex, nodeIndex);

                if (prevScoreDistribution.MaxScore + combinedScore > maxScore)
                {
                    maxScore = prevScoreDistribution.MaxScore + combinedScore;
                }
                if (prevScoreDistribution.MinScore + combinedScore < minScore)
                {
                    minScore = prevScoreDistribution.MinScore + combinedScore;
                }
                hasValidEdge = true;
            }

            if (!hasValidEdge) return null; //new ScoreDistribution(0, 1);
            
            // considering Target score for fast computing.....max 2 times faster but not useful at this point Scoredistriubtion 
            //minScore = Math.Max(_targetScore - _maxAchievableScore[nodeIndex], minScore);

            // Compute scoring distribution for the current node
            var scoringDistribution = new ScoreDistribution((int)Math.Floor(minScore), (int)Math.Ceiling(maxScore));

            foreach (var edge in _graph.GetEdges(nodeIndex))
            {
                var prevScoreDistribution = gfTable[edge.PrevNodeIndex];
                if (prevScoreDistribution == null) continue;
                var combinedScore = curNodeScore + _graph.GetEdgeScore(edge.PrevNodeIndex, nodeIndex);
                scoringDistribution.AddEValueDist(prevScoreDistribution, (int)Math.Round(combinedScore), edge.Weight);
            }
            return scoringDistribution;
        }
示例#5
0
        //private int _targetScore;
        //private readonly int[] _maxAchievableScore;

        public void ComputeGeneratingFunction()//int targetScore = 0)
        {
            //_targetScore = targetScore;
            var gfTable = new ScoreDistribution[_graph.GetNumNodes()];
            // Source
            var sourceDist = new ScoreDistribution(0, 1);
            sourceDist.SetEValue(0, 1);
            gfTable[0] = sourceDist;

            // All the other nodes
            for (var nodeIndex = 1; nodeIndex < _graph.GetNumNodes(); nodeIndex++)
            {
                gfTable[nodeIndex] = GetScoreDistribution(nodeIndex, gfTable);
            }

            // Sink
            // TODO: adjusting the distribution depending on neighboring amino acid (e.g. R.PEPTIDEK. vs A.PEPTIDEK)
            _scoreDistribution = gfTable[gfTable.Length - 1];
        }
示例#6
0
        //private int _targetScore;
        //private readonly int[] _maxAchievableScore;

        public void ComputeGeneratingFunction()//int targetScore = 0)
        {
            //_targetScore = targetScore;
            var gfTable = new ScoreDistribution[_graph.GetNumNodes()];
            // Source
            var sourceDist = new ScoreDistribution(0, 1);

            sourceDist.SetEValue(0, 1);
            gfTable[0] = sourceDist;

            // All the other nodes
            for (var nodeIndex = 1; nodeIndex < _graph.GetNumNodes(); nodeIndex++)
            {
                gfTable[nodeIndex] = GetScoreDistribution(nodeIndex, gfTable);
            }

            // Sink
            // TODO: adjusting the distribution depending on neighboring amino acid (e.g. R.PEPTIDEK. vs A.PEPTIDEK)
            _scoreDistribution = gfTable[gfTable.Length - 1];
        }