Пример #1
0
        /// <summary>
        /// Activity class includes both a class name (High, Medium, Low) and an activity color (Green to Red)
        /// and is calculated from ActivityBin
        /// </summary>

        public void SetActivityClass()
        {
            UnpivotedAssayResult sRow = this;
            int bin = sRow.ActivityBin;

            StringMx sx = new StringMx();

            if (bin < 0)
            {
                sx.Value     = "Missing Data";
                sx.BackColor = CondFormat.CsfUndefined;
            }

            else if (bin <= 3)
            {
                sx.Value     = "Fail";
                sx.BackColor = CondFormat.CsfRed;
            }

            else if (bin <= 6)
            {
                sx.Value     = "BorderLine";
                sx.BackColor = CondFormat.CsfYellow;
            }

            else
            {
                sx.Value     = "Pass";
                sx.BackColor = CondFormat.CsfGreen;
            }

            sRow.ActivityClass = sx;
            return;
        }
Пример #2
0
        /// <summary>
        /// Set the activity bin for the row (now set in SQL)
        /// </summary>

        public void SetActivityBin(
            QualifiedNumber resultValueQn,
            double resultNumericValue,
            out int activityBin)
        {
            UnpivotedAssayResult sRow = this;

            double val = 0;

            if (resultNumericValue > 0)             // use numeric value if we have it
            {
                val = resultNumericValue;
            }
            else if (resultValueQn != null && resultValueQn.NumberValue > 0)             // otherwise use any qualified number numeric value
            {
                val = resultValueQn.NumberValue;
            }

            if (val <= 0)
            {
                activityBin = 0;                       // no valid value
            }
            else if (Lex.Eq(sRow.ResultTypeConcType, "SP"))
            {             // calc SP activity bin
                double crc = ConvertSPToCRC(val, sRow.Conc);
                activityBin = CalcCRCActivityBin(crc);
            }

            else             // calc CRC activity bin
            {
                activityBin = CalcCRCActivityBin(val);
            }
        }
Пример #3
0
        /// <summary>
        /// Convert a value object[] into a new UnpivotedAssayResult
        /// </summary>
        /// <param name="vo"></param>
        /// <param name="voi"></param>
        /// <returns></returns>

        new public static UnpivotedAssayResult FromValueObjectNew(
            object[] vo,
            UnpivotedAssayResultFieldPositionMap voMap)
        {
            UnpivotedAssayResult row = new UnpivotedAssayResult();

            row.FromValueObject(vo, voMap);
            return(row);
        }
Пример #4
0
        /// <summary>
        /// Lookup predefined conditional formatting by name
        /// </summary>
        /// <param name="cfName"></param>
        /// <returns></returns>

        public static CondFormat GetPredefined(string cfName)
        {
            CondFormat cf = null;

            cfName = cfName.ToUpper();

            if (Lex.Eq(cfName, "Activity Class Conditional Formatting") || Lex.Eq(cfName, "ActivityClassCondFormat"))             // special internal format
            {
                cf = UnpivotedAssayResult.BuildActivityClassCondFormat();
                return(cf);
            }

            else if (Lex.Eq(cfName, "Activity Bin Conditional Formatting") || Lex.Eq(cfName, "ActivityBinCondFormat"))             // special internal format
            {
                cf = UnpivotedAssayResult.BuildActivityBinCondFormat();
                return(cf);
            }

            else if (Lex.StartsWith(cfName, "CONDFORMAT_"))
            {
                if (PredefinedDict == null)                 // need to build?
                {
                    if (InterfaceRefs.IUserObjectTree == null)
                    {
                        return(null);
                    }
                    List <UserObject> uoList = InterfaceRefs.IUserObjectTree.GetUserObjectsByType(UserObjectType.CondFormat);
                    if (uoList == null)
                    {
                        return(null);
                    }

                    PredefinedDict = new Dictionary <string, string>();
                    foreach (UserObject uo0 in uoList)
                    {
                        PredefinedDict[uo0.InternalName.ToUpper()] = uo0.Content;
                    }
                }

                if (!PredefinedDict.ContainsKey(cfName))
                {
                    return(null);
                }

                cf = CondFormat.Deserialize(PredefinedDict[cfName]);
                return(cf);
            }

            else
            {
                return(null);
            }
        }
