コード例 #1
0
        public ModifiedPeptide SetVariableModifications(PeptideModificationState varMods, int index)
        {
            ModifiedPeptide result = CreateNonmodifiedVersion(index);

            result.modifications = varMods;
            if (varMods != null)
            {
                result.mass += varMods.GetDeltaMass();
            }
            return(result);
        }
コード例 #2
0
 public static ModifiedPeptide Read(BinaryReader reader)
 {
     try {
         ModifiedPeptide result = new ModifiedPeptide();
         result.peptideIndex  = reader.ReadInt32();
         result.modifications = PeptideModificationState.Read(reader);
         result.mass          = reader.ReadDouble();
         return(result);
     } catch (EndOfStreamException) {
         return(null);
     }
 }
コード例 #3
0
        public static double ApplyFixedModifications(Modification[] mods, string sequence, bool isNterm, bool isCterm, int len,
                                                     out PeptideModificationCounts modCounts)
        {
            ushort[] modifications = new ushort[len];
            for (int i = 0; i < len; i++)
            {
                modifications[i] = ushort.MaxValue;
            }
            ushort nTermModification = ushort.MaxValue;
            ushort cTermModification = ushort.MaxValue;
            double deltaMass         = 0;

            foreach (Modification mod in mods)
            {
                deltaMass += ApplyFixedModification(mod, sequence, isNterm, isCterm, modifications,
                                                    ref nTermModification, ref cTermModification);
            }
            modCounts = PeptideModificationState.ProjectToCounts(modifications, nTermModification, cTermModification);
            return(deltaMass);
        }
コード例 #4
0
        public PeptideModificationState[] ApplyVariableModificationsFixedNumbers(Modification[] modifications, int[] counts,
                                                                                 out bool incomplete)
        {
            incomplete = false;
            PeptideModificationState[] mods = new PeptideModificationState[] { CreateNonmodifiedVersion() };
            int limit = (int)Math.Round(6000000.0 / sequence.ToString().Length / modifications.Length);

            for (int i = 0; i < modifications.Length; i++)
            {
                bool         incompl;
                Modification mod = modifications[i];
                int          n   = counts[i];
                mods = ApplyVariableModificationFixedNumber(mods, mod, n, out incompl, limit);
                if (incompl)
                {
                    incomplete = true;
                }
            }
            return(mods);
        }
コード例 #5
0
        public static Peptide Read(BinaryReader reader)
        {
            Peptide result = new Peptide();

            result.sequence = AASequence.Read(reader);
            if (result.sequence == null)
            {
                return(null);
            }
            result.monoIsotopicMass = reader.ReadDouble();
            int nproteins = reader.ReadInt32();

            for (int i = 0; i < nproteins; i++)
            {
                result.proteinIndices.Add(reader.ReadInt32());
                result.proteinOffsets.Add(reader.ReadInt32());
                result.residueBefore.Add(reader.ReadByte());
                result.residueAfter.Add(reader.ReadByte());
            }
            result.fixedModifications = PeptideModificationState.Read(reader);
            return(result);
        }
コード例 #6
0
 public ModifiedPeptide(DatabasePeptide peptide, int peptideIndex, string sequence)
 {
     this.peptideIndex = peptideIndex;
     modifications     = new PeptideModificationState(sequence.Length);
     mass = peptide.GetMonoIsotopicMass(sequence);
 }
コード例 #7
0
 public ModifiedPeptide(Peptide peptide, int peptideIndex)
 {
     this.peptideIndex = peptideIndex;
     modifications     = new PeptideModificationState(peptide.Sequence.Length);
     mass = peptide.MonoIsotopicMass;
 }
コード例 #8
0
 public Peptide(string sequence)
 {
     this.sequence      = new AASequence(sequence);
     monoIsotopicMass   = MonoIsotopicMass;
     fixedModifications = new PeptideModificationState(sequence.Length);
 }
