예제 #1
0
        public IAnalysisResult AnalyzeData(IMatrixData mdata, Parameters param, ProcessInfo processInfo)
        {
            var remoteExe = param.GetParam <string>(InterpreterLabel).Value;
            var inFile    = Path.GetTempFileName();

            PerseusUtils.WriteMatrixToFile(mdata, inFile);
            var paramFile = Path.GetTempFileName();

            param.ToFile(paramFile);
            var outFile = Path.GetTempFileName();

            if (!TryGetCodeFile(param, out string codeFile))
            {
                processInfo.ErrString = $"Code file '{codeFile}' was not found";
                return(null);
            }
            var args = $"{codeFile} {paramFile} {inFile} {outFile}";

            if (Utils.RunProcess(remoteExe, args, processInfo.Status, out string errorString) != 0)
            {
                processInfo.ErrString = errorString;
                return(null);
            }
            return(GenerateResult(outFile, mdata, processInfo));
        }
예제 #2
0
        public void ProcessData(IMatrixData inData, INetworkData outData, Parameters param, ref IData[] supplData, ProcessInfo processInfo)
        {
            var remoteExe = param.GetParam <string>(InterpreterLabel).Value;
            var inFile    = Path.GetTempFileName();

            PerseusUtils.WriteMatrixToFile(inData, inFile, false);
            var paramFile = Path.GetTempFileName();

            param.ToFile(paramFile);
            var outFolder = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());

            if (!TryGetCodeFile(param, out string codeFile))
            {
                processInfo.ErrString = $"Code file '{codeFile}' was not found";
                return;
            }
            var suppFiles = SupplDataTypes.Select(Utils.CreateTemporaryPath).ToArray();
            var args      = $"{codeFile} {paramFile} {inFile} {outFolder} {string.Join(" ", suppFiles)}";

            Debug.WriteLine($"executing > {remoteExe} {args}");
            if (Utils.RunProcess(remoteExe, args, processInfo.Status, out string processInfoErrString) != 0)
            {
                processInfo.ErrString = processInfoErrString;
                return;
            }
            ;
            FolderFormat.Read(outData, outFolder, processInfo);
            supplData = Utils.ReadSupplementaryData(suppFiles, SupplDataTypes, processInfo);
        }
예제 #3
0
        public IAnalysisResult AnalyzeData(IMatrixData mdata, Parameters param, ProcessInfo processInfo)
        {
            var remoteExe = param.GetParam <string>(InterpreterLabel).Value;

            if (string.IsNullOrWhiteSpace(remoteExe))
            {
                processInfo.ErrString = Resources.RemoteExeNotSpecified;
                return(null);
            }
            var inFile = Path.GetTempFileName();

            PerseusUtils.WriteMatrixToFile(mdata, inFile);
            var outFiles = new[] { Path.GetTempFileName() }
            .Concat(SupplDataTypes.Select(dataType => Path.GetTempFileName()))
            .ToArray();

            if (!TryGetCodeFile(param, out string codeFile))
            {
                processInfo.ErrString = $"Code file '{codeFile}' was not found";
                return(null);
            }
            var commandLineArguments = GetCommandLineArguments(param);
            var args = $"{codeFile} {commandLineArguments} {inFile} {string.Join(" ", outFiles)}";

            if (Utils.RunProcess(remoteExe, args, processInfo.Status, out string errorString) != 0)
            {
                processInfo.ErrString = errorString;
                return(null);
            }
            return(GenerateResult(outFiles, mdata, processInfo));
        }
