Пример #1
0
        public static double CalcMonoisotopicMass(string sequence, PeptideModificationState varMod, Modification[] fixMod)
        {
            double result = AminoAcid.CalcMonoisotopicMass(sequence) + varMod.GetDeltaMass();

            foreach (char c in sequence)
            {
                result += GetDeltaFixed(c, fixMod);
            }
            return(result);
        }
Пример #2
0
        /// <summary>
        /// Indication of whether or not an ISequenceItem is in the alphabet. This is
        /// a simple lookup and will only match exactly with items of this alphabet. It
        /// will not compare items from other alphabets that match the same amino acid.
        /// </summary>
        public bool Contains(ISequenceItem item)
        {
            AminoAcid aa = item as AminoAcid;

            if (aa == null)
            {
                return(false);
            }

            return(values.Contains(aa));
        }
Пример #3
0
// ReSharper disable MemberCanBeMadeStatic.Local
        private void comboAA_KeyPress(object sender, KeyPressEventArgs e)
        {
            // Force uppercase in this control.
            e.KeyChar = char.ToUpper(e.KeyChar);
            // Only allow amino acid characters space, comma and backspace
            // ReSharper disable once LocalizableElement
            if (!AminoAcid.IsAA(e.KeyChar) && " ,\b".IndexOf(e.KeyChar) == -1)
            {
                e.Handled = true;
            }
        }
Пример #4
0
        public AminoAcid CreateAminoAcid()
        {
            var aminoAcid = new AminoAcid()
            {
                Name = "TestAminoAcid",
                Code = "Z"
            };

            aminoAcid.Codons.Add(CreateCodon());

            return(GetOrCreate(() => aminoAcid));
        }
        /// <summary>
        /// Initializes new instance of <see cref="FragmentViewModel" />.
        /// </summary>
        /// <param name="aminoAcid">The selected amino acid.</param>
        /// <param name="index">The index of this fragment within the greater sequence that it is part of.</param>
        /// <param name="dialogService">Dialog service for opening LCMSSpectator dialogs.</param>
        public FragmentViewModel(AminoAcid aminoAcid, int index = 0, IMainDialogService dialogService = null)
        {
            AminoAcid = aminoAcid;
            Index     = index;
            SetModSymbol(aminoAcid as ModifiedAminoAcid);

            this.dialogService        = dialogService ?? new MainDialogService();
            SelectModificationCommand = ReactiveCommand.Create(SelectModificationImpl);

            // Update the modification symbol when the amino acid changes.
            this.WhenAnyValue(x => x.AminoAcid).Subscribe(aa => SetModSymbol(aa as ModifiedAminoAcid));
        }
Пример #6
0
        private void Validate()
        {
            if (string.IsNullOrEmpty(CleavageC) && string.IsNullOrEmpty(CleavageN))
            {
                throw new InvalidDataException(Resources.Enzyme_Validate_Enzymes_must_have_at_least_one_cleavage_point);
            }
            var cleavageAll = String.Empty;

            if (string.IsNullOrEmpty(CleavageC))
            {
                if (!string.IsNullOrEmpty(RestrictC))
                {
                    throw new InvalidDataException(Resources.Enzyme_Validate_Enzyme_must_have_C_terminal_cleavage_to_have_C_terminal_restrictions_);
                }
                CleavageC  = RestrictC = null;
                _cleavageC = null;
                _restrictC = null;
            }
            else
            {
                AminoAcid.ValidateAAList(CleavageC);
                if (!string.IsNullOrEmpty(RestrictC))
                {
                    AminoAcid.ValidateAAList(RestrictC);
                }
                _cleavageC  = CleavageC.ToCharArray();
                _restrictC  = RestrictC == null? null : RestrictC.ToCharArray();
                cleavageAll = CleavageC;
            }
            if (string.IsNullOrEmpty(CleavageN))
            {
                if (!string.IsNullOrEmpty(RestrictN))
                {
                    throw new InvalidDataException(Resources.Enzyme_Validate_Enzyme_must_have_N_terminal_cleavage_to_have_N_terminal_restrictions_);
                }
                CleavageN  = RestrictN = null;
                _cleavageN = null;
                _restrictN = null;
            }
            else
            {
                AminoAcid.ValidateAAList(CleavageN);
                if (!string.IsNullOrEmpty(RestrictN))
                {
                    AminoAcid.ValidateAAList(RestrictN);
                }

                _cleavageN   = CleavageN.ToCharArray();
                _restrictN   = RestrictN == null ? null : RestrictN.ToCharArray();
                cleavageAll += CleavageN;
            }
            _cleavageAll = cleavageAll.ToCharArray();
        }
Пример #7
0
        private static IEnumerable <Composition> DefaultCompositionCalculator(
            Dictionary <char, double[]> possibleOffsets,
            AminoAcid aminoAcid)
        {
            if (aminoAcid == null)
            {
                return(possibleOffsets['*'].Select(off => new CompositionWithDeltaMass(off)));
            }
            var key = possibleOffsets.ContainsKey(aminoAcid.Residue) ? aminoAcid.Residue : '*';

            return(possibleOffsets[key].Select(offset => new CompositionWithDeltaMass(offset) - aminoAcid.Composition));
        }
