Ejemplo n.º 1
0
        /// <summary>
        /// Build the Query, QueryManager and DataTable for the matching structure display
        /// </summary>

        public void BuildStructureDisplayQuery()
        {
            MetaTable mt = MetaTableCollection.Get("QuickSearchRelatedStructures");

            if (mt == null)
            {
                DebugLog.Message("QuickSearchRelatedStructures MetaTable not found");
                RSC.MoleculeGridPageControl.Visible = false;
                return;
            }

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

            q.UserObject.Name     = qt.MetaTable.Label;
            StructureDisplayQuery = q;

            QueryColumn qc = qt.FirstStructureQueryColumn;

            if (qc != null)             // setup dummy criteria
            {
                ParsedStructureCriteria pssc = new ParsedStructureCriteria();
                pssc.SearchType = StructureSearchType.FullStructure;                 // just full structure search for now
                pssc.Molecule   = new MoleculeMx(MoleculeFormat.Smiles, "C");        // placeholder structure
                pssc.ConvertToQueryColumnCriteria(qc);

                qc.DisplayFormatString = "Highlight=true;Align=true";
            }

            string title = "Related Structures";

            qt.Label = title;

            DataTableMx dt = q.ResultsDataTable as DataTableMx;

            Qm = ToolHelper.SetupQueryManager(q, dt);

            MoleculeGridPageControl mgpc = RSC.MoleculeGridPageControl;
            MoleculeGridPanel       gp   = mgpc.MoleculeGridPanel;

            mgpc.Width  = RSC.Width - 3;            // be sure we have page control correctly sized
            mgpc.Height = RSC.Height - mgpc.Top - 3;

            ToolHelper.SetupGridPanelForDisplay(Qm, mgpc.MoleculeGridPanel, true, true);

            MoleculeGridControl grid = mgpc.MoleculeGrid;

            if (grid != null && grid.GV != null)
            {
                grid.GV.IndicatorWidth = 40;                 // narrow indicator a bit
            }
            //ToolHelper.DisplayData // build and display empty grid for query with columns scaled to fit the grid
            //		(q, dt, RSC.MoleculeGridPageControl.MoleculeGridPanel, true, true);

            return;
        }
Ejemplo n.º 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;
        }