Exemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="mod"></param>
 /// <param name="targetResidue"></param>
 /// <param name="loc"></param>
 /// <param name="isFixedModification"></param>
 public SearchModification(Modification mod, char targetResidue, SequenceLocation loc, bool isFixedModification)
 {
     Modification        = mod;
     TargetResidue       = targetResidue;
     Location            = loc;
     IsFixedModification = isFixedModification;
 }
Exemplo n.º 2
0
 public SearchModification(Modification mod, char targetResidue, SequenceLocation loc, bool isFixedModification)
 {
     Modification = mod;
     TargetResidue = targetResidue;
     Location = loc;
     IsFixedModification = isFixedModification;
 }
Exemplo n.º 3
0
        /// <summary>
        /// Get the indices of modifications that apply to residue <paramref name="residue"/> at location <paramref name="location"/>
        /// </summary>
        /// <param name="residue"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        public int[] GetModificationIndices(char residue, SequenceLocation location)
        {
            var residueModMap = _locationSpecificResidueModMap[location];

            if (residueModMap.TryGetValue(residue, out var modIndexArr))
            {
                return(modIndexArr);
            }
            return(new int[0]);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Get the amino acid specified by character <paramref name="residue"/> that occurs at location <paramref name="location"/>, with any static modifications
        /// </summary>
        /// <param name="residue"></param>
        /// <param name="location"></param>
        /// <returns></returns>
        public AminoAcid GetAminoAcid(char residue, SequenceLocation location)
        {
            var residueMap = _locationSpecificResidueMap[location];

            if (residueMap.TryGetValue(residue, out var aminoAcid))
            {
                return(aminoAcid);
            }
            return(null);
        }
Exemplo n.º 5
0
 public bool AddAminoAcid(char residue, SequenceLocation location = SequenceLocation.Everywhere)
 {
     return PutAminoAcid(_index, residue, location);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Add an amino acid residue to this generator.
        /// </summary>
        /// <param name="index">index to add the amino acid. 0 is C-term. 1 is the C-term amino acid.</param>
        /// <param name="residue">amino acid residue to add.</param>
        /// <param name="loc">location of the residue</param>
        /// <returns>true if residue is a valid amino acid; false otherwise.</returns>
        private bool PutAminoAcid(int index, char residue, SequenceLocation loc)
        {
            _index = index + 1;

            var aminoAcid = AminoAcidSet.GetAminoAcid(residue, loc);
            if (aminoAcid == null) // residue is not valid
            {
                return false;
            }

            var fragmentComposition = _fragmentComposition[_index - 1] + aminoAcid.Composition;
            if (fragmentComposition.Mass > _maxSequenceMass) return false;

            _aminoAcidSequence[_index] = aminoAcid;
            _fragmentComposition[_index] = fragmentComposition;

            var modIndices = AminoAcidSet.GetModificationIndices(residue, loc);
            if (!modIndices.Any())  // No modification
            {
                _graph[_index] = new Node[_graph[_index - 1].Length];
                for (var i = 0; i < _graph[_index - 1].Length; i++)
                {
                    _graph[_index][i] = new Node(_graph[_index - 1][i].ModificationCombinationIndex, i);
                }
            }
            else
            {
                var modCombIndexToNodeMap = new Dictionary<int, Node>();
                for (var i = 0; i < _graph[_index - 1].Length; i++)
                {
                    var prevNodeIndex = i;
                    var prevNode = _graph[_index - 1][i];
                    var prevModCombIndex = prevNode.ModificationCombinationIndex;
                    Node newNode;
                    // unmodified edge
                    if (modCombIndexToNodeMap.TryGetValue(prevModCombIndex, out newNode))
                    {
                        newNode.AddPrevNodeIndex(prevNodeIndex);
                    }
                    else
                    {
                        modCombIndexToNodeMap.Add(prevModCombIndex, new Node(prevModCombIndex, prevNodeIndex));
                    }

                    // modified edge
                    foreach (var modIndex in modIndices)
                    {
                        var modCombIndex = ModificationParams.GetModificationCombinationIndex(
                                                    prevNode.ModificationCombinationIndex, modIndex);
                        if (modCombIndex < 0)   // too many modifications
                            continue;
                        if (modCombIndexToNodeMap.TryGetValue(modCombIndex, out newNode))
                        {
                            newNode.AddPrevNodeIndex(prevNodeIndex);
                        }
                        else
                        {
                            modCombIndexToNodeMap.Add(modCombIndex, new Node(modCombIndex, prevNodeIndex));
                        }
                    }
                    _graph[_index] = modCombIndexToNodeMap.Values.ToArray();
                }
            }

            return true;
        }
Exemplo n.º 7
0
 public int[] GetModificationIndices(char residue, SequenceLocation location)
 {
     var residueModMap = _locationSpecificResidueModMap[location];
     int[] modIndexArr;
     if (residueModMap.TryGetValue(residue, out modIndexArr))
     {
         return modIndexArr;
     }
     return new int[0];
 }
Exemplo n.º 8
0
 public AminoAcid GetAminoAcid(char residue, SequenceLocation location)
 {
     var residueMap = _locationSpecificResidueMap[location];
     AminoAcid aminoAcid;
     if (residueMap.TryGetValue(residue, out aminoAcid))
     {
         return aminoAcid;
     }
     return null;
 }
Exemplo n.º 9
0
 /// <summary>
 /// Add an amino acid to this shifted sequence graph
 /// </summary>
 /// <param name="residue"></param>
 /// <param name="location"></param>
 /// <returns></returns>
 public bool AddAminoAcid(char residue, SequenceLocation location = SequenceLocation.Everywhere)
 {
     return(PutAminoAcid(_index, residue, location));
 }
Exemplo n.º 10
0
        /// <summary>
        /// Add an amino acid residue to this generator.
        /// </summary>
        /// <param name="index">index to add the amino acid. 0 is C-term. 1 is the C-term amino acid.</param>
        /// <param name="residue">amino acid residue to add.</param>
        /// <param name="loc">location of the residue</param>
        /// <returns>true if residue is a valid amino acid; false otherwise.</returns>
        private bool PutAminoAcid(int index, char residue, SequenceLocation loc)
        {
            _index = index + 1;

            var aminoAcid = AminoAcidSet.GetAminoAcid(residue, loc);

            if (aminoAcid == null) // residue is not valid
            {
                return(false);
            }

            var fragmentComposition = _fragmentComposition[_index - 1] + aminoAcid.Composition;

            if (fragmentComposition.Mass > _maxSequenceMass)
            {
                return(false);
            }

            _aminoAcidSequence[_index]   = aminoAcid;
            _fragmentComposition[_index] = fragmentComposition;

            var modIndices = AminoAcidSet.GetModificationIndices(residue, loc);

            if (!modIndices.Any())  // No modification
            {
                _graph[_index] = new Node[_graph[_index - 1].Length];
                for (var i = 0; i < _graph[_index - 1].Length; i++)
                {
                    _graph[_index][i] = new Node(_graph[_index - 1][i].ModificationCombinationIndex, i);
                }
            }
            else
            {
                var modCombIndexToNodeMap = new Dictionary <int, Node>();
                for (var i = 0; i < _graph[_index - 1].Length; i++)
                {
                    var prevNodeIndex    = i;
                    var prevNode         = _graph[_index - 1][i];
                    var prevModCombIndex = prevNode.ModificationCombinationIndex;

                    // unmodified edge
                    if (modCombIndexToNodeMap.TryGetValue(prevModCombIndex, out var unmodifiedEdgeNode))
                    {
                        unmodifiedEdgeNode.AddPrevNodeIndex(prevNodeIndex);
                    }
                    else
                    {
                        modCombIndexToNodeMap.Add(prevModCombIndex, new Node(prevModCombIndex, prevNodeIndex));
                    }

                    // modified edge
                    foreach (var modIndex in modIndices)
                    {
                        var modCombIndex = ModificationParams.GetModificationCombinationIndex(
                            prevNode.ModificationCombinationIndex, modIndex);
                        if (modCombIndex < 0)   // too many modifications
                        {
                            continue;
                        }
                        if (modCombIndexToNodeMap.TryGetValue(modCombIndex, out var modifiedEdgeNode))
                        {
                            modifiedEdgeNode.AddPrevNodeIndex(prevNodeIndex);
                        }
                        else
                        {
                            modCombIndexToNodeMap.Add(modCombIndex, new Node(modCombIndex, prevNodeIndex));
                        }
                    }
                    _graph[_index] = modCombIndexToNodeMap.Values.ToArray();
                }
            }

            return(true);
        }