Пример #5
0
        new public void ToValueObject(
            object[] vo,
            UnpivotedAssayResultFieldPositionMap voMap)
        {
            base.ToValueObject(vo, voMap);             // set the basic attribute values

            UnpivotedAssayResult row = this;

            //if (row.ResultValue != null) row = row; // debug

            SetVo(vo, voMap.CompoundId.Voi, row.CompoundId);
            SetVo(vo, voMap.Structure.Voi, row.Structure);

            SetVo(vo, voMap.ActivityBin.Voi, row.ActivityBin);
            SetVo(vo, voMap.ActivityClass.Voi, row.ActivityClass);
            SetVo(vo, voMap.ResultValueQn.Voi, row.ResultValue);
            SetVo(vo, voMap.ResultQualifier.Voi, row.ResultQualifier);
            SetVo(vo, voMap.ResultNumericValue.Voi, row.ResultNumericValue);
            SetVo(vo, voMap.ResultTextValue.Voi, row.ResultTextValue);
            SetVo(vo, voMap.NValue.Voi, row.NValue);
            SetVo(vo, voMap.NValueTested.Voi, row.NValueTested);
            SetVo(vo, voMap.StdDev.Voi, row.StdDev);
            SetVo(vo, voMap.Units.Voi, row.Units);
            SetVo(vo, voMap.Conc.Voi, row.Conc);
            SetVo(vo, voMap.ConcUnits.Voi, row.ConcUnits);
            SetVo(vo, voMap.RunDate.Voi, row.RunDate);

            SetVo(vo, voMap.MostPotentValueQn.Voi, row.MostPotentVal);
            SetVo(vo, voMap.ActivityBinMostPotent.Voi, row.ActivityBinMostPotent);

            StringMx sx = new StringMx(row.ResultDetail);             // put link to cid, targetId & resultType

            sx.DbLink = "'" + row.CompoundId + "','" + row.GeneId + "','" + row.ResultTypeConcType + "'";
            SetVo(vo, voMap.ResultDetailId.Voi, sx);

            //SetVo(vo, voMap.TargetMapX.Voi, row.TargetMapX);
            //SetVo(vo, voMap.TargetMapY.Voi, row.TargetMapY);

            SetVo(vo, voMap.Sources.Voi, row.Sources);
            SetVo(vo, voMap.DrawingOrder.Voi, row.DrawingOrder);
            SetVo(vo, voMap.CidOrder.Voi, row.CidOrder);

            return;
        }
Пример #6
0
        /// <summary>
        /// Put row values into standard form
        /// </summary>
        /// <param name="r"></param>

        public void NormalizeValues()
        {
            string msg;

            UnpivotedAssayResult r = this;

            // Normalize SP concentrations to micromolar units

            if (String.IsNullOrEmpty(r.ConcUnits) && r.AssayName != null)
            {             // if no conc in data try to get from assay name
                Match m = Regex.Match(r.AssayName, "(\\d+\\.*\\d*) ?(uM|mM|nM)", RegexOptions.IgnoreCase);
                if (m.Success)
                {
                    r.ConcUnits = m.Groups[2].Value;
                    r.Conc      = double.Parse(m.Groups[1].Value);
                }
            }

            // Normalize SP concentrations to micromolar units

            if (!String.IsNullOrEmpty(r.ConcUnits) && r.Conc > 0)
            {
                if (Lex.Eq(r.ConcUnits, "mM"))
                {
                    r.Conc     *= 1000.0;
                    r.ConcUnits = "uM";
                }

                else if (Lex.Eq(r.ConcUnits, "nM"))
                {
                    r.Conc     /= 1000.0;
                    r.ConcUnits = "uM";
                }

                else if (Lex.Ne(r.ConcUnits, "uM"))
                {
                    msg = "Can't convert units: " + r.ConcUnits;
                }
            }

            // Normalize CRC concentrations to micromolar units

            if (Lex.Eq(r.ResultTypeConcType, "CRC"))
            {
                if (Lex.Eq(r.Units, "mM"))
                {
                    if (r.ResultNumericValue != NullValue.NullNumber)
                    {
                        r.ResultNumericValue *= 1000.0;
                    }
                    if (r.ResultValue != null && r.ResultValue.NumberValue != NullValue.NullNumber)
                    {
                        r.ResultValue.NumberValue *= 1000.0;
                    }
                    if (r.StdDev > 0)
                    {
                        r.StdDev *= 1000.0;
                    }
                    r.Units = "uM";
                }

                else if (Lex.Eq(r.Units, "nM"))
                {
                    if (r.ResultNumericValue != NullValue.NullNumber)
                    {
                        r.ResultNumericValue /= 1000.0;
                    }
                    if (r.ResultValue != null && r.ResultValue.NumberValue != NullValue.NullNumber)
                    {
                        r.ResultValue.NumberValue /= 1000.0;
                    }
                    if (r.StdDev > 0)
                    {
                        r.StdDev /= 1000.0;
                    }
                    r.Units = "uM";
                }

                else if (Lex.Ne(r.Units, "uM"))
                {
                    msg = "Can't convert units: " + r.Units;
                }
            }

            return;
        }
