Esempio n. 1
0
 private ExplicitTransitionGroupValues(double?explicitIonMobility,
                                       eIonMobilityUnits explicitIonMobilityUnits,
                                       double?explicitCollisionalCrossSectionSqA)
 {
     IonMobility                = explicitIonMobility;
     IonMobilityUnits           = explicitIonMobilityUnits;
     CollisionalCrossSectionSqA = explicitCollisionalCrossSectionSqA;
 }
 public ValidatingIonMobilityPrecursor(Target seq,
                                       Adduct precursorAdduct,
                                       double collisionalCrossSection,
                                       double ionMobility,
                                       double highEnergyIonMobilityOffset,
                                       eIonMobilityUnits units)
     : base(new DbPrecursorIon(seq, precursorAdduct), collisionalCrossSection, ionMobility, units, highEnergyIonMobilityOffset)
 {
 }
Esempio n. 3
0
 public DbPrecursorAndIonMobility(DbPrecursorIon precursor, double?collisionalCrossSection, double?ionMobility, eIonMobilityUnits units,
                                  double?highEnergyOffset)
 {
     DbPrecursorIon             = precursor;
     CollisionalCrossSectionSqA = collisionalCrossSection ?? 0;
     IonMobility                 = ionMobility ?? 0;
     IonMobilityUnits            = units;
     HighEnergyIonMobilityOffset = highEnergyOffset ?? 0;
 }
 public ValidatingIonMobilityPrecursor(SmallMoleculeLibraryAttributes smallMoleculeLibraryAttributes,
                                       Adduct precursorAdduct,
                                       double collisionalCrossSection,
                                       double ionMobility,
                                       double highEnergyIonMobilityOffset,
                                       eIonMobilityUnits units)
     : base(new DbPrecursorIon(new Target(smallMoleculeLibraryAttributes), precursorAdduct),
            collisionalCrossSection, ionMobility, units, highEnergyIonMobilityOffset)
 {
 }
 // Single conformer ctor
 public PrecursorIonMobilities(SmallMoleculeLibraryAttributes smallMoleculeLibraryAttributes,
                               Adduct precursorAdduct,
                               double collisionalCrossSection,
                               double ionMobility,
                               double highEnergyIonMobilityOffset,
                               eIonMobilityUnits units)
     : this(new LibKey(new Target(smallMoleculeLibraryAttributes), precursorAdduct),
            IonMobilityAndCCS.GetIonMobilityAndCCS(ionMobility, units, collisionalCrossSection, highEnergyIonMobilityOffset))
 {
 }
 // Single conformer ctor
 public PrecursorIonMobilities(Target seq,
                               Adduct precursorAdduct,
                               double collisionalCrossSection,
                               double ionMobility,
                               double highEnergyIonMobilityOffset,
                               eIonMobilityUnits units)
     : this(new LibKey(seq, precursorAdduct),
            IonMobilityAndCCS.GetIonMobilityAndCCS(ionMobility, units, collisionalCrossSection, highEnergyIonMobilityOffset))
 {
 }
Esempio n. 7
0
 public IonMobilityValue ChangeIonMobilityUnits(eIonMobilityUnits units)
 {
     if (Equals(units, Units))
     {
         return(this);
     }
     if (Equals(units, eIonMobilityUnits.none))
     {
         return(EMPTY);
     }
     return(ChangeProp(ImClone(this), im => im.Units = units));
 }
Esempio n. 8
0
        public static ExplicitTransitionGroupValues Create(double?explicitIonMobility,
                                                           eIonMobilityUnits explicitIonMobilityUnits,
                                                           double?explicitCollisionalCrossSectionSqA)
        {
            if (explicitIonMobility.HasValue || explicitCollisionalCrossSectionSqA.HasValue)
            {
                return(new ExplicitTransitionGroupValues(explicitIonMobility, explicitIonMobilityUnits,
                                                         explicitCollisionalCrossSectionSqA));
            }

            return(EMPTY);
        }