コード例 #9
0
        private PeptideModificationState[] ApplyVariableModificationFixedNumber(PeptideModificationState peptide,
                                                                                Modification mod, int n,
                                                                                out bool incomplete)
        {
            incomplete = false;
            if (n == 0)
            {
                return(new PeptideModificationState[0]);
            }
            if (mod.GetPosition() == ModificationPosition.anyNterm)
            {
                if (n > 1)
                {
                    return(new PeptideModificationState[0]);
                }
                if (peptide.GetNTermModification() == ushort.MaxValue)
                {
                    PeptideModificationState q = peptide.Clone();
                    q.SetNTermModification(mod.Index);
                    return(new PeptideModificationState[] { q });
                }
                return(new PeptideModificationState[0]);
            }
            if (mod.GetPosition() == ModificationPosition.anyCterm)
            {
                if (n > 1)
                {
                    return(new PeptideModificationState[0]);
                }
                if (peptide.GetCTermModification() == ushort.MaxValue)
                {
                    PeptideModificationState q = peptide.Clone();
                    q.SetCTermModification(mod.Index);
                    return(new PeptideModificationState[] { q });
                }
                return(new PeptideModificationState[0]);
            }
            if (mod.GetPosition() == ModificationPosition.proteinNterm)
            {
                if (n > 1)
                {
                    return(new PeptideModificationState[0]);
                }
                if (peptide.GetNTermModification() == ushort.MaxValue)
                {
                    PeptideModificationState q = peptide.Clone();
                    q.SetNTermModification(mod.Index);
                    return(new PeptideModificationState[] { q });
                }
                return(new PeptideModificationState[0]);
            }
            if (mod.GetPosition() == ModificationPosition.proteinCterm)
            {
                if (n > 1)
                {
                    return(new PeptideModificationState[0]);
                }
                if (peptide.GetCTermModification() == ushort.MaxValue)
                {
                    PeptideModificationState q = peptide.Clone();
                    q.SetCTermModification(mod.Index);
                    return(new PeptideModificationState[] { q });
                }
                return(new PeptideModificationState[0]);
            }
            string s = Sequence;

            switch (mod.GetTermType(0))
            {
            case ModificationSiteType.aa: {
                HashSet <int> ind = new HashSet <int>();
                for (int j = 0; j < s.Length; j++)
                {
                    for (int i = 0; i < mod.AaCount; i++)
                    {
                        if (s[j] == mod.GetAaAt(i) && peptide.GetModificationAt(j) == ushort.MaxValue)
                        {
                            ind.Add(j);
                        }
                    }
                }
                int[] indices = ind.ToArray();
                if (indices.Length < n)
                {
                    return(new PeptideModificationState[0]);
                }
                List <PeptideModificationState> result = new List <PeptideModificationState>();
                bool    incompl;
                int[][] comb = NumUtil.GetCombinations(indices.Length, n, 10000, out incompl);
                if (incompl)
                {
                    incomplete = incompl;
                }
                for (int j = 0; j < comb.Length; j++)
                {
                    int[] iind = ArrayUtil.SubArray(indices, comb[j]);
                    PeptideModificationState q = peptide.Clone();
                    for (int k = 0; k < iind.Length; k++)
                    {
                        q.SetModificationAt(iind[k], mod.Index);
                    }
                    result.Add(q);
                }
                return(result.ToArray());
            }

            case ModificationSiteType.nterm: {
                if (n > 1)
                {
                    return(new PeptideModificationState[0]);
                }
                for (int i = 0; i < mod.AaCount; i++)
                {
                    List <PeptideModificationState> toBeAdded = new List <PeptideModificationState>();
                    if (s[0] == mod.GetAaAt(i) && peptide.GetNTermModification() == ushort.MaxValue)
                    {
                        PeptideModificationState q = peptide.Clone();
                        q.SetNTermModification(mod.Index);
                        toBeAdded.Add(q);
                    }
                    if (toBeAdded.Count > 0)
                    {
                        return(toBeAdded.ToArray());
                    }
                }
                return(new PeptideModificationState[0]);
            }

            case ModificationSiteType.cterm: {
                if (n > 1)
                {
                    return(new PeptideModificationState[0]);
                }
                for (int i = 0; i < mod.AaCount; i++)
                {
                    List <PeptideModificationState> toBeAdded = new List <PeptideModificationState>();
                    if (s[s.Length - 1] == mod.GetAaAt(i) && peptide.GetCTermModification() == ushort.MaxValue)
                    {
                        PeptideModificationState q = peptide.Clone();
                        q.SetCTermModification(mod.Index);
                        toBeAdded.Add(q);
                    }
                    if (toBeAdded.Count > 0)
                    {
                        return(toBeAdded.ToArray());
                    }
                }
                return(new PeptideModificationState[0]);
            }
            }
            throw new Exception("Never get here.");
        }