Пример #7
0
        /// <summary>
        /// Convert a value object[] into a ResultsRow
        /// </summary>
        /// <param name="vo"></param>
        /// <param name="voi"></param>
        /// <returns></returns>

        new public void FromValueObject(
            object[] vo,
            UnpivotedAssayResultFieldPositionMap voMap)
        {
            string   txt;
            int      i1;
            double   d1;
            DateTime dt;

            base.FromValueObject(vo, voMap);
            UnpivotedAssayResult row = this;

            row.CompoundId = GetStringVo(vo, voMap.CompoundId.Voi);
            row.Structure  = GetStructureVo(vo, voMap.Structure.Voi);

            row.ActivityBin   = GetIntVo(vo, voMap.ActivityBin.Voi);
            row.ActivityClass = GetSxVo(vo, voMap.ActivityClass.Voi);

            row.ResultValue = GetQnVo(vo, voMap.ResultValueQn.Voi);
            if (!NullValue.IsNull(row.ResultValue))
            {             // copy values to individual fields in case not in the vo
                row.ResultQualifier    = row.ResultValue.Qualifier;
                row.ResultNumericValue = row.ResultValue.NumberValue;
                row.ResultTextValue    = row.ResultValue.TextValue;
                row.NValue             = row.ResultValue.NValue;
                row.NValueTested       = row.ResultValue.NValueTested;
                row.StdDev             = row.ResultValue.StandardDeviation;
                row.StdErr             = row.ResultValue.StandardError;
            }

            txt = GetStringVo(vo, voMap.ResultQualifier.Voi);
            if (txt != null)
            {
                row.ResultQualifier = txt;
            }

            d1 = GetDoubleVo(vo, voMap.ResultNumericValue.Voi);
            if (d1 != NullValue.NullNumber)
            {
                row.ResultNumericValue = d1;
            }

            txt = GetStringVo(vo, voMap.ResultTextValue.Voi);
            if (txt != null)
            {
                row.ResultTextValue = txt;
            }

            i1 = GetIntVo(vo, voMap.NValue.Voi);
            if (d1 != NullValue.NullNumber)
            {
                row.NValue = i1;
            }

            i1 = GetIntVo(vo, voMap.NValueTested.Voi);
            if (i1 != NullValue.NullNumber)
            {
                row.NValueTested = i1;
            }

            d1 = GetDoubleVo(vo, voMap.StdDev.Voi);
            if (d1 != NullValue.NullNumber)
            {
                row.StdDev = d1;
            }

            row.Units     = GetStringVo(vo, voMap.Units.Voi);
            row.Conc      = GetDoubleVo(vo, voMap.Conc.Voi);
            row.ConcUnits = GetStringVo(vo, voMap.ConcUnits.Voi);
            row.RunDate   = GetDateVo(vo, voMap.RunDate.Voi);

            row.MostPotentVal         = GetQnVo(vo, voMap.MostPotentValueQn.Voi);
            row.ActivityBinMostPotent = GetIntVo(vo, voMap.ActivityBinMostPotent.Voi);

            row.ResultDetail = GetStringVo(vo, voMap.ResultDetailId.Voi);

            //row.TargetMapX = GetIntVo(vo, voMap.TargetMapX.Voi);
            //row.TargetMapY = GetIntVo(vo, voMap.TargetMapY.Voi);

            row.Sources      = GetStringVo(vo, voMap.Sources.Voi);
            row.DrawingOrder = GetDoubleVo(vo, voMap.DrawingOrder.Voi);
            row.CidOrder     = GetIntVo(vo, voMap.CidOrder.Voi);

            return;
        }