Esempio n. 9
0
        private void UpdateMeasuredDriftTimesControl(IonMobilityPredictor predictor)
        {
            // List any measured ion mobility values, taking care to show only those matching display units
            gridMeasuredDriftTimes.Rows.Clear();
            if (predictor == null)
            {
                return;
            }
            _predictor = (_predictor ?? IonMobilityPredictor.EMPTY).ChangeMeasuredIonMobilityValues(predictor.MeasuredMobilityIons);
            Units      = _predictor.GetIonMobilityUnits();
            var units = Units;

            if (predictor.MeasuredMobilityIons != null)
            {
                bool hasHighEnergyOffsets =
                    predictor.MeasuredMobilityIons.Any(p => p.Value.HighEnergyIonMobilityValueOffset != 0);
                cbOffsetHighEnergySpectra.Checked = hasHighEnergyOffsets;
                foreach (var p in predictor.MeasuredMobilityIons)
                {
                    var ccs = p.Value.CollisionalCrossSectionSqA.HasValue
                        ? string.Format(@"{0:F04}", p.Value.CollisionalCrossSectionSqA.Value)
                        : string.Empty;
                    var im                   = p.Value.IonMobility.Units == units ? p.Value.IonMobility.Mobility : null;
                    var imOffset             = p.Value.IonMobility.Units == units ? p.Value.HighEnergyIonMobilityValueOffset : 0;
                    var chargeOrAdductString = _smallMoleculeUI
                                ? p.Key.Adduct.AdductFormula
                                : p.Key.Charge.ToString(LocalizationHelper.CurrentCulture);
                    if (hasHighEnergyOffsets)
                    {
                        gridMeasuredDriftTimes.Rows.Add(p.Key.Target,
                                                        chargeOrAdductString,
                                                        im.HasValue ? im.Value.ToString(LocalizationHelper.CurrentCulture) : string.Empty,
                                                        ccs,
                                                        imOffset.ToString(LocalizationHelper.CurrentCulture)
                                                        );
                    }
                    else
                    {
                        gridMeasuredDriftTimes.Rows.Add(p.Key.Target,
                                                        chargeOrAdductString,
                                                        im.HasValue ? im.Value.ToString(LocalizationHelper.CurrentCulture) : string.Empty,
                                                        ccs
                                                        );
                    }
                }
            }
            else
            {
                cbOffsetHighEnergySpectra.Checked = false;
            }
        }
Esempio n. 10
0
        public static string GetUnitsString(eIonMobilityUnits units)
        {
            switch (units)
            {
            case eIonMobilityUnits.none:
                return(@"#N/A");

            case eIonMobilityUnits.drift_time_msec:
                return(@"msec");

            case eIonMobilityUnits.inverse_K0_Vsec_per_cm2:
                return(@"Vs/cm^2");

            case eIonMobilityUnits.compensation_V:
                return(@"V");
            }
            return(@"unknown ion mobility type");
        }
Esempio n. 11
0
 public ExplicitTransitionGroupValues(double?explicitCollisionEnergy,
                                      double?explicitIonMobility,
                                      double?explicitIonMobilityHighEnergyOffset,
                                      eIonMobilityUnits explicitIonMobilityUnits,
                                      double?explicitCollisionalCrossSectionSqA,
                                      double?explicitSLens,
                                      double?explicitConeVoltage,
                                      double?explicitDeclusteringPotential,
                                      double?explicitCompensationVoltage)
 {
     CollisionEnergy             = explicitCollisionEnergy;
     IonMobility                 = explicitIonMobility;
     IonMobilityHighEnergyOffset = explicitIonMobilityHighEnergyOffset;
     IonMobilityUnits            = explicitIonMobilityUnits;
     CollisionalCrossSectionSqA  = explicitCollisionalCrossSectionSqA;
     SLens                 = explicitSLens;
     ConeVoltage           = explicitConeVoltage;
     DeclusteringPotential = explicitDeclusteringPotential;
     CompensationVoltage   = explicitCompensationVoltage;
 }
Esempio n. 12
0
        public Dictionary <LibKey, IonMobilityAndCCS> GetTableMeasuredIonMobility(bool useHighEnergyOffsets, eIonMobilityUnits units)
        {
            var e    = new CancelEventArgs();
            var dict = new Dictionary <LibKey, IonMobilityAndCCS>();

            foreach (DataGridViewRow row in _gridMeasuredDriftTimePeptides.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }

                string seq;
                if (!ValidateSequence(e, row.Cells[EditDriftTimePredictorDlg.COLUMN_SEQUENCE], out seq))
                {
                    return(null);
                }

                // OK, we have a non-empty "sequence" string, but is that actually a peptide or a molecule?
                // See if there's anything in the document whose text representation matches what's in the list

                var target = _targetResolver.ResolveTarget(seq);
                if (target == null || target.IsEmpty)
                {
                    return(null);
                }

                Adduct charge;
                if (!ValidateCharge(e, row.Cells[EditDriftTimePredictorDlg.COLUMN_CHARGE], target.IsProteomic, out charge))
                {
                    return(null);
                }

                double mobility;
                if (!ValidateDriftTime(e, row.Cells[EditDriftTimePredictorDlg.COLUMN_ION_MOBILITY], out mobility))
                {
                    return(null);
                }

                double?ccs;
                if (!ValidateCCS(e, row.Cells[EditDriftTimePredictorDlg.COLUMN_CCS], out ccs))
                {
                    return(null);
                }

                double highEnergyOffset = 0; // Set default value in case user does not provide one
                if (useHighEnergyOffsets && !ValidateHighEnergyDriftTimeOffset(e, row.Cells[EditDriftTimePredictorDlg.COLUMN_HIGH_ENERGY_OFFSET], out highEnergyOffset))
                {
                    return(null);
                }
                var ionMobility = IonMobilityValue.GetIonMobilityValue(mobility, units);
                try
                {
                    dict.Add(new LibKey(target, charge), IonMobilityAndCCS.GetIonMobilityAndCCS(ionMobility, ccs, highEnergyOffset));
                }
                // ReSharper disable once EmptyGeneralCatchClause
                catch
                {
                    // just take the first seen
                }
            }
            return(dict);
        }
