コード例 #1
0
 public void Output(List<IonTypePeak> pkl, IonType ionType)
 {
   Console.WriteLine("Assert.AreEqual({0}, pkl.Count);", pkl.Count);
   for (int i = 0; i < pkl.Count; i++)
   {
     Console.WriteLine(MyConvert.Format("AssertPeak(pkl[{0}], IonType.{1}, {2}, {3:0.0000});", i, ionType.ToString(), i + 1, pkl[i].Mz));      
   }
 }
コード例 #2
0
ファイル: Transition.cs プロジェクト: lgatto/proteowizard
 public static bool IsPrecursor(IonType type)
 {
     return type == IonType.precursor;
 }
コード例 #3
0
ファイル: Sequence.cs プロジェクト: lgatto/proteowizard
 public static bool IsNTerminal(IonType type)
 {
     return type == IonType.A || type == IonType.B || type == IonType.C;
 }
コード例 #4
0
ファイル: TransitionCalc.cs プロジェクト: lgatto/proteowizard
        public static int CalcProductCharge(double productPrecursorMass,
            int precursorCharge,
            double[,] productMasses,
            IList<IList<ExplicitLoss>> potentialLosses,
            double productMz,
            double tolerance,
            MassType massType,
            MassShiftType massShiftType,
            out IonType? ionType,
            out int? ordinal,
            out TransitionLosses losses,
            out int massShift)
        {
            // Get length of fragment ion mass array
            int len = productMasses.GetLength(1);

            // Check all possible ion types and offsets
            double minDelta = double.MaxValue, minDeltaNs = double.MaxValue;
            int bestCharge = 0, bestChargeNs = 0;
            IonType? bestIonType = null, bestIonTypeNs = null;
            int? bestOrdinal = null, bestOrdinalNs = null;
            TransitionLosses bestLosses = null, bestLossesNs = null;
            int bestMassShift = 0;

            // Check to see if it is the precursor
            foreach (var lossesTrial in TransitionGroup.CalcTransitionLosses(IonType.precursor, 0, massType, potentialLosses))
            {
                double productMass = productPrecursorMass - (lossesTrial != null ? lossesTrial.Mass : 0);
                int potentialMassShift;
                int nearestCharge;
                int? charge = CalcProductCharge(productMass, productMz, tolerance, false, precursorCharge,
                                               massShiftType, out potentialMassShift, out nearestCharge);
                if (charge.HasValue && charge.Value == precursorCharge)
                {
                    double potentialMz = SequenceMassCalc.GetMZ(productMass, charge.Value) + potentialMassShift;
                    double delta = Math.Abs(productMz - potentialMz);

                    if (potentialMassShift == 0 && minDeltaNs > delta)
                    {
                        bestChargeNs = charge.Value;
                        bestIonTypeNs = IonType.precursor;
                        bestOrdinalNs = len + 1;
                        bestLossesNs = lossesTrial;

                        minDeltaNs = delta;
                    }
                    else if (potentialMassShift != 0 && minDelta > delta)
                    {
                        bestCharge = charge.Value;
                        bestIonType = IonType.precursor;
                        bestOrdinal = len + 1;
                        bestLosses = lossesTrial;
                        bestMassShift = potentialMassShift;

                        minDelta = delta;
                    }
                }
            }

            foreach (IonType type in Transition.ALL_TYPES)
            {
                // Types have priorities.  If moving to a lower priority type, and there is already a
                // suitable answer stop looking.
                if ((type == Transition.ALL_TYPES[2] || type == Transition.ALL_TYPES[2]) &&
                        (MatchMz(minDelta, tolerance) || MatchMz(minDeltaNs, tolerance)))
                    break;

                for (int offset = 0; offset < len; offset++)
                {
                    foreach (var lossesTrial in TransitionGroup.CalcTransitionLosses(type, offset, massType, potentialLosses))
                    {
                        // Look for the closest match.
                        double productMass = productMasses[(int) type, offset];
                        if (lossesTrial != null)
                            productMass -= lossesTrial.Mass;
                        int potentialMassShift;
                        int nearestCharge;
                        int? chargeFound = CalcProductCharge(productMass, productMz, tolerance, false, precursorCharge,
                                                       massShiftType, out potentialMassShift, out nearestCharge);
                        if (chargeFound.HasValue)
                        {
                            int charge = chargeFound.Value;
                            double potentialMz = SequenceMassCalc.GetMZ(productMass, charge) + potentialMassShift;
                            double delta = Math.Abs(productMz - potentialMz);
                            if (potentialMassShift == 0 && minDeltaNs > delta)
                            {
                                bestChargeNs = charge;
                                bestIonTypeNs = type;
                                // The peptide length is 1 longer than the mass array
                                bestOrdinalNs = Transition.OffsetToOrdinal(type, offset, len + 1);
                                bestLossesNs = lossesTrial;

                                minDeltaNs = delta;
                            }
                            else if (potentialMassShift != 0 && minDelta > delta)
                            {
                                bestCharge = charge;
                                bestIonType = type;
                                // The peptide length is 1 longer than the mass array
                                bestOrdinal = Transition.OffsetToOrdinal(type, offset, len + 1);
                                bestLosses = lossesTrial;
                                bestMassShift = potentialMassShift;

                                minDelta = delta;
                            }
                        }
                    }
                }
            }

            // Pefer no-shift to shift, even if the shift value is closer
            if (MatchMz(minDelta, tolerance) && !MatchMz(minDeltaNs, tolerance))
            {
                ionType = bestIonType;
                ordinal = bestOrdinal;
                losses = bestLosses;
                massShift = bestMassShift;
                return bestCharge;
            }

            ionType = bestIonTypeNs;
            ordinal = bestOrdinalNs;
            losses = bestLossesNs;
            massShift = 0;
            return bestChargeNs;
        }
