Пример #1
0
/// <summary>
/// Write out the data and return the html/js to open the template .dxp file with the exported data file
/// </summary>
/// <param name="q"></param>
/// <param name="trvp"></param>
/// <returns></returns>

        public static string CreateSpotfireAnalysisDocument(
            Query q,
            TargetSummaryOptions trvp)
        {
            ExportParms ep = new ExportParms();

            ep.OutputDestination = OutputDest.TextFile;
            ep.ExportFileFormat  = ExportFileFormat.Csv;
            ep.OutputFileName    = TempFile.GetTempFileName(".csv");          // temp .csv file to export to
            ep.IncludeDataTypes  = true;

            string result = UalUtil.IQueryExec.RunQuery(q, ep);             // do the export

            if (result == null)
            {
                return(null);                      // just return if cancelled
            }
            string templateLibFolder =             // unc name of the lib folder (not currently used)
                                       ServicesIniFile.Read("SpotfireLibraryFolder");

            string templateLibUrl =             // url of the library containing the Mobius templates
                                    ServicesIniFile.Read("SpotfireLibraryUrl");

            templateLibUrl = @"http://[server]/SpotfireWeb/Library.aspx?folder=DCRT%20(chemistry)%20users/Mobius/Templates";

            string templateUrl = templateLibUrl + "/MultiDbView";

            string html = templateUrl;             // todo, build html/js to open the template with the specified file

            return(html);
        }
Пример #2
0
        /// <summary>
        /// Create a Spotfire Analysis Document displaying data for the specified
        /// query using the template and other formatting info in the SpotfireParms.
        /// </summary>
        /// <param name="q"></param>
        /// <param name="stp"></param>
        /// <returns></returns>

        public static string CreateSpotfireAnalysisDocument(
            Query q,
            TargetSummaryOptions trvp)
        {
            string serializedQuery = q.Serialize();
            string serializedTrvp  = trvp.Serialize();

            if (ServiceFacade.UseRemoteServices)
            {
                Mobius.Services.Native.INativeSession       nativeClient = ServiceFacade.CreateNativeSessionProxy();
                Services.Native.NativeMethodTransportObject resultObject =
                    ServiceFacade.InvokeNativeMethod(nativeClient,
                                                     (int)Services.Native.ServiceCodes.MobiusTargetResultsViewerService,
                                                     (int)Services.Native.ServiceOpCodes.MobiusTargetResultsViewerService.CreateSpotfireAnalysisDocument,
                                                     new Services.Native.NativeMethodTransportObject(new object[] { serializedQuery, serializedTrvp }));
                ((System.ServiceModel.IClientChannel)nativeClient).Close();
                if (resultObject == null || resultObject.Value == null)
                {
                    return(null);
                }
                string path = resultObject.Value.ToString();
                return(path);
            }

            else
            {
                q    = Query.Deserialize(serializedQuery);
                trvp = TargetSummaryOptions.Deserialize(serializedTrvp);
                string path = Mobius.ToolServices.TargetResultsViewerService.CreateSpotfireAnalysisDocument(q, trvp);
                return(path);
            }
        }
Пример #3
0
        /// <summary>
        /// Setup the form values
        /// </summary>
        /// <param name="tso"></param>

        public void SetFormValues(
            TargetSummaryOptions tso,
            bool allowDbChange)
        {
            InSetup = true;

            Tso = tso;                   // TargetSummaryOptions instance associated with this control

            Cids.Text = tso.CidCriteria; // set initial cid criteria
            InSetup   = false;

            return;
        }
Пример #4
0
        /// <summary>
        /// Allocate & initialize a TargetResultsViewerParms instance
        /// </summary>
        /// <returns></returns>

        public static TargetSummaryOptions GetPreferences()
        {
            TargetSummaryOptions tso;
            string tsoString = Preferences.Get("MultiDbViewerPrefs");

            if (Lex.Contains(tsoString, "MultiDbViewerPrefs"))
            {
                tso = TargetSummaryOptions.Deserialize(tsoString);
            }
            else
            {
                tso = new TargetSummaryOptions();
            }

            return(tso);
        }
Пример #5
0
/// <summary>
/// Load any target map info
/// </summary>

        void LoadTargetMap()
        {
            try
            {
                Tso = TargetSummaryOptions.GetFromMdbAssayOptionsColumn(Qt);
                if (Tso == null || Lex.IsNullOrEmpty(Tso.TargetMapName))
                {
                    return;
                }

                TargetMap = TargetMapDao.GetMapByLabel(Tso.TargetMapName);                 // get the basics
                TargetMap = TargetMapDao.GetMapWithCoords(TargetMap.Name);                 // get the coords
                return;
            }
            catch (Exception ex) { return; }             // just return if "none" or no longer exists
        }