Esempio n. 13
0
        }                                            // This is private to force use of GetTransitionGroupIonMobilityInfo (for memory efficiency, as most uses are empty)

        // Serialization support
        public static TransitionGroupIonMobilityInfo GetTransitionGroupIonMobilityInfo(double?ccs, double?ionMobilityMS1,
                                                                                       double?ionMobilityFragment, double?ionMobilityWindow, eIonMobilityUnits units)
        {
            if (ccs.HasValue || ionMobilityMS1.HasValue || ionMobilityFragment.HasValue || ionMobilityWindow.HasValue)
            {
                return new TransitionGroupIonMobilityInfo()
                       {
                           CollisionalCrossSection = ccs,
                           IonMobilityMS1          = ionMobilityMS1,
                           IonMobilityFragment     = ionMobilityFragment,
                           IonMobilityWindow       = ionMobilityWindow,
                           IonMobilityUnits        = units
                       }
            }
            ;
            return(EMPTY);
        }
Esempio n. 14
0
 public void SetIonMobilityUnits(eIonMobilityUnits units)
 {
     Units = units;
 }
Esempio n. 15
0
 public IonMobilityValue ChangeIonMobility(double?value, eIonMobilityUnits units)
 {
     return(value == Mobility && units == Units ? this : GetIonMobilityValue(value, units));
 }
Esempio n. 16
0
        public Dictionary <LibKey, IonMobilityAndCCS> GetTableMeasuredIonMobility(bool useHighEnergyOffsets, eIonMobilityUnits units)
        {
            var e    = new CancelEventArgs();
            var dict = new Dictionary <LibKey, IonMobilityAndCCS>();

            foreach (DataGridViewRow row in _gridMeasuredDriftTimePeptides.Rows)
            {
                if (row.IsNewRow)
                {
                    continue;
                }

                string seq;
                if (!ValidateSequence(e, row.Cells[EditDriftTimePredictorDlg.COLUMN_SEQUENCE], out seq))
                {
                    return(null);
                }

                // OK, we have a non-empty "sequence" string, but is that actually a peptide or a molecule?
                // See if there's anything in the document whose text representation matches what's in the list
                var target = Program.MainWindow.Document.Molecules.Select(m => m.Target).FirstOrDefault(t => seq.Equals(t.ToString()));
                if (target == null || target.IsEmpty)
                {
                    // Does seq evaluate as a peptide?
                    target = !seq.All(c => char.IsUpper(c) || char.IsDigit(c) || @"[+-,.]()".Contains(c))
                        ? new Target(CustomMolecule.FromSerializableString(seq))
                        : Target.FromSerializableString(seq);
                }

                Adduct charge;
                if (!ValidateCharge(e, row.Cells[EditDriftTimePredictorDlg.COLUMN_CHARGE], target.IsProteomic, out charge))
                {
                    return(null);
                }

                double mobility;
                if (!ValidateDriftTime(e, row.Cells[EditDriftTimePredictorDlg.COLUMN_ION_MOBILITY], out mobility))
                {
                    return(null);
                }

                double?ccs;
                if (!ValidateCCS(e, row.Cells[EditDriftTimePredictorDlg.COLUMN_CCS], out ccs))
                {
                    return(null);
                }

                double highEnergyOffset = 0; // Set default value in case user does not provide one
                if (useHighEnergyOffsets && !ValidateHighEnergyDriftTimeOffset(e, row.Cells[EditDriftTimePredictorDlg.COLUMN_HIGH_ENERGY_OFFSET], out highEnergyOffset))
                {
                    return(null);
                }
                var ionMobility = IonMobilityValue.GetIonMobilityValue(mobility, units);
                try
                {
                    dict.Add(new LibKey(target, charge), IonMobilityAndCCS.GetIonMobilityAndCCS(ionMobility, ccs, highEnergyOffset));
                }
                // ReSharper disable once EmptyGeneralCatchClause
                catch
                {
                    // just take the first seen
                }
            }
            return(dict);
        }