コード例 #5
0
ファイル: Sequence.cs プロジェクト: lgatto/proteowizard
        public FragmentIon(PepV01 peptide, IonType type, int offset, double mh)
        {
            _peptide = peptide;

            IType = type;
            CleavageOffset = offset;
            MassH = mh;

            // Derived values
            if (IsNTerminal())
            {
                Ordinal = offset + 1;
                AA = peptide.Sequence[offset];
            }
            else
            {
                Ordinal = _peptide.Length - offset - 1;
                AA = peptide.Sequence[offset + 1];
            }
        }
コード例 #6
0
ファイル: SequenceUtil.cs プロジェクト: lgatto/proteowizard
 private double GetTermDeltaMass(IonType type)
 {
     switch (type)
     {
         case IonType.a: return _massDiffA - _massDiffB;
         case IonType.b: return 0;
         case IonType.c: return _massDiffC - _massDiffB;
         case IonType.x: return _massDiffX - _massDiffY;
         case IonType.y: return 0;
         case IonType.z: return _massDiffZ - _massDiffY;
         default:
             throw new ArgumentException("Invalid ion type"); // Not L10N
     }
 }
コード例 #7
0
ファイル: SequenceUtil.cs プロジェクト: lgatto/proteowizard
        private double GetFragmentMass(string seq,
                                       IonType type,
                                       int ordinal,
                                       int? decoyMassShift,
                                       int massIndex,
                                       IsotopeDistInfo isotopeDists,
                                       ExplicitSequenceMods mods)
        {
            if (Transition.IsPrecursor(type))
            {
                if (isotopeDists != null)
                {
                    int i = isotopeDists.MassIndexToPeakIndex(massIndex);
                    if (0 > i || i >= isotopeDists.CountPeaks)
                    {
                        throw new IndexOutOfRangeException(
                            string.Format(Resources.SequenceMassCalc_GetFragmentMass_Precursor_isotope__0__is_outside_the_isotope_distribution__1__to__2__,
                                          GetMassIDescripion(massIndex), isotopeDists.PeakIndexToMassIndex(0),
                                          isotopeDists.PeakIndexToMassIndex(isotopeDists.CountPeaks - 1)));
                    }
                    return isotopeDists.GetMassI(massIndex, decoyMassShift);
                }
                return GetPrecursorMass(seq, mods);                
            }

            int len = seq.Length - 1;

            bool nterm = Transition.IsNTerminal(type);
            double mass = GetTermMass(nterm ? IonType.b : IonType.y, mods) + BioMassCalc.MassProton;

            int iA = (nterm ? 0 : len);
            int inc = (nterm ? 1 : -1);

            var modMasses = GetModMasses(mods);

            mass += (nterm ? modMasses._aminoNTermModMasses[seq[iA]] : modMasses._aminoCTermModMasses[seq[iA]]);

            for (int i = 0; i < ordinal; i++)
            {
                char aa = seq[iA];
                mass += _aminoMasses[aa] + modMasses._aminoModMasses[aa];
                if (mods != null && iA < mods.ModMasses.Count)
                    mass += mods.ModMasses[iA];
                iA += inc;
            }

            mass += GetTermDeltaMass(type);    // Exactly match GetFragmentIonMasses()

            return mass;
        }