예제 #4
0
        public static int WriteRNAFiles(IMatrixData mdata, Parameters param, Parameters dataParam, string workingDirectory, out string errString, string RNAexp)
        {
            //need to write a general version
            //accepts text only data for now

            string fileTempY = System.IO.Path.Combine(workingDirectory, @".\tempY.txt");
            string fileY     = System.IO.Path.Combine(workingDirectory, @".\fileY.txt");


            IMatrixData mCopyY = (IMatrixData)mdata.Clone();

            int[] nameInd = new[] { param.GetParam <int>("Gene Name Column").Value };

            int[] yInd = dataParam.GetParam <int[]>(RNAexp).Value;

            double baseVal = GetBase(dataParam.GetParamWithSubParams <int>(PECAParameters.dataFormGeneric));

            SetupMDataForInput(mCopyY, yInd, nameInd, baseVal);

            try
            {
                //hacky way of removing comments
                PerseusUtils.WriteMatrixToFile(mCopyY, fileTempY, false);
                RemoveCommentsFromFile(fileTempY, fileY);
            }
            catch (Exception e)
            {
                //need to reorganize this
                errString = e.ToString();
                return(-1);
            }

            errString = null;
            return(0);
        }
        public void Export(Parameters parameters, IMatrixData data, ProcessInfo processInfo)
        {
            string filename      = parameters.GetParam <string>("File name").Value;
            bool   addtlMatrices = parameters.GetParam <bool>("Write quality and imputed matrices").Value;

            addtlMatrices = addtlMatrices && data.IsImputed != null && data.Quality != null && data.IsImputed.IsInitialized() &&
                            data.Quality.IsInitialized();
            PerseusUtils.WriteMatrixToFile(data, filename, addtlMatrices);
        }
예제 #6
0
 public static ButtonParamWf DataPreviewButton(IMatrixData mdata)
 {
     return(new ButtonParamWf("Download data for preview", "save", (o, args) =>
     {
         var dialog = new SaveFileDialog
         {
             FileName = $"{mdata.Name}.txt",
             Filter = "tab-separated data, *.txt|*.txt"
         };
         if (dialog.ShowDialog() == DialogResult.OK)
         {
             PerseusUtils.WriteMatrixToFile(mdata, dialog.FileName, false);
         }
     }));
 }
예제 #7
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents,
                                ProcessInfo processInfo)
        {
            var remoteExe = param.GetParam <string>(InterpreterLabel).Value;

            if (string.IsNullOrWhiteSpace(remoteExe))
            {
                processInfo.ErrString = Resources.RemoteExeNotSpecified;
                return;
            }
            var inFile = Path.GetTempFileName();

            PerseusUtils.WriteMatrixToFile(mdata, inFile, AdditionalMatrices);
            var outFile = Path.GetTempFileName();

            if (!TryGetCodeFile(param, out string codeFile))
            {
                processInfo.ErrString = $"Code file '{codeFile}' was not found";
                return;
            }
            ;
            if (supplTables == null)
            {
                supplTables = Enumerable.Range(0, NumSupplTables).Select(i => PerseusFactory.CreateMatrixData()).ToArray();
            }
            var suppFiles            = supplTables.Select(i => Path.GetTempFileName()).ToArray();
            var commandLineArguments = GetCommandLineArguments(param);
            var args = $"{codeFile} {commandLineArguments} {inFile} {outFile} {string.Join(" ", suppFiles)}";

            Debug.WriteLine($"executing > {remoteExe} {args}");
            if (Utils.RunProcess(remoteExe, args, processInfo.Status, out string processInfoErrString) != 0)
            {
                processInfo.ErrString = processInfoErrString;
                return;
            }
            ;
            mdata.Clear();
            PerseusUtils.ReadMatrixFromFile(mdata, processInfo, outFile, '\t');
            for (int i = 0; i < NumSupplTables; i++)
            {
                PerseusUtils.ReadMatrixFromFile(supplTables[i], processInfo, suppFiles[i], '\t');
            }
        }
예제 #8
0
        public void ProcessData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents,
                                ProcessInfo processInfo)
        {
            var remoteExe = param.GetParam <string>(InterpreterLabel).Value;
            var inFile    = Path.GetTempFileName();

            PerseusUtils.WriteMatrixToFile(mdata, inFile, false);
            var paramFile = Path.GetTempFileName();

            param.ToFile(paramFile);
            var outFile  = Path.GetTempFileName();
            var codeFile = GetCodeFile(param);
            var args     = $"{codeFile} {paramFile} {inFile} {outFile}";

            Debug.WriteLine($"executing > {remoteExe} {args}");
            if (Utils.RunProcess(remoteExe, args, processInfo.Status, out string processInfoErrString) != 0)
            {
                processInfo.ErrString = processInfoErrString;
                return;
            }
            ;
            mdata.Clear();
            PerseusUtils.ReadMatrixFromFile(mdata, processInfo, outFile, '\t');
        }