Пример #6
0
        object IInvokeServiceOps.InvokeServiceOperation(int opCode, object[] args)
        {
            MobiusTargetResultsViewerService op = (MobiusTargetResultsViewerService)opCode;

            switch (op)
            {
            case MobiusTargetResultsViewerService.CreateSpotfireAnalysisDocument:
            {
                string            serializedQuery = (string)args[0];
                Mobius.Data.Query q = Mobius.Data.Query.Deserialize(serializedQuery);

                string serializedTrvp     = (string)args[1];
                TargetSummaryOptions trvp = TargetSummaryOptions.Deserialize(serializedTrvp);

                string path = Mobius.ToolServices.TargetResultsViewerService.CreateSpotfireAnalysisDocument(q, trvp);
                return(path);
            }
            }

            return(null);
        }
Пример #7
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);
        }
Пример #8
0
/// <summary>
/// Setup the form values
/// </summary>
/// <param name="tso"></param>

        public void SetFormValues(
            TargetSummaryOptions tso,
            bool allowDbChange)
        {
            InSetup = true;

            Tso = tso;             // TargetSummaryOptions instance associated with this control

            if (!Initialized)
            {
                InitializeTargetMapControl(tso);
            }

            Cids.Text         = tso.CidCriteria;     // set initial cid criteria
            Targets.Text      = tso.TargetList;
            GeneFamilies.Text = tso.GeneFamilies;

            if (Lex.Eq(tso.DbName, "CorpDb"))
            {
                CorpDb.Checked = true;
            }
            else
            {
                CorpDbAndChemblDb.Checked = true;
            }
            DatabaseGroupBox.Enabled = allowDbChange; // allow database changes only if no query so far

            TableView.Checked = true;                 // default view
            if (Lex.Eq(tso.PreferredView, "Table"))
            {
                TableView.Checked = true;
            }
            else if (Lex.Eq(tso.PreferredView, "Map"))
            {
                MapView.Checked = true;
            }
            else if (Lex.Eq(tso.PreferredView, "Network"))
            {
                NetworkView.Checked = true;
            }
            else if (Lex.Eq(tso.PreferredView, "Heatmap"))
            {
                HeatmapView.Checked = true;
            }
            else if (Lex.Eq(tso.PreferredView, "WebPlayer"))
            {
                WebPlayerView.Checked = true;
            }

            IncludeStructures.Checked = tso.IncludeStructures;

            TargetsWithActivesOnly.Checked = tso.TargetsWithActivesOnly;
            AssayTypes  = tso.AssayTypesToInclude;
            MaxCRC.Text = tso.CrcUpperBound;
            MinSP.Text  = tso.SpLowerBound;
            if (tso.UseMeans)
            {
                MeanSummarization.Checked = true;
            }
            else
            {
                MinMaxSummarization.Checked = true;
            }

            FilterableTargets.Text = tso.FilterableTargets;

            InSetup = false;

            return;
        }
Пример #9
0
/// <summary>
/// Save preferences
/// </summary>
/// <param name="tso"></param>

        public static void SavePreferences(TargetSummaryOptions tso)
        {
            string tsoString = tso.Serialize();

            Preferences.Set("MultiDbViewerPrefs", tsoString);
        }