Пример #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FlipScoringGraphEdge" />
 /// with initialized data.
 /// </summary>
 /// <param name="prevNodeIndex">The source node index.</param>
 /// <param name="sinkNodeIndex">The sink node index.</param>
 /// <param name="weight">The edge weight.</param>
 /// <param name="label">The amino acid that that the edge corresponds to.</param>
 /// <param name="scorer">The FLIP scoring model.</param>
 public FlipScoringGraphEdge(
     int prevNodeIndex,
     int sinkNodeIndex,
     double weight,
     AminoAcid label,
     FlipScorer <DeconvolutedSpectrum> scorer)
 {
     this.PrevNodeIndex = prevNodeIndex;
     this.SinkNodeIndex = sinkNodeIndex;
     this.Weight        = weight;
     this.Label         = label;
     this.scorer        = scorer;
 }
        private Group TranslateCDKMonomer(IMonomer iMonomer)
        {
            // find type
            Type cdkType = iMonomer.GetType();

            if (cdkType is AminoAcid)
            {
                AminoAcid amino = (AminoAcid)iMonomer;

                //AminoMonomer monomer = new AminoMonomer();
            }
            return(null);
        }
Пример #10
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="aa"></param>
        /// <param name="modification"></param>
        public ModifiedAminoAcid(AminoAcid aa, Modification modification)
            : base(aa.Residue, aa.Name + "+" + modification.Name, aa.Composition + modification.Composition)
        {
            var modAa = aa as ModifiedAminoAcid;

            if (modAa == null)
            {
                _modification = modification; // aa is not modified
            }
            else                              // aa is already modified
            {
                _modification = Modification.RegisterAndGetModification(modAa.Modification.Name + "+" + modification.Name, Composition);
            }
        }
Пример #11
0
        /// <summary>Initializes a new instance of the <see cref="GraphXSequenceGraph"/> class.</summary>
        /// <param name="aminoAcidSet">The amino acid set.</param>
        /// <param name="nterm">The n-terminal residue of the sequence.</param>
        /// <param name="sequence">The sequence.</param>
        /// <param name="cterm">The c-terminal residue of the sequence.</param>
        /// <param name="mods">The search modification to apply to the sequence.</param>
        protected GraphXSequenceGraph(AminoAcidSet aminoAcidSet, AminoAcid nterm, string sequence, AminoAcid cterm, IEnumerable <SearchModification> mods) :
            base(aminoAcidSet, nterm, sequence, cterm)
        {
            var modList = mods.ToList();

            var ntermMods = (from m in modList
                             where (m.IsFixedModification && (m.Location == SequenceLocation.ProteinNTerm || m.Location == SequenceLocation.PeptideNTerm))
                             select m).ToList();

            var ctermMods = (from m in modList
                             where (m.IsFixedModification && (m.Location == SequenceLocation.ProteinCTerm || m.Location == SequenceLocation.PeptideCTerm))
                             select m).ToList();

            Modification ntermMod = null;

            foreach (var nmod in ntermMods)
            {
                ntermMod = nmod.Modification;
                if (nmod.TargetResidue == nterm.Residue)
                {
                    break;
                }
            }

            Modification ctermMod = null;

            foreach (var cmod in ctermMods)
            {
                ctermMod = cmod.Modification;
                if (cmod.TargetResidue == cterm.Residue)
                {
                    break;
                }
            }

            nterminal = null;
            cterminal = null;
            if (ntermMod != null)
            {
                nterminal = new ModifiedAminoAcid(new AminoAcid('(', "NTerm", Composition.Zero), ntermMod);
            }

            if (ctermMod != null)
            {
                cterminal = new ModifiedAminoAcid(new AminoAcid(')', "CTerm", Composition.Zero), ctermMod);
            }

            DataGraph = new DataGraph();
            BuildGraph();
        }
Пример #12
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            if (this == obj)
            {
                return(true);
            }
            AminoAcid other = obj as AminoAcid;

            return(other?.Letter == Letter);
        }