Esempio n. 17
0
 public static IonMobilityValue GetIonMobilityValue(double?value, eIonMobilityUnits units)
 {
     return((units == eIonMobilityUnits.none || !value.HasValue)
         ? EMPTY
         : new IonMobilityValue(value, units));
 }
Esempio n. 18
0
 public static IonMobilityValue GetIonMobilityValue(double mobility, eIonMobilityUnits units)
 {
     return((units == eIonMobilityUnits.none)
         ? EMPTY
         : new IonMobilityValue(mobility, units));
 }
Esempio n. 19
0
 // Private so we can issue EMPTY in the common case of no ion mobility info
 private IonMobilityValue(double?mobility, eIonMobilityUnits units)
 {
     Mobility = mobility;
     Units    = units;
 }
Esempio n. 20
0
        public ExplicitTransitionGroupValues ChangeIonMobility(double?imNew, eIonMobilityUnits unitsNew)
        {
            var explicitTransitionGroupValues = ChangeProp(ImClone(this), (im, v) => im.IonMobility = v, imNew);

            return(ChangeProp(ImClone(explicitTransitionGroupValues), (im, v) => im.IonMobilityUnits = v, unitsNew));
        }
Esempio n. 21
0
        public ChromatogramDataProvider(MsDataFileImpl dataFile,
                                        ChromFileInfo fileInfo,
                                        IProgressStatus status,
                                        int startPercent,
                                        int endPercent,
                                        IProgressMonitor loader)
            : base(fileInfo, status, startPercent, endPercent, loader)
        {
            _dataFile = dataFile;
            _globalChromatogramExtractor = new GlobalChromatogramExtractor(dataFile);

            if (_dataFile.IsThermoFile)
            {
                _readMaxMinutes = 4;
            }

            int len = dataFile.ChromatogramCount;

            _chromIndices = new int[len];

            bool fixCEOptForShimadzu = dataFile.IsShimadzuFile;
            int  indexPrecursor      = -1;
            var  lastPrecursor       = SignedMz.ZERO;

            for (int i = 0; i < len; i++)
            {
                int    index;
                string id = dataFile.GetChromatogramId(i, out index);

                if (!ChromKey.IsKeyId(id))
                {
                    continue;
                }

                var chromKey = ChromKey.FromId(id, fixCEOptForShimadzu);
                if (chromKey.Precursor != lastPrecursor)
                {
                    lastPrecursor = chromKey.Precursor;
                    indexPrecursor++;
                }
                if (chromKey.Precursor.IsNegative)
                {
                    _sourceHasNegativePolarityData = true;
                }
                else
                {
                    _sourceHasPositivePolarityData = true;
                }
                var ki = new ChromKeyProviderIdPair(chromKey, index);
                _chromIndices[index] = indexPrecursor;
                _chromIds.Add(ki);
            }

            // Shimadzu can't do the necessary product m/z stepping for itself.
            // So, they provide the CE values in their IDs and we need to adjust
            // product m/z values for them to support CE optimization.
            if (fixCEOptForShimadzu)
            {
                FixCEOptForShimadzu();
            }

            if (_chromIds.Count == 0)
            {
                throw new NoSrmDataException(FileInfo.FilePath);
            }

            // CONSIDER: TIC and BPC are not well defined for SRM and produced chromatograms with over 100,000 points in
            // Agilent CE optimization data. So, keep them off for now.
//            foreach (int globalIndex in _globalChromatogramExtractor.GlobalChromatogramIndexes)
//            {
//                _chromIndices[globalIndex] = globalIndex;
//                _chromIds.Add(new ChromKeyProviderIdPair(ChromKey.FromId(_globalChromatogramExtractor.GetChromatogramId(globalIndex, out int indexId), false), globalIndex));
//            }

            foreach (var qcTracePair in _globalChromatogramExtractor.QcTraceByIndex)
            {
                _chromIndices[qcTracePair.Key] = qcTracePair.Key;
                _chromIds.Add(new ChromKeyProviderIdPair(ChromKey.FromQcTrace(qcTracePair.Value), qcTracePair.Key));
            }

            // CONSIDER(kaipot): Some way to support mzML files converted from MIDAS wiff files
            _hasMidasSpectra = (dataFile.IsABFile) && SpectraChromDataProvider.HasSpectrumData(dataFile);

            _ionMobilityUnits       = dataFile.IonMobilityUnits;
            _hasIonMobilityCombined = dataFile.HasCombinedIonMobilitySpectra;  // When true, data source provides IMS data in 3-array format, which affects spectrum ID format

            SetPercentComplete(50);
        }