Exemple #1
0
        void AddRow(
            DataTableMx dt,
            string t1,
            string t2,
            int cpdCount)
        {
            int voLen = dt.Columns.Count;

            object[] vo = new object[voLen];
            vo[2] = t1;
            vo[3] = t1;
            vo[4] = t2;
            vo[5] = cpdCount;
            DataRowMx dr = dt.NewRow();

            dr.ItemArrayRef = vo;             // copy ref for efficiency since vo won't be changed
            dt.Rows.Add(dr);
            return;
        }
Exemple #2
0
        /// <summary>
        /// Do Generic display of a list of structures
        /// </summary>
        /// <param name="title"></param>
        /// <param name="cidLabel"></param>
        /// <param name="structLabel"></param>
        /// <param name="structures"></param>

        public static void DisplayStructures(
            string title,
            string cidLabel,
            string structLabel,
            List <MoleculeMx> structures,
            MoleculeGridPanel gridPanel,
            bool embedDataInQuery)
        {
            QueryManager qm = null;

            MetaTable mt = MetaTableCollection.GetWithException("Generic_Structure_Table");

            mt.MetaBrokerType = MetaBrokerType.NoSql;

            Query      q  = ToolHelper.InitEmbeddedDataToolQuery(mt);
            QueryTable qt = q.Tables[0];

            qt.Label = title;
            qt.GetQueryColumnByName("CompoundId").Label = cidLabel;
            qt.GetQueryColumnByName("Structure").Label  = structLabel;

            DataTableMx dt = q.ResultsDataTable as DataTableMx;

            for (int mi = 0; mi < structures.Count; mi++)
            {
                MoleculeMx cs  = structures[mi];
                DataRowMx  dr  = dt.NewRow();
                string     cid = cs.Id;
                if (Lex.IsUndefined(cid))
                {
                    cid = (mi + 1).ToString();
                }
                dr[qt.Alias + ".CompoundId"] = new CompoundId(cid);
                dr[qt.Alias + ".Structure"]  = cs;
                dt.Rows.Add(dr);
            }

            DisplayData(q, dt, gridPanel, embedDataInQuery);

            return;
        }
Exemple #3
0
        /// <summary>
        /// Update the match counts panel and structure view based on a set of structures and filter values
        /// </summary>
        /// <param name="excludeCurrentHitList"></param>
        /// <param name="rssrs"></param>

        public void DisplayRelatedStructures(
            List <StructSearchMatch> fml)
        {
            MoleculeMx cs;

            if (fml == null || fml.Count == 0)
            {
                DisplayEmptyStructureGrid();
                return;
            }

            if (StructureDisplayQuery == null)
            {
                BuildStructureDisplayQuery();                                            // initial setup
            }
            Query               q    = StructureDisplayQuery;
            QueryTable          qt   = q.Tables[0];
            DataTableMx         dt   = Qm.DataTable;
            MoleculeGridControl grid = Qm.MoleculeGrid;

            grid.BeginUpdate();

            dt.Clear();             // filter table

            HashSet <string> cidSet = new HashSet <string>();

            for (int mi = 0; mi < fml.Count; mi++)             // build and add the rows to the datatable of structures
            {
                StructSearchMatch ssm = fml[mi];
                DataRowMx         dr  = dt.NewRow();
                dr[qt.Alias + ".CompoundId"] = ssm.SrcCid;

                cs = new MoleculeMx(ssm.MolStringFormat, ssm.MolString);
                if (Lex.IsDefined(ssm.SrcCid))
                {
                    cs.SetMolComments("CorpId=" + ssm.SrcCid);                    // Attach CorpId to Molfile so it will be rendered correctly
                }
                if (ssm.SearchType == StructureSearchType.SmallWorld && Lex.IsDefined(ssm.GraphicsString))
                {
                    cs.SvgString = ssm.GraphicsString;
                }

                dr[qt.Alias + ".Structure"]  = cs;
                dr[qt.Alias + ".MatchType"]  = ssm.SearchTypeName;
                dr[qt.Alias + ".MatchScore"] = ssm.MatchScore;
                dr[qt.Alias + ".Database"]   = ssm.SrcName;
                dt.Rows.Add(dr);

                cidSet.Add(ssm.SrcCid);
            }

            Qm.DataTableManager.InitializeRowAttributes();

            string title = "Related Structures - Matches: " + fml.Count + ", Compound Ids: " + cidSet.Count;

            Qm.MoleculeGrid.SetTableHeaderCaption(0, title);

            if (!RSC.MoleculeGridPageControl.Visible)
            {
                RSC.MoleculeGridPageControl.Visible = true;
            }

            grid.EndUpdate();
            ToolHelper.RefreshDataDisplay(Qm);

            return;
        }
Exemple #4
0
/// <summary>
/// Create and execute the drill down query
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>

        void BuildAndRunDrillDownQuery(object sender, PivotCellEventArgs e)
        {
            object o;

            PivotDrillDownDataSource ds = e.CreateDrillDownDataSource();

            if (ds.RowCount <= 0)
            {
                return;                               // no data
            }
            Query q2 = Qm.Query.Clone();

            q2.ShowGridCheckBoxes = false;

// Build name for drilldown from row and column fields values

            string txt = "";

            PivotGridField[] rf = e.GetRowFields();
            PivotGridField[] ca = e.GetColumnFields();
            Array.Resize(ref rf, rf.Length + ca.Length);
            Array.Copy(ca, 0, rf, rf.Length - ca.Length, ca.Length);

            foreach (PivotGridField f in rf)
            {
                o = e.GetFieldValue(f);
                if (o != null && o.ToString() != "")
                {
                    if (txt != "")
                    {
                        txt += ", ";
                    }
                    txt += o.ToString();
                }
            }

            if (e.ColumnValueType == PivotGridValueType.GrandTotal ||
                e.RowValueType == PivotGridValueType.GrandTotal)
            {
                txt += " Grand Total";
            }

            else if (e.ColumnValueType == PivotGridValueType.Total ||
                     e.RowValueType == PivotGridValueType.Total)
            {
                txt += " Total";
            }

            q2.UserObject.Name = txt;

// Create DataTable containing drill down data

            DataTableMx dt2 = DataTableManager.BuildDataTable(q2);

            for (int ri = 0; ri < ds.RowCount; ri++)
            {                                     // copy rows over
                DataRowMx dr2 = dt2.NewRow();
                object[]  vo  = dr2.ItemArrayRef; // get ref to the item array
                for (int ci = 0; ci < dt2.Columns.Count; ci++)
                {
                    //if (ci == 14) ci = ci; // debug
                    vo[ci] = ds.GetValue(ri, ci);                     // direct copy into ItemArray
                }

                dt2.Rows.Add(dr2);
            }

            QueryManager qm2 = ToolHelper.SetupQueryManager(q2, dt2);

            qm2.ResultsFormat.OutputFormContext = OutputFormContext.Popup;

            PopupGrid pug = new PopupGrid(qm2);

            MoleculeGridPanel.ConfigureAndShow(qm2, pug);
            return;
        }