Пример #13
0
        /// <summary>
        /// The original had support for a chargeIncrement variable, which
        /// I did not understand, but reviewing a calculate_pi program written by Jimmy Eng,
        /// I found that he used zero for this variable:
        /// http://sashimi.svn.sourceforge.net/viewvc/sashimi/trunk/trans_proteomic_pipeline/src/util/calculate_pi.cpp?revision=5807&amp;view=markup
        /// The results of using zero are different from using 1, and they match up perfectly
        /// with this web-based pI calculator:
        /// http://expasy.org/tools/pi_tool.html
        /// I have left the chargeIncrement parameter for historical reasons, but suggest
        /// using the default, unless you understand this variable better than I do.
        /// </summary>
        /// <param name="seq">The peptide sequence for which the isoelectric point (pI) is desired</param>
        /// <param name="chargeIncrement">Meaning unknown</param>
        /// <returns>The calculated pI for the peptide</returns>
        public static double Calculate(string seq, int chargeIncrement = 0)
        {
            int[] comp = new int[26];    /* Amino acid composition of the protein */

            foreach (char aa in seq)
            {
                comp[AminoAcid.ToIndex(aa)]++;
            }

            int ntermRes = AminoAcid.ToIndex(seq.First());
            int ctermRes = AminoAcid.ToIndex(seq.Last());

            double phMin = PH_MIN;
            double phMax = PH_MAX;

            int    i;
            double phMid = 0;

            for (i = 0; i < MAXLOOP && (phMax - phMin) > EPSI; i++)
            {
                phMid = phMin + (phMax - phMin) / 2.0;

                double cter = Exp10(-PK[ctermRes, 0]) / (Exp10(-PK[ctermRes, 0]) + Exp10(-phMid));
                double nter = Exp10(-phMid) / (Exp10(-PK[ntermRes, 1]) + Exp10(-phMid));

                double carg = comp[R] * Exp10(-phMid) / (Exp10(-PK[R, 2]) + Exp10(-phMid));
                double chis = comp[H] * Exp10(-phMid) / (Exp10(-PK[H, 2]) + Exp10(-phMid));
                double clys = comp[K] * Exp10(-phMid) / (Exp10(-PK[K, 2]) + Exp10(-phMid));

                double casp = comp[D] * Exp10(-PK[D, 2]) / (Exp10(-PK[D, 2]) + Exp10(-phMid));
                double cglu = comp[E] * Exp10(-PK[E, 2]) / (Exp10(-PK[E, 2]) + Exp10(-phMid));

                double ccys = comp[C] * Exp10(-PK[C, 2]) / (Exp10(-PK[C, 2]) + Exp10(-phMid));
                double ctyr = comp[Y] * Exp10(-PK[Y, 2]) / (Exp10(-PK[Y, 2]) + Exp10(-phMid));

                double charge = carg + clys + chis + nter + chargeIncrement
                                - (casp + cglu + ctyr + ccys + cter);

                if (charge > 0.0)
                {
                    phMin = phMid;
                }
                else
                {
                    phMax = phMid;
                }
            }

            return(phMid);
        }
Пример #14
0
 public static void ValidateSequence(string seq)
 {
     if (string.IsNullOrEmpty(seq))
     {
         throw new InvalidDataException(Resources.FastaSequence_ValidateSequence_A_protein_sequence_may_not_be_empty);
     }
     for (int i = 0; i < seq.Length; i++)
     {
         char c = seq[i];
         if (!AminoAcid.IsExAA(c) && c != '*' && c != '-') // Not L10N
         {
             throw new InvalidDataException(string.Format(Resources.FastaSequence_ValidateSequence_A_protein_sequence_may_not_contain_the_character__0__at__1__, seq[i], i));
         }
     }
 }
