Example #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Client != null ? Client.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (IntensityModel != null ? IntensityModel.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (RTModel != null ? RTModel.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Settings != null ? Settings.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Precursor != null ? Precursor.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Peptide != null ? Peptide.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ NCE;
         return(hashCode);
     }
 }
Example #2
0
            public override PrositHelpers.PrositRequest Predict()
            {
                ActionUtil.RunAsync(() =>
                {
                    try
                    {
                        var labelType = Precursor.LabelType;
                        var ms        = IntensityModel.PredictSingle(Client, Settings,
                                                                     new PrositIntensityModel.PeptidePrecursorNCE(Peptide, Precursor, labelType, NCE), _tokenSource.Token);

                        var iRTMap = RTModel.PredictSingle(Client,
                                                           Settings,
                                                           Peptide, _tokenSource.Token);

                        var spectrumInfo = new SpectrumInfoProsit(ms, Precursor, labelType, NCE);
                        var irt          = iRTMap[Peptide];
                        Spectrum         = new SpectrumDisplayInfo(
                            spectrumInfo, Precursor, irt);
                    }
                    catch (Exception ex)
                    {
                        Exception = ex;

                        // Ignore, UpdateUI is already working on a new request,
                        // so don't even update UI
                        if (ex.InnerException is RpcException rpcEx && rpcEx.StatusCode == StatusCode.Cancelled)
                        {
                            return;
                        }
                    }

                    // Bad timing could cause the ping to finish right when we cancel as the form closes
                    // causing a UI update to be called after the form was destroyed
                    if (!_tokenSource.IsCancellationRequested)
                    {
                        _updateCallback.Invoke();
                    }
                });

                return(this);
            }
Example #3
0
            public virtual PrositRequest Predict()
            {
                ActionUtil.RunAsync(() =>
                {
                    try
                    {
                        var labelType = LabelType ?? Precursor.LabelType;
                        var skyIn     = new PrositIntensityModel.PeptidePrecursorNCE(Peptide,
                                                                                     Precursor, labelType, NCE);
                        var massSpectrum = IntensityModel.PredictSingle(Client,
                                                                        Settings, skyIn,
                                                                        _tokenSource.Token);
                        var iRT = RTModel.PredictSingle(Client,
                                                        Settings,
                                                        Peptide, _tokenSource.Token);
                        Spectrum = new SpectrumDisplayInfo(
                            new SpectrumInfoProsit(massSpectrum, Precursor, labelType, NCE),
                            // ReSharper disable once AssignNullToNotNullAttribute
                            Precursor,
                            iRT[Peptide]);
                    }
                    catch (PrositException ex)
                    {
                        Exception = ex;

                        // Ignore, UpdateUI is already working on a new request,
                        // so don't even update UI
                        if (ex.InnerException is RpcException rpcEx && rpcEx.StatusCode == StatusCode.Cancelled)
                        {
                            return;
                        }
                    }

                    _updateCallback.Invoke();
                });
                return(this);
            }
Example #4
0
        public List <IntensityModel> Intensity(string code, DateTime from, DateTime to, string exit)
        {
            var result = new List <IntensityModel>();

            // old table: a1_curva_intesidad_sobrecarga
            using (var connection = new NpgsqlConnection(_connectionString)) {
                NpgsqlCommand command;

                if (exit == "max")
                {
                    command = new NpgsqlCommand(
                        @"select fecha, horas, fase_r, fase_s, fase_t
                        from b1_curva_intesidad_sobrecarga
                        where matricula = @Code and fecha >= @From and fecha <= @To and tpo_salida_max = 1", connection);

                    command.Parameters.Add("Code", NpgsqlDbType.Varchar).Value   = code;
                    command.Parameters.Add("From", NpgsqlDbType.Timestamp).Value = from;
                    command.Parameters.Add("To", NpgsqlDbType.Timestamp).Value   = to;
                }
                else
                {
                    command = new NpgsqlCommand(
                        @"select fecha, horas, fase_r, fase_s, fase_t
                        from b1_curva_intesidad_sobrecarga
                        where matricula = @Code and fecha >= @From and fecha <= @To and salida = @Exit", connection);

                    command.Parameters.Add("Code", NpgsqlDbType.Varchar).Value   = code;
                    command.Parameters.Add("From", NpgsqlDbType.Timestamp).Value = from;
                    command.Parameters.Add("To", NpgsqlDbType.Timestamp).Value   = to;
                    command.Parameters.Add("Exit", NpgsqlDbType.Varchar).Value   = exit.ToUpperInvariant();
                }

                connection.Open();

                var reader = command.ExecuteReader();

                while (reader.Read())
                {
                    if (reader.IsDBNull(1))
                    {
                        continue;
                    }

                    var model = new IntensityModel {
                        Date = (DateTime)reader["fecha"],
                        Hour = (int)reader["horas"],
                        R    = reader.IsDBNull(2) ? 0 : (double)reader["fase_r"],
                        S    = reader.IsDBNull(3) ? 0 : (double)reader["fase_s"],
                        T    = reader.IsDBNull(4) ? 0 : (double)reader["fase_t"]
                    };

                    // TODO: temp fix for incorrect horas from db
                    if (model.Hour < 24)
                    {
                        result.Add(model);
                    }
                }

                reader.Close();
            }

            return(result);
        }