コード例 #8
0
 private string GetLabel(IonType type, int ordinal, TransitionLosses losses, int charge, double mz, int rank, bool showMz)
 {
     var label = new StringBuilder(type.GetLocalizedString());
     if (!Transition.IsPrecursor(type))
         label.Append(ordinal.ToString(LocalizationHelper.CurrentCulture));
     if (losses != null)
     {
         label.Append(" -"); // Not L10N
         label.Append(Math.Round(losses.Mass, 1));
     }
     string chargeIndicator = (charge == 1 ? string.Empty : Transition.GetChargeIndicator(charge));
     label.Append(chargeIndicator);
     if (showMz)
         label.Append(string.Format(" = {0:F01}", mz)); // Not L10N
     if (rank > 0 && ShowRanks)
         label.Append(TextUtil.SEPARATOR_SPACE).Append(string.Format("({0})",string.Format(Resources.AbstractSpectrumGraphItem_GetLabel_rank__0__, rank))); // Not L10N
     return label.ToString();
 }
コード例 #9
0
 private bool IsVisibleIon(IonType type, int ordinal, int charge)
 {
     // Show precursor ions when they are supposed to be shown, regardless of charge
     return ordinal > 0 && ShowTypes.Contains(type) && (type == IonType.precursor || ShowCharges.Contains(charge));
 }
コード例 #10
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
 public TransitionKey(TransitionGroupDocNode nodeGroup, TransitionLossKey tranLossKey, IsotopeLabelType labelType)
 {
     var transition = tranLossKey.Transition;
     _ionType = transition.IonType;
     _customIonEquivalenceTestValue = tranLossKey.CustomIonEquivalenceTestValue;
     _ionOrdinal = transition.Ordinal;
     _massIndex = transition.MassIndex;
     _decoyMassShift = transition.DecoyMassShift;
     _charge = transition.Charge;
     _precursorCharge = nodeGroup.TransitionGroup.PrecursorCharge;
     _losses = tranLossKey.Losses;
     _labelType = labelType;
 }
コード例 #11
0
ファイル: PeptideDocNode.cs プロジェクト: lgatto/proteowizard
 public TransitionKey(TransitionKey key, IsotopeLabelType labelType)
 {
     _ionType = key._ionType;
     _customIonEquivalenceTestValue = key._customIonEquivalenceTestValue;
     _ionOrdinal = key._ionOrdinal;
     _massIndex = key._massIndex;
     _decoyMassShift = key._decoyMassShift;
     _charge = key._charge;
     _precursorCharge = key._precursorCharge;
     _losses = key._losses;
     _labelType = labelType;
 }