Пример #10
0
/// <summary>
/// GetFormValues
/// </summary>
/// <param name="tso"></param>
/// <returns></returns>

        public bool GetFormValues(
            TargetSummaryOptions tso)
        {
            tso.CidCriteria  = Cids.Text;
            tso.TargetList   = Targets.Text;
            tso.GeneFamilies = GeneFamilies.Text;

            if (CorpDb.Checked)
            {
                tso.DbName = "CorpDb";
            }
            else
            {
                tso.DbName = "CorpDbChEMBL";
            }

            if (TableView.Checked)
            {
                tso.PreferredView = "Table";
            }

            else if (MapView.Checked)
            {
                tso.PreferredView = "Map";
            }

            else if (NetworkView.Checked)
            {
                tso.PreferredView = "Network";
            }

            else if (HeatmapView.Checked)
            {
                tso.PreferredView = "Heatmap";
            }

            else if (WebPlayerView.Checked)
            {
                tso.PreferredView = "WebPlayer";
            }

            else
            {
                throw new Exception("Unrecognized output format");
            }

            tso.IncludeStructures      = IncludeStructures.Checked;
            tso.TargetsWithActivesOnly = TargetsWithActivesOnly.Checked;
            tso.CrcUpperBound          = MaxCRC.Text;
            tso.SpLowerBound           = MinSP.Text;
            tso.UseMeans            = MeanSummarization.Checked;
            tso.AssayTypesToInclude = AssayTypes;

            tso.FilterableTargets = FilterableTargets.Text;

            string mapLabel = TargetMap.Text;

            tso.TargetMapName = "";

            if (mapLabel != "")
            {
                foreach (string name0 in TargetMapNamesAndLabels.Keys)
                {
                    if (Lex.Eq(TargetMapNamesAndLabels[name0], mapLabel))
                    {
                        tso.TargetMapName = name0;
                        break;
                    }
                }
            }

            tso.UserMapNames = Csv.JoinCsvString(UserMapNames);

            if (TargetsWithActivesOnly.Checked)             // (not currently used)
            {
                double d;
                if (!double.TryParse(MaxCRC.Text, out d))
                {
                    MessageBoxMx.Show("You must supply a valid upper CRC bound value.", UmlautMobius.String);
                    MaxCRC.Focus();
                    return(false);
                }

                if (!double.TryParse(MinSP.Text, out d))
                {
                    MessageBoxMx.Show("You must supply a valid lower SP bound value.", UmlautMobius.String);
                    MinSP.Focus();
                    return(false);
                }
            }

            return(true);
        }
Пример #11
0
/// <summary>
/// Initialize form with map info
/// </summary>
/// <param name="tso"></param>

        void InitializeTargetMapControl(TargetSummaryOptions tso)
        {
            MapLabelList = new List <string>();
            MapLabelDict = new Dictionary <string, object>();
            UserMapNames = new List <string>();                               // pathways specific to this user

            TargetMapNamesAndLabels = TargetMapDao.GetTargetNamesAndLabels(); // get full list of maps
            List <string> commonMapNames = TargetMapDao.GetCommonMapNames();  // get common maps

            foreach (string mapName in commonMapNames)
            {
                if (!TargetMapNamesAndLabels.ContainsKey(mapName))
                {
                    continue;
                }
                string mapLabel = TargetMapNamesAndLabels[mapName];
                MapLabelList.Add(mapLabel);
                MapLabelDict[mapLabel.ToUpper()] = null;
            }

            if (tso.UserMapNames.Length > 0)             // get user-specific pathways
            {
                List <string> sa = Csv.SplitCsvString(tso.UserMapNames);
                foreach (string mapName0 in sa)
                {
                    if (!TargetMapNamesAndLabels.ContainsKey(mapName0))
                    {
                        continue;
                    }
                    string mapLabel = TargetMapNamesAndLabels[mapName0];
                    if (MapLabelDict.ContainsKey(mapLabel.ToUpper()))
                    {
                        continue;                                                                   // don't add if already have
                    }
                    MapLabelList.Add(mapLabel);
                    MapLabelDict[mapLabel.ToUpper()] = null;
                    UserMapNames.Add(mapName0);
                }
            }

            Lex.SortList(MapLabelList);

            MapLabelList.Add("None");
            MapLabelList.Add("---------------");
            MapLabelList.Add("Retrieve KEGG Pathway...");             // allow addition of new pathway
            TargetMap.Properties.Items.Clear();
            TargetMap.Properties.Items.AddRange(MapLabelList);

            if (Lex.IsNullOrEmpty(tso.TargetMapName))
            {
                tso.TargetMapName = "General Multi-platform Dendogram";
            }
            SelectedTargetMap = tso.TargetMapName;
            if (String.IsNullOrEmpty(SelectedTargetMap))
            {
                SelectedTargetMap = MapLabelList[0];
            }
            if (TargetMapNamesAndLabels.ContainsKey(SelectedTargetMap))
            {
                SelectedTargetMap = TargetMapNamesAndLabels[SelectedTargetMap];
            }
            TargetMap.Text = SelectedTargetMap;

            Initialized = true;
        }
Пример #12
0
        /// <summary>
        /// GetFormValues
        /// </summary>
        /// <param name="tso"></param>
        /// <returns></returns>

        public bool GetFormValues(
            TargetSummaryOptions tso)
        {
            tso.CidCriteria = Cids.Text;
            return(true);
        }