private IMatrixData ProcessAplFiles(ProcessInfo processInfo, int nThreads, IList<MsRunImpl> aplfiles)
        {
            string tempFile = Path.Combine(FileUtils.GetTempFolder(), "spectraref.txt");
            if (File.Exists(tempFile)){
                File.Delete(tempFile);
            }
            IMatrixData matrix;
            StreamWriter writer = null;

            try{
                Enum[] enums = new Enum[]{spectraRef.raw_file, spectraRef.charge, spectraRef.scan_number, spectraRef.location, spectraRef.format, spectraRef.id_format, spectraRef.fragmentation, spectraRef.mz, spectraRef.index};
                IList<string> header = enums.Select(Constants.GetPattern).ToList();

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

                int nTasks = aplfiles.Count;

                processInfo.Progress(0);
                processInfo.Status(string.Format("Read Andromeda peaklist files [{0}|{1}]", 0, nTasks));

                writer = new StreamWriter(tempFile);
                writer.WriteLine(StringUtils.Concat("\t", header));
                writer.WriteLine("#!{Type}" + StringUtils.Concat("\t", header.Select(x => "T")));

                ThreadDistributor distr = new ThreadDistributor(nThreads, nTasks,
                                                                x =>
                                                                ParseAplFile(aplfiles[x], writer,
                                                                             string.Format(
                                                                                 "Read Andromeda peaklist files [{0}|{1}]",
                                                                                 x + 1, nTasks), (x + 1)*100/nTasks,
                                                                             processInfo));
                distr.Start();

                processInfo.Status("Close all files");

                writer.Close();
                writer.Dispose();
                writer = null;

                processInfo.Progress(0);
                processInfo.Status("Create SpectraRef matrix");

                matrix = new MatrixData();
                LoadData(matrix, tempFile, processInfo);
            }
            catch (Exception ex){
                throw ex;
            }
            finally{
                if (writer != null){
                    writer.Close();
                }

                if (File.Exists(tempFile)){
                    File.Delete(tempFile);
                }
            }

            return matrix;
        }
        private IMatrixData ProcessDbFiles(ProcessInfo processInfo, int nThreads, IList<Database> databases)
        {
            string tempFile = Path.Combine(FileUtils.GetTempFolder(), "databaseref.txt");
            IMatrixData matrix;
            StreamWriter writer = null;

            try{
                processInfo.Progress(0);
                processInfo.Status(string.Format("Read database files [{0}|{1}]", 0, "?"));

                Enum[] enums = new Enum[] { databaseRef.file, databaseRef.source, databaseRef.specie, databaseRef.taxid, databaseRef.version, databaseRef.identifier };
                IList<string> header = enums.Select(Constants.GetPattern).ToList();

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

                writer = new StreamWriter(tempFile);

                int nTasks = databases.Count;
                writer.WriteLine(StringUtils.Concat("\t", header));
                writer.WriteLine("#!{Type}" + StringUtils.Concat("\t", header.Select(x => "T")));

                ThreadDistributor distr = new ThreadDistributor(nThreads, nTasks,
                                                                x =>
                                                                ParseDatabase(writer, databases[x],
                                                                              string.Format(
                                                                                  "Read database files [{0}|{1}]",
                                                                                  x + 1, nTasks), (x + 1)*100/nTasks,
                                                                              processInfo));
                distr.Start();

                processInfo.Status("Close all files");

                writer.Close();
                writer.Dispose();
                writer = null;

                processInfo.Progress(0);
                processInfo.Status("Create DatabaseRef Matrix");

                matrix = new MatrixData();
                LoadData(matrix, tempFile, processInfo);
            }
            catch (Exception ex){
                throw ex;
            }
            finally{
                if (writer != null){
                    writer.Close();
                }

                if (File.Exists(tempFile)){
                    File.Delete(tempFile);
                }
            }

            return matrix;
        }
示例#3
0
 public Variant(Enum[] value)
 {
     this.Value = value.Select(v => Convert.ToInt32(v, CultureInfo.InvariantCulture)).ToArray();
     this.Type = VariantType.Int32;
     this.ArrayDimensions = new int[value.Rank];
     for (int i = 0; i < value.Rank; i++)
     {
         this.ArrayDimensions[i] = value.GetLength(i);
     }
 }