コード例 #12
0
        private static CellDesc CreateIon(IonType type, int ordinal, double massH, int charge,
            IEnumerable<DocNode> choices, ICollection<DocNode> chosen, Transition tranSelected,
            RenderTools rt)
        {
            double mz = SequenceMassCalc.GetMZ(massH, charge);
            CellDesc cell = CreateData(string.Format("{0:F02}", mz), rt); // Not L10N

            foreach (TransitionDocNode nodeTran in choices)
            {
                Transition tran = nodeTran.Transition;
                if (tran.IonType == type &&
                    tran.Ordinal == ordinal &&
                    tran.Charge == charge)
                {
                    cell.Font = rt.FontBold;
                    if (Equals(tran, tranSelected))
                    {
                        cell.Brush = rt.BrushSelected; // Stop after selected
                        break;
                    }
                    if (!chosen.Contains(nodeTran))
                        cell.Brush = rt.BrushChoice;  // Keep looking
                    else
                    {
                        cell.Brush = rt.BrushChosen;  // Stop after chosen
                        break;
                    }
                }
            }

            return cell;
        }
コード例 #13
0
ファイル: MeasuredIon.cs プロジェクト: lgatto/proteowizard
 public bool IsMatch(string sequence, IonType ionType, int cleavageOffset)
 {
     if (!IsFragment)
         return false;
     int ordinal = Transition.OffsetToOrdinal(ionType, cleavageOffset, sequence.Length);
     if (ordinal < MinFragmentLength)
         return false;
     char aaN = Transition.GetFragmentNTermAA(sequence, cleavageOffset);
     char aaC = Transition.GetFragmentCTermAA(sequence, cleavageOffset);
     // Make sure the specified amino acid is in the fragment set for this ion
     char aa = (IsNTerm() ? aaN : aaC);
     if (Fragment.IndexOf(aa) == -1)
         return false;
     // Make suer the adjacent amino acid is not in the restricted set for this ion
     aa = (IsNTerm() ? aaC : aaN);
     if (Restrict != null && Restrict.IndexOf(aa) != -1)
         return false;
     return true;
 }
コード例 #14
0
ファイル: Import.cs プロジェクト: lgatto/proteowizard
 public ProductExp(int productCharge, IonType ionType, int fragmentOrdinal, TransitionLosses losses, int massShift)
 {
     Charge = productCharge;
     IonType = ionType;
     FragmentOrdinal = fragmentOrdinal;
     Losses = losses;
     MassShift = null;
     if (massShift != 0)
         MassShift = massShift;
 }
コード例 #15
0
ファイル: Transition.cs プロジェクト: lgatto/proteowizard
 public static int OffsetToOrdinal(IonType type, int offset, int len)
 {
     if (IsNTerminal(type))
         return offset + 1;
     else
         return len - offset - 1;
 }
コード例 #16
0
ファイル: Transition.cs プロジェクト: lgatto/proteowizard
 public Transition(TransitionGroup group, IonType type, int offset, int massIndex, int charge)
     : this(group, type, offset, massIndex, charge, null)
 {
 }
コード例 #17
0
ファイル: Transition.cs プロジェクト: lgatto/proteowizard
 public static IonType GetEnum(string enumValue, IonType defaultValue)
 {
     return Helpers.EnumFromLocalizedString(enumValue, LOCALIZED_VALUES, defaultValue);
 }
コード例 #18
0
ファイル: Transition.cs プロジェクト: lgatto/proteowizard
 public Transition(TransitionGroup group, int charge, int? massIndex, CustomIon customIon, IonType type=IonType.custom)
     : this(group, type, null, massIndex, charge, null, customIon)
 {
 }
コード例 #19
0
ファイル: SequenceUtil.cs プロジェクト: lgatto/proteowizard
 public static IEnumerable<double> GetFragmentMasses(IonType type, double[,] masses)
 {
     int col = (int) type;
     int len = masses.GetLength(1);
     if (Transition.IsNTerminal(type))
     {
         for (int i = 0; i < len; i++)
             yield return masses[col, i];
     }
     else
     {
         for (int i = len - 1; i >= 0; i--)
             yield return masses[col, i];
     }
 }
