Beispiel #1
0
        /// <summary>
        /// Retrieve next result row
        /// </summary>
        /// <returns></returns>

        public override object[] NextRow()
        {
            object[]             vo;
            UnpivotedAssayResult rr;

            if (!PivotInCode)             // if not multipivot then call generic broker
            {
                vo = base.NextRow();
            }

            else if (MultipivotRowList == null || MultipivotRowList.Count == 0)
            {
                vo = null;
            }

            else                           // remove row from multipivot row list
            {
                vo = MultipivotRowList[0]; // note: iterating MultipivotRowDict is slow
                MultipivotRowList.RemoveAt(0);
            }

            if (vo != null)
            {
                rr = UnpivotedAssayResult.FromValueObjectNew(vo, MdbAssayVoMap);                 // set cond formatting
                rr.SetResultValueBackColor(rr.ResultValue, rr.ActivityBin);
                rr.SetResultValueBackColor(rr.MostPotentVal, rr.ActivityBinMostPotent);

                SetCoordinates(rr);
                int voLength = Qt.SelectedCount;
                //if (vo.Length == voLength)
                rr.ToValueObject(vo, MdbAssayVoMap);                 // if same length use existing vo
            }

            return(vo);
        }
Beispiel #2
0
/// <summary>
/// Summarize unpivoted unsummarized assay data by target
/// </summary>
/// <param name="parms"></param>
/// <param name="qm2"></param>
/// <returns></returns>

        public QueryManager SummarizeByTargetUnpivoted(
            TargetSummaryOptions summaryOptions,
            QueryManager qm2)
        {
            // This method takes an unpivoted input query, summarizes it according to the summarization parameters
            // and then formats the summarized data according to the specified output format.
            // If a targetMap is specified then then coordinates are included in the output, the summarization
            // level must be target, and the output format must be unpivoted.

            QueryTable        qt, qt2;
            DataRowMx         dr, dr2;
            DataRowAttributes dra;
            string            cid = "", currentCid;
            int rti, rfi;

            AssayDict tad = TargetAssayDict;                                                // be sure target assay dict has been loaded

            TargetAssaySummarizationLevel sumLevel  = TargetAssaySummarizationLevel.Target; // target level
            SummarizationType             sumMethod = summaryOptions.UseMeans ? SummarizationType.BioResponseMean : SummarizationType.MostPotent;
            OutputDest outputDest = OutputDest.WinForms;
            TargetMap  targetMap  = TargetMapDao.GetMapWithCoords(summaryOptions.TargetMapName);

            qt = Query.GetQueryTableByName(MultiDbAssayDataNames.CombinedNonSumTableName);
            if (qt == null)
            {
                throw new Exception("Query table not found: " + MultiDbAssayDataNames.CombinedNonSumTableName);
            }

            UnpivotedAssayResultFieldPositionMap voMap = UnpivotedAssayResultFieldPositionMap.NewOriginalMap();             // used for fast indexing of value by col name

            voMap.InitializeFromQueryTableVoPositions(qt, 0);

            if (qm2 == null)             // need to create query manager?
            {
                qm2 = new QueryManager();
                qm2 = InitializeSubqueryQm(MultiDbAssayDataNames.CombinedNonSumTableName);
            }

            Query q2 = qm2.Query;

            qt2 = q2.GetQueryTableByNameWithException(MultiDbAssayDataNames.BaseTableName);

            UnpivotedAssayResultFieldPositionMap voMap2 = UnpivotedAssayResultFieldPositionMap.NewOriginalMap();             // used for fast indexing of value by col name

            voMap2.InitializeFromQueryTableVoPositions(qt2, 0);

// Summarize rows & store in DataSet

            qm2.DataTable.Clear();

            Dictionary <string, object> includedTargets = null;

            if (summaryOptions.TargetsWithActivesOnly)
            {             // scan data & make a list of targets to be included
                includedTargets = new Dictionary <string, object>();
                // ...
            }

            List <UnpivotedAssayResult> tars = new List <UnpivotedAssayResult>();           // build list of TA rows here

            currentCid = "";

            for (int dri = 0; dri <= DataTableMx.Rows.Count; dri++)
            {
                if (dri < DataTableMx.Rows.Count)
                {
                    dr  = DataTableMx.Rows[dri];
                    cid = dr[KeyValueVoPos] as string;
                    dra = GetRowAttributes(dr);
                    if (dra != null && dra.Filtered)
                    {
                        continue;
                    }
                    if (currentCid == "")
                    {
                        currentCid = cid;
                    }
                }
                else
                {
                    dr = null;
                }

                if (dr == null || cid != currentCid)
                {                       // summarize rows for current cid & add to new datatable
                    if (tars.Count > 0) //
                    {
                        List <UnpivotedAssayResult> sumTars = TargetAssayUtil.SummarizeData(
                            tars,
                            sumLevel,
                            sumMethod,
                            true,
                            NullValue.NullNumber,
                            NullValue.NullNumber,
                            targetMap);

                        int voLength2 = qm2.DataTable.Columns.Count;
                        foreach (UnpivotedAssayResult sumTar in sumTars)
                        {
                            object[] vo2 = sumTar.ToValueObject(voLength2, voMap2);
                            dr2 = qm2.DataTable.NewRow();
                            dr2.ItemArrayRef = vo2;                             // copy ref for efficiency since vo won't be changed
                            qm2.DataTable.Rows.Add(dr2);
                        }
                    }
                    if (dr == null)
                    {
                        break;
                    }
                    tars.Clear();
                    currentCid = cid;
                }

                UnpivotedAssayResult tar = UnpivotedAssayResult.FromValueObjectNew(dr.ItemArray, voMap);
                tars.Add(tar);                 // store in form for summarization
            }

            qm2.DataTableManager.InitializeRowAttributes();

            return(qm2);
        }