Пример #1
0
        /// <summary>
        /// Validate Rgroup decomposition & build proper query table
        /// </summary>
        /// <param name="qt"></param>
        /// <param name="q"></param>
        /// <param name="resultKeys"></param>

        public override void DoPreSearchTransformation(
            Query originalQuery,
            QueryTable originalQt,
            Query newQuery)
        {
            int ri;

            QueryTable qt = originalQt.Clone();             // make copy we can modify

            SetupQueryTableForRGroupDecomposition(qt, newQuery);

            newQuery.AddQueryTableUnique(qt);             // store replacement query table
            return;
        }
Пример #2
0
        /// <summary>
        /// Create clone query and metatables that can be modified later if necessary
        /// </summary>

        QueryTable CloneQueryTableAndMetaTable(QueryTable qt)
        {
            QueryTable qt2 = qt.Clone();
            MetaTable  mt2 = qt.MetaTable.Clone();

            qt2.MetaTable = mt2;
            foreach (QueryColumn qc2 in qt2.QueryColumns)
            {
                MetaColumn mc  = qc2.MetaColumn;
                MetaColumn mc2 = mt2.GetMetaColumnByName(mc.Name);                 // get clone metacolumn
                qc2.MetaColumn = mc2;
            }

            return(qt2);
        }
Пример #3
0
/// <summary>
/// Convert a multipivot table into a set of tables where data exists for
/// one or more of the compound identifiers in the list.
/// </summary>
/// <param name="qt">Current form of query table</param>
/// <param name="q">Query to add transformed tables to</param>
/// <param name="ResultKeys">Keys data will be retrieved for</param>

        public override void ExpandToMultipleTables(
            QueryTable qt,
            Query q,
            List <string> resultKeys)
        {
            MetaTable        mt2;
            QueryTable       qt2;
            QueryColumn      qc2;
            HashSet <string> geneDict = new HashSet <string>();
            string           sql;
            string           geneSymbol;

            int t0 = TimeOfDay.Milliseconds();

// Build query & get set of gene symbols

            Query q2 = new Query();

            q2.SingleStepExecution = true;

            q2.KeyCriteria = q2.KeyCriteriaDisplay =              // keylist to return (may want to include all target summary option criteria)
                                                     " in (" + MqlUtil.FormatValueListString(resultKeys, true) + ")";

            qt2 = qt.Clone();
            qt2.SelectKeyOnly();
            qc2          = qt2.GetQueryColumnByNameWithException("gene_symbol");
            qc2.Selected = true;
            q2.AddQueryTable(qt2);

            QueryEngine qe2 = new QueryEngine();

            qe2.ExecuteQuery(q2);
            while (true)
            {
                object[] vo = qe2.NextRow();
                if (vo == null)
                {
                    qe2.Close();
                    break;
                }

                if (qe2.Cancelled)
                {
                    qe2.Close();
                    return;
                }

                geneSymbol = vo[2] as string;
                if (Lex.IsNullOrEmpty(geneSymbol))
                {
                    continue;
                }
                geneDict.Add(geneSymbol.ToUpper());
            }

            string[] sa = new string[geneDict.Count];
            geneDict.CopyTo(sa);
            Array.Sort(sa);

            foreach (string s0 in sa)
            {
                geneSymbol = s0;
                string mt2Name = MultiDbAssayDataNames.BasePivotTablePrefix + geneSymbol;

                //if (QueryEngine.FilterAllDataQueriesByDatabaseContents &&
                //    !MetaTableCollection.IsMetaTableInContents(mtName)) continue; // metatable must be in contents

                mt2 = MetaTableCollection.Get(mt2Name);
                if (mt2 == null)
                {
                    continue;                              // in case can't allocate for some reason
                }
                qt2 = q.GetQueryTableByName(mt2.Name);     // see if already in query
                if (qt2 != null)
                {
                    continue;                              // ignore if already there
                }
                qt2 = new QueryTable(q, mt2);              // allocate new query table & add to query
                qt2.DeselectAll();

                foreach (QueryColumn qc0 in qt.QueryColumns)                 // set selected columns to match those in the source qt
                {
                    if (qc0.Selected && qt2.GetQueryColumnByName(qc0.MetaColumn.Name) != null)
                    {
                        qt2.GetQueryColumnByName(qc0.MetaColumn.Name).Selected = true;
                    }
                }

                if (qt.HeaderBackgroundColor != Color.Empty)
                {
                    qt2.HeaderBackgroundColor = qt.HeaderBackgroundColor;
                }
            }

            t0 = TimeOfDay.Milliseconds() - t0;
            return;
        }