예제 #9
0
        public static int WriteInputFiles(IMatrixData mdata, Parameters param, string workingDirectory, out string errString, string expSeries1 = "Expression Series 1", string expSeries2 = "Expression Series 2", string expSeries3 = "Expression Series 3")
        {
            //need to write a general version
            //accepts text only data for now



            //set as global
            string fileTempX = System.IO.Path.Combine(workingDirectory, @".\tempX.txt");
            string fileX     = System.IO.Path.Combine(workingDirectory, @".\fileX.txt");
            string fileTempM = System.IO.Path.Combine(workingDirectory, @".\tempM.txt");
            string fileM     = System.IO.Path.Combine(workingDirectory, @".\fileM.txt");
            string fileTempY = System.IO.Path.Combine(workingDirectory, @".\tempY.txt");
            string fileY     = System.IO.Path.Combine(workingDirectory, @".\fileY.txt");


            IMatrixData mCopyX = (IMatrixData)mdata.Clone();
            IMatrixData mCopyM = (IMatrixData)mdata.Clone();
            IMatrixData mCopyY = (IMatrixData)mdata.Clone();


            int[] nameInd = new[] { param.GetParam <int>("Gene Name Column").Value };

            int[] xInd = param.GetParam <int[]>(expSeries1).Value;
            int[] mInd = param.GetParam <int[]>(expSeries2).Value;
            int[] yInd = param.GetParam <int[]>(expSeries3).Value;

            //int n_tp = param.GetParam<int>("Number of Time Points").Value;
            int n_rep = param.GetParam <int>("Number of Replicates").Value;

            if (nameInd.Length == 0)
            {
                errString = "Please select a gene name column";
                return(-1);
            }
            if (xInd.Length == 0)
            {
                errString = "Please select some columns for Expression Series";
                return(-1);
            }

            if (xInd.Length != yInd.Length || xInd.Length != mInd.Length)
            {
                errString = "Expression Series need to have matching number of columns";
                return(-1);
            }

            if ((xInd.Length % n_rep) != 0)
            {
                errString = "number of columns not multiple of Number of Replicates";
                return(-1);
            }
            //check also timepoints here

            //if ((xInd.Length % n_tp)!=0)
            //{
            //    errString = "number of columns not multiple of Number of Time Points";
            //    return -1;
            //}

            double baseVal1 = PluginPECA.Utils.GetBase(param.GetParamWithSubParams <int>(PECAParameters.dataForm1));
            double baseVal2 = PluginPECA.Utils.GetBase(param.GetParamWithSubParams <int>(PECAParameters.dataForm2));
            double baseVal3 = PluginPECA.Utils.GetBase(param.GetParamWithSubParams <int>(PECAParameters.dataForm3));

            PluginPECA.Utils.SetupMDataForInput(mCopyX, xInd, nameInd, baseVal1);
            PluginPECA.Utils.SetupMDataForInput(mCopyM, mInd, nameInd, baseVal2);
            PluginPECA.Utils.SetupMDataForInput(mCopyY, yInd, nameInd, baseVal3);

            try
            {
                //hacky way of removing comments
                //better to just ask GS to ignore comments from his code
                PerseusUtils.WriteMatrixToFile(mCopyX, fileTempX, false);
                PluginPECA.Utils.RemoveCommentsFromFile(fileTempX, fileX);
                PerseusUtils.WriteMatrixToFile(mCopyM, fileTempM, false);
                PluginPECA.Utils.RemoveCommentsFromFile(fileTempM, fileM);
                PerseusUtils.WriteMatrixToFile(mCopyY, fileTempY, false);
                PluginPECA.Utils.RemoveCommentsFromFile(fileTempY, fileY);
            }
            catch (Exception e)
            {
                //need to reorganize this
                errString = e.ToString();
                return(-1);
            }

            errString = null;
            return(0);
        }