Exemplo n.º 1
0
        /// <summary>
        /// Read supplementary files according to file paths and data types.
        /// </summary>
        /// <param name="suppFiles"></param>
        /// <param name="supplDataTypes"></param>
        /// <param name="processInfo"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public static IData[] ReadSupplementaryData(string[] suppFiles, DataType[] supplDataTypes, ProcessInfo processInfo)
        {
            var numSupplTables = suppFiles.Length;

            IData[] supplData = new IData[numSupplTables];
            for (int i = 0; i < numSupplTables; i++)
            {
                switch (supplDataTypes[i])
                {
                case DataType.Matrix:
                    var mdata = PerseusFactory.CreateMatrixData();
                    PerseusUtils.ReadMatrixFromFile(mdata, processInfo, suppFiles[i], '\t');
                    supplData[i] = mdata;
                    break;

                case DataType.Network:
                    var ndata = PerseusFactory.CreateNetworkData();
                    FolderFormat.Read(ndata, suppFiles[i], processInfo);
                    supplData[i] = ndata;
                    break;

                default:
                    throw new NotImplementedException($"Data type {supplDataTypes[i]} not supported!");
                }
            }
            return(supplData);
        }
Exemplo n.º 2
0
        public void LoadData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents,
                             ProcessInfo processInfo)
        {
            var remoteExe = GetExectuable(param);
            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;
            }
            ;
            if (supplTables == null)
            {
                supplTables = Enumerable.Range(0, NumSupplTables).Select(i => PerseusFactory.CreateMatrixData()).ToArray();
            }
            var suppFiles = supplTables.Select(i => Path.GetTempFileName()).ToArray();
            var args      = $"{codeFile} {paramFile} {outFile} {string.Join(" ", suppFiles)}";

            Debug.WriteLine($"executing > {remoteExe} {args}");
            if (Utils.RunProcess(remoteExe, args, processInfo.Status, out string processInfoErrString) != 0)
            {
                processInfo.ErrString = processInfoErrString;
                return;
            }
            ;
            PerseusUtils.ReadMatrixFromFile(mdata, processInfo, outFile, '\t');
            for (int i = 0; i < NumSupplTables; i++)
            {
                PerseusUtils.ReadMatrixFromFile(supplTables[i], processInfo, suppFiles[i], '\t');
            }
        }
Exemplo n.º 3
0
        private static void ReadMatrixDataInto(IDataWithAnnotationColumns data, string file, ProcessInfo processInfo)
        {
            var mdata = PerseusFactory.CreateMatrixData();

            PerseusUtils.ReadMatrixFromFile(mdata, processInfo, file, '\t');
            data.CopyAnnotationColumnsFrom(mdata);
        }
        public void LoadData(IMatrixData mdata, Parameters parameters, ref IMatrixData[] supplTables,
                             ref IDocumentData[] documents, ProcessInfo processInfo)
        {
            PerseusLoadMatrixParam par = (PerseusLoadMatrixParam)parameters.GetParam("File");
            string filename            = par.Filename;

            if (string.IsNullOrEmpty(filename))
            {
                processInfo.ErrString = "Please specify a filename";
                return;
            }
            PerseusUtils.ReadMatrixFromFile(mdata, processInfo, filename, par.MainColumnIndices, par.NumericalColumnIndices,
                                            par.CategoryColumnIndices, par.TextColumnIndices, par.MultiNumericalColumnIndices, par.MainFilterParameters,
                                            par.NumericalFilterParameters, par.ShortenExpressionColumnNames);
        }
Exemplo n.º 5
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');
            }
        }
Exemplo n.º 6
0
        public void LoadData(IMatrixData mdata, Parameters param, ref IMatrixData[] supplTables, ref IDocumentData[] documents,
                             ProcessInfo processInfo)
        {
            var remoteExe = GetExectuable(param);
            var paramFile = Path.GetTempFileName();

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

            Debug.WriteLine($"executing > {remoteExe} {args}");
            if (Utils.RunProcess(remoteExe, args, processInfo.Status, out string processInfoErrString) != 0)
            {
                processInfo.ErrString = processInfoErrString;
                return;
            }
            ;
            PerseusUtils.ReadMatrixFromFile(mdata, processInfo, outFile, '\t');
        }