コード例 #20
0
ファイル: Transition.cs プロジェクト: lgatto/proteowizard
        public Transition(TransitionGroup group, IonType type, int? offset, int? massIndex, int charge, int? decoyMassShift, CustomIon customIon = null)
        {
            _group = group;

            IonType = type;
            CleavageOffset = offset ?? 0;
            MassIndex = massIndex ?? 0;
            Charge = charge;
            DecoyMassShift = decoyMassShift;
            // Small molecule precursor transition should have same custom ion as parent
            if (IsPrecursor(type) && group.IsCustomIon)
                CustomIon = group.CustomIon;
            else
                CustomIon = customIon;
            // Derived values
            if (!IsCustom(type, group))
            {
                Peptide peptide = group.Peptide;
                Ordinal = OffsetToOrdinal(type, (int)offset, peptide.Length);
                AA = (IsNTerminal()
                    ? peptide.Sequence[(int)offset]
                    : peptide.Sequence[(int)offset + 1]);
            }
            else
            {
                // caller may have passed in offset = group.Peptide.Length - 1, which for custom ions gives -1
                CleavageOffset = 0;
            }
            Validate();
        }
コード例 #21
0
ファイル: SequenceUtil.cs プロジェクト: lgatto/proteowizard
        private double GetTermMass(IonType type, ExplicitSequenceMods mods)
        {
            var modMasses = GetModMasses(mods);

            switch (type)
            {
                case IonType.a: return _massDiffA + modMasses._massModCleaveN;
                case IonType.b: return _massDiffB + modMasses._massModCleaveN;
                case IonType.c: return _massDiffC + modMasses._massModCleaveN;
                case IonType.x: return _massDiffX + modMasses._massModCleaveC;
                case IonType.y: return _massDiffY + modMasses._massModCleaveC;
                case IonType.z: return _massDiffZ + modMasses._massModCleaveC;
                default:
                    throw new ArgumentException("Invalid ion type"); // Not L10N
            }
        }
コード例 #22
0
ファイル: Transition.cs プロジェクト: lgatto/proteowizard
 public static bool IsCTerminal(IonType type)
 {
     return type == IonType.x || type == IonType.y || type == IonType.z;
 }
コード例 #23
0
ファイル: SkylineGraphs.cs プロジェクト: lgatto/proteowizard
 private void CheckIonType(IonType type, bool check)
 {
     var set = Settings.Default;
     switch (type)
     {
         case IonType.a: set.ShowAIons = aMenuItem.Checked = check; break;
         case IonType.b: set.ShowBIons = bMenuItem.Checked = check; break;
         case IonType.c: set.ShowCIons = cMenuItem.Checked = check; break;
         case IonType.x: set.ShowXIons = xMenuItem.Checked = check; break;
         case IonType.y: set.ShowYIons = yMenuItem.Checked = check; break;
         case IonType.z: set.ShowZIons = zMenuItem.Checked = check; break;
     }
 }
コード例 #24
0
ファイル: Transition.cs プロジェクト: lgatto/proteowizard
 public static bool IsCustom(IonType type, TransitionGroup parent)
 {
     return type == IonType.custom || (type == IonType.precursor && parent.IsCustomIon);
 }
コード例 #25
0
ファイル: Sequence.cs プロジェクト: lgatto/proteowizard
 public static bool IsCTerminal(IonType type)
 {
     return type == IonType.X || type == IonType.Y || type == IonType.Z;
 }
コード例 #26
0
ファイル: Transition.cs プロジェクト: lgatto/proteowizard
 public static bool IsNTerminal(IonType type)
 {
     return type == IonType.a || type == IonType.b || type == IonType.c || type == IonType.precursor;
 }
コード例 #27
0
ファイル: Sequence.cs プロジェクト: lgatto/proteowizard
        public static int OrdinalToOffset(IonType type, int ordinal, int len)
        {
            if (IsNTerminal(type))
                return ordinal - 1;

            return len - ordinal - 1;
        }
コード例 #28
0
 public void AssertPeak(IonTypePeak peak, IonType ionType, int ionIndex, double mz)
 {
   Assert.AreEqual(ionType, peak.PeakType);
   Assert.AreEqual(ionIndex, peak.PeakIndex);
   Assert.AreEqual(mz, peak.Mz, 0.0001);
 }