示例#1
0
/// <summary>
/// Get the root table associated with a compound id prefix
/// </summary>
/// <param name="prefix"></param>
/// <param name="rti"></param>
/// <param name="mtRoot"></param>

        public static void GetRootMetaTableFromPrefix(
            string prefix,
            out RootTable rti,
            out MetaTable mtRoot)
        {
            rti    = null;
            mtRoot = null;

            if (prefix == "")
            {
                prefix = "none";                           // no prefix
            }
            if (PrefixToRootTableDict.ContainsKey(prefix)) // already have root info?
            {
                rti    = PrefixToRootTableDict[prefix];
                mtRoot = PrefixToRootMetaTableDict[prefix];
                return;
            }

            rti = RootTable.GetFromPrefix(prefix);
            if (rti == null)
            {
                return;
            }

            string mtName = rti.MetaTableName;

            mtRoot = MetaTableCollection.Get(mtName);

            PrefixToRootTableDict[prefix]     = rti;
            PrefixToRootMetaTableDict[prefix] = mtRoot;

            return;
        }
示例#2
0
        /// <summary>
        /// Build query to fetch all unsummarized assay data for a target
        /// </summary>
        /// <param name="geneSymbol"></param>
        /// <returns></returns>

        public static Query BuildTargetAssayUnsummarizedDataQuery(
            string geneSymbol)
        {
            Query      q  = new Query();
            MetaTable  mt = MetaTableCollection.Get(UnsummarizedMetaTableName);
            QueryTable qt = new QueryTable(mt);

            q.AddQueryTable(qt);
            q.SingleStepExecution = true;   // for performance
            q.KeySortOrder        = 0;      // no sorting
            return(q);
        }
示例#3
0
        /// <summary>
        /// Remove a metatable from both the local and remote table map
        /// </summary>
        /// <param name="mtName"></param>

        public static void RemoveGlobally(
            string mtName)
        {
            MetaTableCollection.Remove(mtName);             // do local remove

            if (MetaTableFactory == null)
            {
                throw new Exception("MetaTableFactory instance is not defined");
            }
            MetaTableFactory.RemoveServiceMetaTable(mtName);             // remove from service side to force reload
            return;
        }
示例#4
0
        /// <summary>
        /// Deserialize old format conditional formatting.
        /// </summary>
        /// <param name="serializedForm"></param>
        /// <returns></returns>

        public static CondFormat DeserializeOld(
            string serializedForm)
        {
            CondFormat cf = new CondFormat();

            string[] sa  = serializedForm.Split('\n');
            string[] sa2 = sa[0].Split('\t');
            //			cf.IsCSF = Boolean.Parse(sa2[0]); // (obsolete)
            if (sa2.Length >= 3)
            {
                MetaTable mt = MetaTableCollection.Get(sa2[1]);
                if (mt == null)
                {
                    return(null);
                }
                MetaColumn mc = mt.GetMetaColumnByName(sa2[2]);
                if (mc != null)
                {
                    cf.ColumnType = mc.DataType;
                }
            }

            if (sa.Length > 1 && sa[1] != "")
            {
                cf.Rules.Add(CondFormatRules.DeserializeOld(sa[1]));
            }
            if (sa.Length > 2 && sa[2] != "")
            {
                cf.Rules.Add(CondFormatRules.DeserializeOld(sa[2]));
            }
            if (sa.Length > 3 && sa[3] != "")
            {
                cf.Rules.Add(CondFormatRules.DeserializeOld(sa[3]));
            }
            if (sa.Length > 4 && sa[4] != "")
            {
                cf.Rules.Add(CondFormatRules.DeserializeOld(sa[4]));
            }

            return(cf);
        }
示例#5
0
        /// <summary>
        /// Parse serialized form of calculated field
        /// </summary>
        /// <param name="content"></param>
        /// <returns></returns>

        public static CalcField DeserializeOld(
            string content)
        {
            MetaTable mt, mt2;
            string    mtName;

            CalcField       cf = new CalcField();
            CalcFieldColumn c1 = cf.Column1;
            CalcFieldColumn c2 = cf.Column2;

            string[] sa = content.Split('\t');

            cf.CalcType = CalcTypeEnum.Basic;             // assume basic type

            if (sa[0] != "")
            {
                mt = MetaTableCollection.GetWithException(sa[0]);
                if (mt.SummarizedExists && !mt.UseSummarizedData)
                {                 // use summarized form if exists
                    mtName = mt.Name + MetaTable.SummarySuffix;
                    mt2    = MetaTableCollection.Get(mtName);
                    if (mt2 != null && mt2.GetMetaColumnByName(sa[1]) != null)
                    {
                        mt = mt2;
                    }
                }

                c1.MetaColumn = mt.GetMetaColumnByNameWithException(sa[1]);
                if (c1.MetaColumn == null)
                {
                    return(null);
                }
                c1.Function = sa[2];
                c1.Constant = sa[3];

                cf.Operation = sa[4];
            }

            if (sa.Length <= 5 ||             // old form with only first field defined
                (sa.Length == 6 && String.IsNullOrEmpty(sa[5])))
            {
                cf.SetDerivedValues();
                return(cf);
            }

            if (sa[6] != "")
            {
                mt = MetaTableCollection.GetWithException(sa[5]);
                if (mt == null)
                {
                    return(null);
                }

                if (mt.SummarizedExists && !mt.UseSummarizedData)
                {                 // use summarized form if exists
                    mtName = mt.Name + MetaTable.SummarySuffix;
                    mt2    = MetaTableCollection.Get(mtName);
                    if (mt2 != null && mt2.GetMetaColumnByName(sa[6]) != null)
                    {
                        mt = mt2;
                    }
                }

                c2.MetaColumn = mt.GetMetaColumnByNameWithException(sa[6]);
                if (c2.MetaColumn == null)
                {
                    return(null);
                }
                c2.Function = sa[7];
                c2.Constant = sa[8];
            }

            if (sa.Length >= 13)             // get other values if new form
            {
                EnumUtil.TryParse(sa[9], out cf.CalcType);
                cf.AdvancedExpr = sa[10];
                string obsoleteIncludedQueryXml = sa[11];                 // obsolete cf.IncludedQueryXml
                cf.Description = sa[12];
            }

            cf.SetDerivedValues();

            return(cf);
        }