Пример #15
0
        /// <summary>
        /// Used to determine if a string contains a valid amino acid
        /// sequence.
        /// </summary>
        /// <param name="seq">The string to inspect.</param>
        /// <returns>True if the string is non-zero length and contains only amino acids.</returns>
        public static bool IsSequence(string seq)
        {
            if (seq.Length == 0)
            {
                return(false);
            }

            foreach (char c in seq)
            {
                if (!AminoAcid.IsAA(c))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #16
0
        public override double GetFragmentScore(Composition prefixFragmentComposition, Composition suffixFragmentComposition,
                                                AminoAcid nTerminalResidue = null,
                                                AminoAcid cTerminalResidue = null)
        {
            var score     = 0.0;
            var prefixHit = false;
            var suffixHit = false;

            foreach (var baseIonType in BaseIonTypes)
            {
                var fragmentComposition = baseIonType.IsPrefix
                    ? prefixFragmentComposition + baseIonType.OffsetComposition
                    : suffixFragmentComposition + baseIonType.OffsetComposition;

                var param = baseIonType.IsPrefix ? ScoreParam.Prefix : ScoreParam.Suffix;

                var massBinNum = _comparer.GetBinNumber(fragmentComposition.Mass);
                if (massBinNum >= 0 && massBinNum < _comparer.NumberOfBins)
                {
                    if (_massBinToPeakMap.TryGetValue(massBinNum, out var existingPeak))
                    {
                        var massErrorPpm = 1e6 * (Math.Abs(existingPeak.Mass - fragmentComposition.Mass) / fragmentComposition.Mass);
                        score += param.Count;
                        score += param.Intensity * Math.Min(existingPeak.Intensity / ReferencePeakIntensity, 1.0); // intensity-based scoring
                        score += param.Dist * existingPeak.Dist;                                                   // Envelope distance-based scoring
                        score += param.Corr * existingPeak.Corr;                                                   // Envelope correlation-based scoring
                        score += param.MassError * massErrorPpm;                                                   // Envelope correlation-based scoring

                        if (baseIonType.IsPrefix)
                        {
                            prefixHit = true;
                        }
                        else
                        {
                            suffixHit = true;
                        }
                    }
                }
            }

            if (prefixHit && suffixHit)
            {
                score += ScoreParam.ComplementaryIonCount;
            }
            return(score);
        }
Пример #17
0
        public static AminoAcid[] CalcAllAas(SilacLabel[] labels1)
        {
            List <AminoAcid> result = new List <AminoAcid>();

            for (int i = 0; i < labels1.Length; i++)
            {
                foreach (AminoAcid aa in AminoAcid.aminoAcids)
                {
                    if (aa.Equals(AminoAcid.GetAminoAcidFromLabel(labels1[i])))
                    {
                        result.Add(aa);
                        break;
                    }
                }
            }
            return(result.ToArray());
        }
Пример #18
0
        public static bool IsExSequence(string seq)
        {
            seq = StripModifications(seq);
            if (seq.Length == 0)
            {
                return(false);
            }

            foreach (char c in seq)
            {
                if (!AminoAcid.IsExAA(c))
                {
                    return(false);
                }
            }
            return(true);
        }
Пример #19
0
        /// <summary>
        /// Handle a single umod:aa element and child nodes
        /// Called by ReadAminoAcids (xml hierarchy)
        /// </summary>
        /// <param name="reader">XmlReader that is only valid for the scope of the single umod:aa element</param>
        private static void ReadAminoAcid(XmlReader reader)
        {
            reader.MoveToContent(); // Move to the "aa" element

            string title     = reader.GetAttribute("title");
            string shortName = reader.GetAttribute("three_letter");
            string fullName  = reader.GetAttribute("full_name");
            double monoMass  = Convert.ToDouble(reader.GetAttribute("mono_mass"));
            double avgMass   = Convert.ToDouble(reader.GetAttribute("avge_mass"));

            ChemFormula formula = ReadFormula(reader.ReadSubtree());

            var amAcid = new AminoAcid(title, shortName, fullName, monoMass, avgMass, formula);

            AminoAcids.Add(title, amAcid);

            reader.Close();
        }
Пример #20
0
        /// <summary>
        /// Passes a valid RNA sequence with offset value and validates if
        /// Lookup(sequence) method is returning corresponding amino acid.
        /// </summary>
        /// <param name="sequenceNode">Sequence xml node.</param>
        /// <param name="offsetNode">Offset node with value.</param>
        /// <param name="aminoAcidNode">Expected amino acid value.</param>
        void ValidateCodonsTranslationWithOffset(string sequenceNode,
                                                 string offsetNode, string aminoAcidNode)
        {
            // Get Node values from XML.
            string expectedSeq = _utilityObj._xmlUtil.GetTextValue(Constants.TranslationNode,
                                                                   sequenceNode);
            string expectedAminoAcid = _utilityObj._xmlUtil.GetTextValue(Constants.TranslationNode,
                                                                         aminoAcidNode);
            string expectedOffset = _utilityObj._xmlUtil.GetTextValue(Constants.CodonsNode, offsetNode);

            // Translate Rna to corresponding amino acid.
            ISequence codonsTranslation = new Sequence(Alphabets.RNA, expectedSeq);
            AminoAcid aminoAcid         = Codons.Lookup(codonsTranslation, int.Parse(expectedOffset, null));

            // Validate Codon Translation.
            Assert.AreEqual(expectedAminoAcid.ToString((IFormatProvider)null), aminoAcid.Symbol.ToString((IFormatProvider)null));
            ApplicationLog.WriteLine(
                "Translation P1: Codon translation with offset validation is completed successfully.");
        }
Пример #21
0
        //UPGRADE_NOTE: Final was removed from the declaration of '//logger '. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1003'"
        //UPGRADE_NOTE: The initialization of  '//logger' was moved to static method 'org.openscience.cdk.templates.AminoAcids'. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1005'"
        //private static readonly LoggingTool //logger;

        /// <summary> Creates matrix with info about the bonds in the amino acids.
        /// 0 = bond id, 1 = atom1 in bond, 2 = atom2 in bond, 3 = bond order.
        /// </summary>
        /// <returns> info
        /// </returns>
        public static int[][] aaBondInfo()
        {
            if (aminoAcids == null)
            {
                createAAs();
            }

            int[][] info = new int[153][];
            for (int i = 0; i < 153; i++)
            {
                info[i] = new int[4];
            }

            int counter = 0;
            int total   = 0;

            for (int aa = 0; aa < aminoAcids.Length; aa++)
            {
                AminoAcid acid  = aminoAcids[aa];
                IBond[]   bonds = acid.Bonds;
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                //logger.debug("#bonds for ", acid.getProperty(RESIDUE_NAME).ToString(), " = " + bonds.Length);
                total += bonds.Length;
                //logger.debug("total #bonds: ", total);
                for (int bCounter = 0; bCounter < bonds.Length; bCounter++)
                {
                    info[counter][0] = counter;
                    info[counter][1] = acid.getAtomNumber(bonds[bCounter].getAtomAt(0));
                    info[counter][2] = acid.getAtomNumber(bonds[bCounter].getAtomAt(1));
                    //UPGRADE_WARNING: Data types in Visual C# might be different.  Verify the accuracy of narrowing conversions. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1042'"
                    info[counter][3] = (int)bonds[bCounter].Order;
                    counter++;
                }
            }

            if (counter > 153)
            {
                //logger.error("Error while creating AA info! Bond count is too large: ", counter);
                return(null);
            }

            return(info);
        }
Пример #22
0
        public void WriteModification(IMass modification, ModificationSites sites, bool fixedModification = true)
        {
            if (CurrentStage != Stage.SearchSummary)
            {
                throw new ArgumentException("You must be in the Search Summary stage to write modifications");
            }

            foreach (ModificationSites singleSite in sites.GetActiveSites())
            {
                double basemass = 0;
                if (singleSite >= ModificationSites.NPep)
                {
                    _writer.WriteStartElement("terminal_modification");
                    if (singleSite.HasFlag(ModificationSites.NPep) || singleSite.HasFlag(ModificationSites.NProt))
                    {
                        _writer.WriteAttributeString("terminus", "N");
                        basemass += AminoAcidPolymer.DefaultNTerminus.MonoisotopicMass;
                    }
                    else
                    {
                        _writer.WriteAttributeString("terminus", "C");
                        basemass += AminoAcidPolymer.DefaultCTerminus.MonoisotopicMass;
                    }

                    _writer.WriteAttributeString("protein_terminus", (singleSite.HasFlag(ModificationSites.NProt) || singleSite.HasFlag(ModificationSites.ProtC)) ? "Y" : "N");
                }
                else
                {
                    string    letter = Enum.GetName(typeof(ModificationSites), singleSite);
                    AminoAcid aa     = AminoAcid.GetResidue(letter);
                    _writer.WriteStartElement("aminoacid_modification");
                    _writer.WriteAttributeString("aminoacid", letter);
                    basemass += aa.MonoisotopicMass;
                }
                double massshift = modification.MonoisotopicMass;
                _writer.WriteAttributeString("variable", (fixedModification) ? "N" : "Y");
                _writer.WriteAttributeString("mass", (basemass + massshift).ToString());
                _writer.WriteAttributeString("massdiff", massshift.ToString());
                _writer.WriteAttributeString("description", modification.ToString());
                _writer.WriteEndElement();
            }
        }
Пример #23
0
        private void Validate()
        {
            TransitionFilter.ValidateCharges(Resources.TransitionFilter_ProductCharges_Product_ion_charges, new[] { Charge },
                                             Transition.MIN_PRODUCT_CHARGE, Transition.MAX_PRODUCT_CHARGE);

            if (IsFragment)
            {
                if (string.IsNullOrEmpty(Fragment))
                {
                    throw new InvalidDataException(Resources.MeasuredIon_Validate_Special_fragment_ions_must_have_at_least_one_fragmentation_residue);
                }
                AminoAcid.ValidateAAList(Fragment);
                if (!string.IsNullOrEmpty(Restrict))
                {
                    AminoAcid.ValidateAAList(Restrict);
                }
                if (!Terminus.HasValue)
                {
                    throw new InvalidDataException(Resources.MeasuredIon_Validate_Special_fragment_ions_must_specify_the_terminal_side_of_the_amino_acid_residue_on_which_fragmentation_occurs);
                }
                if (MIN_MIN_FRAGMENT_LENGTH > MinFragmentLength || MinFragmentLength > MAX_MIN_FRAGMENT_LENGTH)
                {
                    throw new InvalidDataException(string.Format(Resources.MeasuredIon_Validate_The_minimum_length__0__must_be_between__1__and__2__,
                                                                 MinFragmentLength, MIN_MIN_FRAGMENT_LENGTH, MAX_MIN_FRAGMENT_LENGTH));
                }
            }
            else
            {
                if (SettingsCustomIon.MonoisotopicMass == 0 || SettingsCustomIon.AverageMass == 0)
                {
                    throw new InvalidDataException(Resources.MeasuredIon_Validate_Reporter_ions_must_specify_a_formula_or_valid_monoisotopic_and_average_masses);
                }
                if (SettingsCustomIon.MonoisotopicMass < MIN_REPORTER_MASS || SettingsCustomIon.AverageMass < MIN_REPORTER_MASS)
                {
                    throw new InvalidDataException(string.Format(Resources.MeasuredIon_Validate_Reporter_ion_masses_must_be_greater_than_or_equal_to__0__, MIN_REPORTER_MASS));
                }
                if (SettingsCustomIon.MonoisotopicMass > MAX_REPORTER_MASS || SettingsCustomIon.AverageMass > MAX_REPORTER_MASS)
                {
                    throw new InvalidDataException(string.Format(Resources.MeasuredIon_Validate_Reporter_ion_masses_must_be_less_than_or_equal_to__0__, MAX_REPORTER_MASS));
                }
            }
        }
Пример #24
0
 public static void WriteSearchEngineParams(string msmName, SilacLabel[] labels, bool addLabels, bool variableMods,
                                            SearchEngineParams msh, string titleSuffix)
 {
     if (addLabels)
     {
         for (int i = 0; i < labels.Length; i++)
         {
             if (variableMods)
             {
                 msh.AddVariabeModification(AminoAcid.GetMascotModificationStringForLabel(labels[i]));
             }
             else
             {
                 msh.AddFixedModification(AminoAcid.GetMascotModificationStringForLabel(labels[i]));
             }
         }
     }
     msh.Title += titleSuffix;
     msh.Write(msmName.Substring(0, msmName.Length - 4) + ".par");
 }
Пример #25
0
            public double GetFragmentScore(Composition prefixFragmentComposition, Composition suffixFragmentComposition,
                                           AminoAcid nTerminalResidue = null,
                                           AminoAcid cTerminalResidue = null)
            {
                var score = 0.0;

                var prefixMass = prefixFragmentComposition.Mass + _prefixOffsetMass;

                if (_ionMassBins.Contains(GetBinNumber(prefixMass)))
                {
                    score += 1;
                }

                var suffixMass = suffixFragmentComposition.Mass + _suffixOffsetMass;

                if (_ionMassBins.Contains(GetBinNumber(suffixMass)))
                {
                    score += 1;
                }
                return(score);
            }
Пример #26
0
 private void Validate()
 {
     if (string.IsNullOrEmpty(CleavageC) && string.IsNullOrEmpty(CleavageN))
     {
         throw new InvalidDataException(Resources.Enzyme_Validate_Enzymes_must_have_at_least_one_cleavage_point);
     }
     if (string.IsNullOrEmpty(CleavageC))
     {
         if (!string.IsNullOrEmpty(RestrictC))
         {
             throw new InvalidDataException(Resources.Enzyme_Validate_Enzyme_must_have_C_terminal_cleavage_to_have_C_terminal_restrictions_);
         }
         CleavageC = RestrictC = null;
     }
     else
     {
         AminoAcid.ValidateAAList(CleavageC);
         if (!string.IsNullOrEmpty(RestrictC))
         {
             AminoAcid.ValidateAAList(RestrictC);
         }
     }
     if (string.IsNullOrEmpty(CleavageN))
     {
         if (!string.IsNullOrEmpty(RestrictN))
         {
             throw new InvalidDataException(Resources.Enzyme_Validate_Enzyme_must_have_N_terminal_cleavage_to_have_N_terminal_restrictions_);
         }
         CleavageN = RestrictN = null;
     }
     else
     {
         AminoAcid.ValidateAAList(CleavageN);
         if (!string.IsNullOrEmpty(RestrictN))
         {
             AminoAcid.ValidateAAList(RestrictN);
         }
     }
 }
Пример #27
0
        /// <summary>
        /// Gets the score at sequence cleavage summed for all ions that were selected during training.
        /// </summary>
        /// <param name="nTerminalFragmentComposition">Composition of NTerminal sequence cleavage.</param>
        /// <param name="cTerminalFragmentComposition">Composition of CTerminal sequence cleavage.</param>
        /// <param name="nTerminalResidue">Residue at NTerminal sequence cleavage.</param>
        /// <param name="cTerminalResidue">Residue at CTerminal sequence cleavage.</param>
        /// <returns>The summed score of all ions.</returns>
        public double GetFragmentScore(
            Composition nTerminalFragmentComposition,
            Composition cTerminalFragmentComposition,
            AminoAcid nTerminalResidue = null,
            AminoAcid cTerminalResidue = null)
        {
            double score = this.scoringParameters.FeatureWeights.Intercept;

            foreach (BaseIonType ionType in this.scoringParameters.SelectedIonTypes)
            {
                FeatureWeights            featureVector      = this.scoringParameters.FeatureWeights;
                Composition               composition        = ionType.IsPrefix ? nTerminalFragmentComposition : cTerminalFragmentComposition;
                AminoAcid                 residue            = ionType.IsPrefix ? nTerminalResidue : cTerminalResidue;
                IEnumerable <Composition> offsetCompositions = ionType.GetPossibleCompositions(residue);

                double ionScore = 0.0;
                foreach (Composition offsetComp in offsetCompositions)  // Iterate over possible compositions for the current base ion type
                {
                    var ionComp = composition + offsetComp;
                    var peak    = this.ProductSpectrum.FindPeak(ionComp, this.scoringParameters.TrainerTolerance);
                    if (peak == null)
                    {
                        continue;
                    }

                    // Use only the score of the best scoring composition option (we have all the beset scoring compositions!)
                    var compScore = featureVector.GetMatchedIonPeakScoreWithError(ionType, peak, ionComp.Mass);
                    if (compScore > ionScore)
                    {
                        ionScore = compScore;
                    }
                }

                score += ionScore;
            }

            return(score);
        }
Пример #28
0
        public void ValidateLookupWithZeroOffset()
        {
            string alphabetName = Utility._xmlUtil.GetTextValue(Constants.SimpleRnaAlphabetNode,
                                                                Constants.AlphabetNameNode);
            string expectedSeq = Utility._xmlUtil.GetTextValue(Constants.CodonsNode,
                                                               Constants.SequenceWithmoreThanTweleveChars);
            string expectedAminoAcid = Utility._xmlUtil.GetTextValue(Constants.CodonsNode,
                                                                     Constants.OffsetOneMoreThanTwelveCharsAminoAcid);
            string expectedOffset = Utility._xmlUtil.GetTextValue(Constants.CodonsNode,
                                                                  Constants.OffsetVaule4);

            ISequence seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Validate Codons lookup method.
            AminoAcid aminoAcid = Codons.Lookup(seq, Convert.ToInt32(expectedOffset, null));

            // Validate amino acids for a given sequence.
            Assert.AreEqual(aminoAcid.Name.ToString(), expectedAminoAcid);
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Translation P2: Amino Acid {0} is expected.", aminoAcid));
            ApplicationLog.WriteLine(
                "Translation P2: Amino Acid validation for a given sequence was completed successfully.");
        }
Пример #29
0
        public void ValidateLookupWithOffsetValueSix()
        {
            string alphabetName = _utilityObj._xmlUtil.GetTextValue(
                Constants.SimpleRnaAlphabetNode, Constants.AlphabetNameNode);
            string expectedSeq = _utilityObj._xmlUtil.GetTextValue(
                Constants.CodonsNode, Constants.ExpectedNormalString);
            string expectedAminoAcid = _utilityObj._xmlUtil.GetTextValue(
                Constants.CodonsNode, Constants.OffsetZeroSixCharsAminoAcid);
            string expectedOffset = _utilityObj._xmlUtil.GetTextValue(
                Constants.CodonsNode, Constants.OffsetVaule2);

            ISequence seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Validate Codons lookup method.
            AminoAcid aminoAcid = Codons.Lookup(seq, Convert.ToInt32(expectedOffset, null));

            // Validate amino acids for a given sequence.
            Assert.AreEqual(aminoAcid.Name.ToString((IFormatProvider)null), expectedAminoAcid);
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Translation P1: Amino Acid {0} is expected.", aminoAcid));
            ApplicationLog.WriteLine(
                "Translation P1: Amino Acid validation for a given sequence was completed successfully.");
        }
Пример #30
0
        public void ValidateAminoAcid()
        {
            // Get Node values from XML.
            string expectedNucleo = Utility._xmlUtil.GetTextValue(
                Constants.CodonsNode, Constants.Nucleotide);
            string expectedAminoAcid = Utility._xmlUtil.GetTextValue(
                Constants.CodonsNode, Constants.AminoAcid);

            // Create Nucleotide objects.
            Nucleotide firstNucleo1 = new Nucleotide(expectedNucleo[0], "Uracil");
            Nucleotide firstNucleo2 = new Nucleotide(expectedNucleo[1], "Uracil");
            Nucleotide firstNucleo3 = new Nucleotide(expectedNucleo[2], "Uracil");

            // Validate Codons lookup method.
            AminoAcid aminoAcid = Codons.Lookup(firstNucleo1, firstNucleo2, firstNucleo3);

            // Validate amino acids for each triplet.
            Assert.AreEqual(aminoAcid.Name.ToString(), expectedAminoAcid);
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Translation BVT: Amino Acid {0} is expected.", aminoAcid));
            ApplicationLog.WriteLine(
                "Translation BVT: Amino Acid validation for a given triplets of nucleotide was completed successfully.");
        }
Пример #31
0
 private double GetScore( PSSMposition pos, AminoAcid aa )
 {
     foreach( PSSMentry entry in pos.entries ) {
     if( entry.condition.Length == 1 ) {
         if( entry.condition.CompareTo(aa.Letter.ToString())==0 )
             return entry.score;
         else
             continue;
     }
     switch( entry.condition.ToLower() ) {
         case "acidic":
             if( aa.Acidic ) return entry.score;
             break;
         case "basic":
             if( aa.Basic ) return entry.score;
             break;
         case "hydrophobic":
             if( aa.Hydrophobic ) return entry.score;
             break;
         case "polar":
             if( aa.Polar ) return entry.score;
             break;
         case "charge":
             if( aa.Charge != 0 ) return entry.score;
             break;
         case "positive":
             if( aa.Positive ) return entry.score;
             break;
         case "negative":
             if( aa.Negative ) return entry.score;
             break;
         case "aromatic":
             if( aa.Aromatic ) return entry.score;
             break;
         case "aliphatic":
             if( aa.Aliphatic ) return entry.score;
             break;
         default:
             throw new ApplicationException( "Undefined PSSM condition: " + entry.condition );
     }
     }
     return 0.0;
 }
Пример #32
0
        /// <summary> Creates amino acid AminoAcid objects.
        /// 
        /// </summary>
        /// <returns> aminoAcids, a HashMap containing the amino acids as AminoAcids.
        /// </returns>
        public static AminoAcid[] createAAs()
        {
            if (aminoAcids != null)
            {
                return aminoAcids;
            }

            // Create set of AtomContainers
            aminoAcids = new AminoAcid[20];

            IChemFile list = new ChemFile();
            //UPGRADE_ISSUE: Method 'java.lang.ClassLoader.getResourceAsStream' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangClassLoader'"
            //UPGRADE_ISSUE: Method 'java.lang.Class.getClassLoader' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangClassgetClassLoader'"
            CMLReader reader = new CMLReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("NuGenCDKSharp." + "list_aminoacids.cml"));//typeof(AminoAcids).getClassLoader().getResourceAsStream("data/templates/list_aminoacids.cml"));
            try
            {
                list = (IChemFile)reader.read(list);
                IAtomContainer[] containers = ChemFileManipulator.getAllAtomContainers(list);
                for (int i = 0; i < containers.Length; i++)
                {
                    //logger.debug("Adding AA: ", containers[i]);
                    // convert into an AminoAcid
                    AminoAcid aminoAcid = new AminoAcid();
                    IAtom[] atoms = containers[i].Atoms;
                    System.Collections.IEnumerator props = containers[i].Properties.Keys.GetEnumerator();
                    //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'"
                    while (props.MoveNext())
                    {
                        //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'"
                        System.Object next = props.Current;
                        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                        //logger.debug("Prop class: " + next.GetType().FullName);
                        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                        //logger.debug("Prop: " + next.ToString());
                        if (next is DictRef)
                        {
                            DictRef dictRef = (DictRef)next;
                            // System.out.println("DictRef type: " + dictRef.getType());
                            if (dictRef.Type.Equals("pdb:residueName"))
                            {
                                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                                aminoAcid.setProperty(RESIDUE_NAME, containers[i].getProperty(dictRef).ToString().ToUpper());
                            }
                            else if (dictRef.Type.Equals("pdb:oneLetterCode"))
                            {
                                aminoAcid.setProperty(RESIDUE_NAME_SHORT, containers[i].getProperty(dictRef));
                            }
                            else if (dictRef.Type.Equals("pdb:id"))
                            {
                                aminoAcid.setProperty(ID, containers[i].getProperty(dictRef));
                                //logger.debug("Set AA ID to: ", containers[i].getProperty(dictRef));
                            }
                            else
                            {
                                //logger.error("Cannot deal with dictRef!");
                            }
                        }
                    }
                    for (int atomCount = 0; atomCount < atoms.Length; atomCount++)
                    {
                        IAtom atom = atoms[atomCount];
                        System.String dictRef = (System.String)atom.getProperty("org.openscience.cdk.dict");
                        if (dictRef != null && dictRef.Equals("pdb:nTerminus"))
                        {
                            aminoAcid.addNTerminus(atom);
                        }
                        else if (dictRef != null && dictRef.Equals("pdb:cTerminus"))
                        {
                            aminoAcid.addCTerminus(atom);
                        }
                        else
                        {
                            aminoAcid.addAtom(atom);
                        }
                    }
                    IBond[] bonds = containers[i].Bonds;
                    for (int bondCount = 0; bondCount < bonds.Length; bondCount++)
                    {
                        aminoAcid.addBond(bonds[bondCount]);
                    }
                    AminoAcidManipulator.removeAcidicOxygen(aminoAcid);
                    aminoAcid.setProperty(NO_ATOMS, "" + aminoAcid.AtomCount);
                    aminoAcid.setProperty(NO_BONDS, "" + aminoAcid.getBondCount());
                    if (i < aminoAcids.Length)
                    {
                        aminoAcids[i] = aminoAcid;
                    }
                    else
                    {
                        //logger.error("Could not store AminoAcid! Array too short!");
                    }
                }
            }
            catch (System.Exception exception)
            {
                //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                //logger.error("Failed reading file: ", exception.Message);
                //logger.debug(exception);
            }

            return aminoAcids;
        }
Пример #33
0
 static void Add(NucleotidRna _1, NucleotidRna _2, NucleotidRna _3, AminoAcid acid)
 {
     var code = GetHashCode(_1, _2, _3);
      _translationTable.Add(code, acid);
 }
Пример #34
0
 public static char ToChar(AminoAcid aminoAcid)
 {
     switch (aminoAcid)
      {
     case AminoAcid.G:
        return 'G';
     case AminoAcid.A:
        return 'A';
     case AminoAcid.V:
        return 'V';
     case AminoAcid.L:
        return 'L';
     case AminoAcid.I:
        return 'I';
     case AminoAcid.P:
        return 'P';
     case AminoAcid.F:
        return 'F';
     case AminoAcid.Y:
        return 'Y';
     case AminoAcid.W:
        return 'W';
     case AminoAcid.S:
        return 'S';
     case AminoAcid.T:
        return 'T';
     case AminoAcid.D:
        return 'D';
     case AminoAcid.E:
        return 'E';
     case AminoAcid.N:
        return 'N';
     case AminoAcid.Q:
        return 'Q';
     case AminoAcid.C:
        return 'C';
     case AminoAcid.M:
        return 'M';
     case AminoAcid.H:
        return 'H';
     case AminoAcid.K:
        return 'K';
     case AminoAcid.R:
        return 'R';
     case AminoAcid.Stop:
        return '*';
     default:
        throw new ArgumentOutOfRangeException("aminoAcid");
      }
 }