示例#6
0
        /// <summary>
        /// Deserialize CalcField from an XmlTextReader
        /// </summary>
        /// <param name="tr"></param>
        /// <returns></returns>

        public static CalcField Deserialize(
            XmlTextReader tr)
        {
            string     mtName, mcName, txt, errMsg = "";
            MetaTable  mt;
            MetaColumn mc;

            CalcField cf = new CalcField();

            XmlUtil.GetStringAttribute(tr, "Name", ref cf.UserObject.Name);

            txt = tr.GetAttribute("CalcType");
            EnumUtil.TryParse(txt, out cf.CalcType);
            if (cf.CalcType != CalcTypeEnum.Basic && cf.CalcType != CalcTypeEnum.Advanced)
            {
                cf.CalcType = CalcTypeEnum.Basic;                 // default to basic type
            }
            txt = tr.GetAttribute("SourceColumnType");
            if (txt != null)
            {
                cf.SourceColumnType = MetaColumn.ParseMetaColumnTypeString(txt);
            }

            txt = tr.GetAttribute("PreclassificationlResultType");
            if (txt != null)
            {
                cf.PreclassificationlResultType = MetaColumn.ParseMetaColumnTypeString(txt);
            }

            for (int ci = 1; ; ci++)             // get the set of columns
            {
                mtName = tr.GetAttribute("Table" + ci);
                if (String.IsNullOrEmpty(mtName))
                {
                    //if (ci == 1) continue; // first col may be undefined
                    //else
                    if (ci > 1)
                    {
                        break;                             // if beyond the first then col then all done
                    }
                }

                if (ci > cf.CfCols.Count)
                {
                    cf.CfCols.Add(new CalcFieldColumn());
                }
                CalcFieldColumn cfc = cf.CfCols[ci - 1];

                mt = MetaTableCollection.Get(mtName);
                if (mt != null)
                {
                    mcName = tr.GetAttribute("Column" + ci);
                    if (mcName != null)
                    {
                        cfc.MetaColumn = mt.GetMetaColumnByName(mcName);
                        if (cfc.MetaColumn == null)
                        {
                            errMsg += "Unable to find column: " + mcName + " in data table " + mt.Label + "(" + mt.Name + ")\r\n";
                        }
                    }
                }

                else if (ci != 1)
                {
                    errMsg += "Unable to find data table: " + mtName + "\r\n";
                }

                txt = tr.GetAttribute("Function" + ci);
                if (txt != null)
                {
                    cfc.Function = txt;
                }

                txt = tr.GetAttribute("Constant" + ci);
                if (txt != null)
                {
                    cfc.Constant = txt;
                }
            }

            txt = tr.GetAttribute("Operation");
            if (txt != null)
            {
                cf.Operation = txt;
            }

            XmlUtil.GetStringAttribute(tr, "AdvancedExpr", ref cf.AdvancedExpr);
            XmlUtil.GetStringAttribute(tr, "OuterJoinRoot", ref cf.OuterJoinRoot);

            XmlUtil.GetStringAttribute(tr, "ColumnLabel", ref cf.ColumnLabel);
            XmlUtil.GetStringAttribute(tr, "Description", ref cf.Description);
            XmlUtil.GetStringAttribute(tr, "Prompt", ref cf.Prompt);


            if (!tr.IsEmptyElement)
            {
                tr.Read();
                tr.MoveToContent();
                if (Lex.Eq(tr.Name, "CondFormat"))                 // and cond format
                {
                    if (!tr.IsEmptyElement)
                    {
                        cf.Classification = CondFormat.Deserialize(tr);
                    }
                    tr.Read();                     // get next element
                    tr.MoveToContent();
                }

                if (!Lex.Eq(tr.Name, "CalcField") || tr.NodeType != XmlNodeType.EndElement)
                {
                    throw new Exception("CalcField.Deserialize - Expected CalcField end element");
                }
            }

            cf.SetDerivedValues();

            return(cf);
        }
示例#7
0
        /// <summary>
        /// Get default key MetaTable
        /// </summary>
        /// <returns></returns>

        public static MetaTable GetDefaultRootMetaTable()
        {
            return(MetaTableCollection.Get("corp_structure")); // todo: set from parameter
        }