示例#1
0
        bool SaveTask(string path, _Task _task)
        {
            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (!Directory.Exists(path + "\\param"))
                {
                    Directory.CreateDirectory(path + "\\param");
                }
                //Directory.CreateDirectory(path + "\\result");

                CreateTaskFile(path, _task);

                //generate pParse.cfg
                Factory.Create_pParse_Instance().pParse_write(_task);
                Factory.Create_pTop_Instance().pTop_write(_task);

                if (_task.T_Quantify.Quantitation_type != (int)Quant_Type.Label_None)
                {
                    Factory.Create_pQuant_Instance().pQuant_write(_task);
                }

                return(true);
            }
            catch (Exception exe)
            {
                MessageBox.Show(exe.Message + "\nSave Failed!");
                return(false);
            }
        }
示例#2
0
        public void SaveChangeTask(TaskBLL task, string assigneeName)
        {
            _Task taskForEdit = db.Tasks.Get(task.Id);

            if (taskForEdit != null)
            {
                if (!taskForEdit.ParentId.HasValue)
                {
                    if ((assigneeName == null) && (task.ParentId != null))
                    {
                        //We cannot change assignee for subtask - only for main task
                        throw new ArgumentNullException("assigneeName", "Cannot be null");
                    }
                    if (taskForEdit.Assignee.Name != assigneeName)
                    {
                        Person assignee;
                        assignee             = db.People.Find(p => (p.Name == assigneeName)).Single();
                        taskForEdit.Assignee = assignee;

                        if (taskForEdit.ParentId == null)
                        {
                            subtaskService.ChangeAssigneeOfSubtasks(taskForEdit.ParentId.Value, assignee.Id);
                        }
                    }
                }

                taskForEdit.Name    = task.Name;
                taskForEdit.ETA     = task.ETA;
                taskForEdit.DueDate = task.DueDate;
                taskForEdit.Comment = task.Comment;

                db.Tasks.Update(taskForEdit);
                db.Save();
            }
        }
示例#3
0
        bool SaveTask(string path, _Task _task)
        {
            try
            {
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                if (!Directory.Exists(path + "\\param"))
                {
                    Directory.CreateDirectory(path + "\\param");
                }
                //Directory.CreateDirectory(path + "\\result");


                //CreateTaskFile(path,_task); // comment by luolan @20150610

                //generate pParse.cfg
                Factory.Create_pParse_Instance().pParse_write(_task);
                Factory.Create_pTop_Instance().pTop_write(_task);

                return(true);
            }
            catch (Exception exe)
            {
                MessageBox.Show(exe.Message + "\nSave Failed!");
                return(false);
            }
        }
示例#4
0
 public ActionResult DeleteConfirmed(int id)
 {
     _Task _Task = db.Tasks.Find(id);
     db.Tasks.Remove(_Task);
     db.SaveChanges();
     return RedirectToAction("Index");
 }
示例#5
0
        public void DeleteTask(int taskId, string currentUserName)
        {
            TaskBLL task = mapper.Map <_Task, TaskBLL>(db.Tasks.Get(taskId));

            if (task == null)
            {
                throw new ArgumentException("Task with this id not found", "taskId");
            }

            if (task.Author.Name == currentUserName)
            {
                if (!task.ParentId.HasValue)
                {
                    IEnumerable <TaskBLL> subtasksForDelete = subtaskService.GetSubtasksOfTask(task.Id);
                    foreach (var subtask in subtasksForDelete)
                    {
                        db.Tasks.Delete(subtask.Id);
                    }
                }
                else
                {
                    //then need to calculate new progress for parent task
                    _Task parrentTask = db.Tasks.Get(task.ParentId.Value);
                    parrentTask.Progress = subtaskService.CalculateProgressOfSubtask(task.ParentId.Value, task.Id, deleting: true);
                    db.Tasks.Update(parrentTask);
                }
                db.Tasks.Delete(task.Id);
                db.Save();
            }
            else
            {
                throw new InvalidOperationException("Access error. You cannot delete this task");
            }
        }
示例#6
0
        public void ProcessAvailableTasks()
        {
            Console.WriteLine("Выберите задачу для выполнения:");
            for (int i = 1; i < _tasks.Count + 1; ++i)
            {
                _Task task = _tasks[i - 1];
                Console.WriteLine("{0}. {1}".f(i.ToString(), task.Name));
            }
            Console.WriteLine("{0}. {1}.".f((_tasks.Count + 1).ToString(), "Все"));
            Console.WriteLine("{0}.".f("Для выхода наберите x"));
            string inc;

            do
            {
                Console.Write("Номер задачи: ");
                int value;
                inc = Console.ReadLine();
                if (int.TryParse(inc, out value) && value != default(int))
                {
                    value--;
                    if (value == _tasks.Count)
                    {
                        ExecuteTasks();
                    }
                    else
                    {
                        ExecuteTask(value);
                    }
                }
            }while (inc != null && inc.ToLower() != "x");
        }
示例#7
0
        public void AddSubtask(TaskBLL subtask, int taskId, bool forceToSave = true)
        {
            var task = mapper.Map <_Task, TaskBLL>(db.Tasks.Get(taskId));

            if (task == null)
            {
                throw new ArgumentException("Parent task wasn't found", "taskId");
            }

            var status = mapper.Map <Status, StatusBLL>(db.Statuses.Find(s => (s.Name == "New")).Single());

            var newSubtask = new TaskBLL
            {
                ParentId  = task.Id,
                Author    = task.Author,
                Name      = subtask.Name,
                Assignee  = task.Assignee,
                Status    = status,
                Progress  = 0,
                DateStart = null,
                ETA       = subtask.ETA,
                DueDate   = subtask.DueDate,
                Comment   = subtask.Comment
            };

            db.Tasks.Create(mapper.Map <TaskBLL, _Task>(newSubtask));

            if (forceToSave)
            {
                _Task parentTask = db.Tasks.Get(taskId);
                parentTask.Progress = CalculateProgressOfSubtask(taskId, 1);
                db.Tasks.Update(parentTask);
                db.Save();
            }
        }
示例#8
0
        bool SaveTask(string path, _Task _task)
        {
            try
            {
                if (Directory.Exists(path))
                {
                    //迟浩:感觉现在对话框提示有点多了,只提示有修改的话需要保存即可,至于是否覆盖则不提示。尝试一下,如果有不妥,再修改

                    //String tmp = "The Directory Already Contains An Item Named '" + _task.Task_name + "' .\n Do you want to overwrite it ?";
                    //MessageBoxResult result = System.Windows.MessageBox.Show(tmp, "pFind", MessageBoxButton.OKCancel, MessageBoxImage.Question);
                    //if (result == MessageBoxResult.Cancel)  //No
                    //{
                    //    return false;  //cancel, or rename the task and then save
                    //}
                }
                else
                {
                    Directory.CreateDirectory(path);
                    Directory.CreateDirectory(path + "\\param");
                    Directory.CreateDirectory(path + "\\result");
                }

                //wrm 2014/10/20:
                CreateTaskFile(path, _task);
                //System.IO.File.Create(path + "\\pFind.pFind");
                //generate pParse.para
                Factory.Create_pParse_Instance().pParse_write(_task);
                //generate pFind.pfd
                Factory.Create_pFind_Instance().pFind_write(_task);

                if (_task.T_File.File_format.Equals("raw"))
                {
                    Factory.Create_pQuant_Instance().pQuant_write(_task);
                }
                else
                {
                    if (System.IO.File.Exists(path + "\\param\\pQuant.cfg"))
                    {
                        System.IO.File.Delete(path + "\\param\\pQuant.cfg");
                    }
                }
                if (_task.T_MS2Quant.Enable_ms2quant)
                {
                    Factory.Create_pQuant_Instance().pIsobariQ_write(_task);
                }

                if (path[path.Length - 1] == '\\')
                {
                    path = path.Substring(0, path.Length - 1);
                }
                ConfigHelper.update_recent_task(Advanced.recent_tasks_file_path, path);
                return(true);
            }
            catch (Exception exe)
            {
                MessageBox.Show(exe.Message + "\nSave Failed!");
                return(false);
            }
        }
示例#9
0
 public Rename(ref _Task _task)
 {
     InitializeComponent();
     this.TaskReName.Text = _task.Task_name;
     this.TaskReName.Focus();
     this.TaskReName.SelectAll();
     tsk = _task;
 }
示例#10
0
        void pParse_Inter.pParse_write(_Task _task)
        {
            /**产生pParse.cfg**/
            try
            {
                pTop.classes.File _file    = _task.T_File;
                string            filepath = _task.Path + "param\\pParseTD.cfg";
                FileStream        pPfst    = new FileStream(filepath, FileMode.Create, FileAccess.Write);
                StreamWriter      pPsw     = new StreamWriter(pPfst, Encoding.Default);
                pPsw.WriteLine("# This is a standard pParseTD configuration file");
                pPsw.WriteLine("# For help: mail to [email protected]");
                pPsw.WriteLine("# Time: " + DateTime.Now.ToString());
                pPsw.WriteLine();
                pPsw.WriteLine("[Basic Options]");
                pPsw.WriteLine("datanum=" + _file.Data_file_list.Count.ToString());
                if (_file.Data_file_list.Count == 0)
                {
                    _task.Check_ok = false;
                }
                for (int i = 0; i < _file.Data_file_list.Count; i++)
                {
                    pPsw.WriteLine("datapath" + (i + 1).ToString() + "=" + _file.Data_file_list[i].FilePath);
                }
                pPsw.WriteLine("input_format=" + (_file.File_format_index == (int)FormatOptions.RAW ? "raw":"mgf"));
                pPsw.WriteLine();
                pPsw.WriteLine("[Advanced Options]");
                pPsw.WriteLine("max_charge=" + _file.Pparse_advanced.Max_charge);
                pPsw.WriteLine("max_mass=" + _file.Pparse_advanced.Max_mass);
                pPsw.WriteLine("SN_threshold=" + _file.Pparse_advanced.Sn_ratio);
                pPsw.WriteLine("mz_error_tolerance=" + _file.Pparse_advanced.Mz_tolerance);
                pPsw.WriteLine();
                string co = _file.Pparse_advanced.Mix_spectra == true ? "1" : "0";
                pPsw.WriteLine("co-elute=" + co);
                //pPsw.WriteLine("# 0, output single precursor for single scan;");
                //pPsw.WriteLine("# 1, output all co-eluted precursors.");
                pPsw.WriteLine("isolation_width=" + _file.Pparse_advanced.Isolation_width.ToString());
                pPsw.WriteLine();
                //pPsw.WriteLine("model_type=" +( _file.Pparse_advanced.Model == (int)ModelOptions.SVM ? "svm" : "mars"));
                //pPsw.WriteLine("mars_threshold=" + _file.Pparse_advanced.Threshold);
                pPsw.WriteLine();
                if (_file.Pparse_advanced.Threshold.ToString() == "" || _file.Pparse_advanced.Mz_decimal.ToString() == "" || _file.Pparse_advanced.Intensity_decimal.ToString() == "")
                {
                    _task.Check_ok = false;
                }

                pPsw.WriteLine("[About pXtract]");
                pPsw.WriteLine("m/z=" + _file.Pparse_advanced.Mz_decimal.ToString());
                pPsw.WriteLine("Intensity=" + _file.Pparse_advanced.Intensity_decimal.ToString());
                pPsw.Close();
                pPfst.Close();
            }
            catch (Exception exe)
            {
                throw new Exception(exe.Message);
            }
        }
示例#11
0
        //创建任务文件

        void CreateTaskFile(string path, _Task _task)
        {
            FileStream   tskst = new FileStream(path + "\\" + _task.Task_name + ".tsk", FileMode.Create, FileAccess.Write);
            StreamWriter tsksw = new StreamWriter(tskst, Encoding.Default);

            tsksw.WriteLine("pTop Task File, Format Version " + ConfigHelper.ptop_version);
            tsksw.WriteLine("# pTop " + ConfigHelper.ptop_version);
            tsksw.Close();
            tskst.Close();
        }
示例#12
0
        //创建任务文件
        //wrm 2014/10/20:
        void CreateTaskFile(string path, _Task _task)
        {
            FileStream   tskst = new FileStream(path + "\\" + _task.Task_name + ".tsk", FileMode.Create, FileAccess.Write);
            StreamWriter tsksw = new StreamWriter(tskst, Encoding.Default);

            tsksw.WriteLine("pFind Studio Task File, Format Version 3.0");
            tsksw.WriteLine("# pFind 3.0");
            tsksw.Close();
            tskst.Close();
        }
示例#13
0
 public ActionResult Edit([Bind(Include = "Id,Description,IsDone")] _Task _Task)
 {
     if (ModelState.IsValid)
     {
         db.Entry(_Task).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(_Task);
 }
示例#14
0
        //begin search
        //void Run_Inter.StartSearchWork(_Task _task)
        //{
        //    try
        //    {
        //        if (_task.Check_ok == false)
        //        {
        //            MessageBox.Show("The configuration is not completed!", "pFind", MessageBoxButton.OK, MessageBoxImage.Warning);
        //        }
        //        else
        //        {
        //            Factory.Create_Run_Instance().SaveParams(_task);
        //            Process process = new Process();

        //            process.StartInfo.UseShellExecute = false;
        //            process.StartInfo.CreateNoWindow = true;
        //            process.StartInfo.RedirectStandardOutput = true;
        //            process.StartInfo.RedirectStandardError = true;

        //            if (_task.T_File.File_format.Equals("raw"))
        //            {
        //                for (int i = 0; i < _task.T_File.Data_file_list.Count; i++)
        //                {

        //                    string xtract = "-a -ms -m " + _task.T_File.Mz_decimal.ToString() + " -i " + _task.T_File.Intensity_decimal.ToString() + " \"" + _task.T_File.Data_file_list[i].FilePath.ToString() + "\"";
        //                    process.StartInfo.FileName = "xtract.exe";
        //                    process.StartInfo.Arguments = xtract;
        //                    if (process.Start())
        //                    {

        //                    }
        //                    process.WaitForExit();

        //                }

        //                process.StartInfo.FileName = "pParse.exe";
        //                process.StartInfo.Arguments = _task.Path + "param\\pParse.para";
        //                if (process.Start())
        //                {

        //                }
        //                process.WaitForExit();

        //            }
        //            process.StartInfo.FileName = "pFind.exe";
        //            process.StartInfo.Arguments = _task.Path + "param\\pFind.pfd";
        //            if (process.Start())
        //            {

        //            }
        //            process.WaitForExit();

        //            process.Close();
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Console.Write(ex.Message);
        //        System.Windows.MessageBox.Show("Sorry, there is something wrong with pFind!");
        //    }
        //}


        //check params of the task
        bool Run_Inter.Check_Task(_Task _task)
        {
            File              _file = _task.T_File;
            SearchParam       _sp   = _task.T_Search;
            FilterParam       _fp   = _task.T_Filter;
            QuantitationParam _qp   = _task.T_Quantitation;

            //check file
            if (_file.File_format_index != (int)FormatOptions.MGF && _file.File_format_index != (int)FormatOptions.RAW)
            {
                return(false);
            }
            if (_file.Data_file_list == null || _file.Data_file_list.Count == 0)
            {
                return(false);
            }
            #region Todo
            //参数检查
            #endregion
            if (_file.Threshold.ToString() == "")
            {
                return(false);
            }
            //check search
            if (_sp.Ptl.Tl_value.ToString() == "" || _sp.Ftl.Tl_value.ToString() == "")
            {
                return(false);
            }
            if (_sp.Db.Db_name == "null" || _sp.Db.Db_path == "null")
            {
                return(false);
            }
            //check filter
            if (_fp.Fdr.Fdr_value.ToString() == "")
            {
                return(false);
            }
            if (_fp.Pep_mass_range.Left_value.ToString() == "" || _fp.Pep_mass_range.Right_value.ToString() == "" || _fp.Pep_mass_range.Left_value > _fp.Pep_mass_range.Right_value)
            {
                return(false);
            }
            if (_fp.Pep_length_range.Left_value.ToString() == "" || _fp.Pep_length_range.Right_value.ToString() == "" || _fp.Pep_length_range.Left_value > _fp.Pep_length_range.Right_value)
            {
                return(false);
            }
            if (_fp.Min_pep_num.ToString() == "")
            {
                return(false);
            }
            //check Quantitation

            _task.Check_ok = true;

            return(true);
        }
示例#15
0
 bool Run_Inter.SaveAsParams(string path, _Task _task)
 {
     try
     {
         return(SaveTask(path, _task));
     }
     catch (Exception exe)
     {
         throw new Exception(exe.Message);
     }
 }
示例#16
0
 //save params
 bool Run_Inter.SaveParams(_Task _task)
 {
     try
     {
         string pathName = _task.Path.Trim();
         return(SaveTask(pathName, _task));
     }
     catch (Exception exe)
     {
         throw new Exception(exe.Message);
     }
 }
示例#17
0
 // GET: _Tasks/Details/5
 public ActionResult Details(int? id)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     _Task _Task = db.Tasks.Find(id);
     if (_Task == null)
     {
         return HttpNotFound();
     }
     return View(_Task);
 }
示例#18
0
        public ActionResult Create([Bind(Include = "Id,Description,IsDone")] _Task _Task)
        {
            if (ModelState.IsValid)
            {
                string currentUserId = User.Identity.GetUserId();
                ApplicationUser currentUser = db.Users.FirstOrDefault(
                    x => x.Id == currentUserId);

                _Task.User = currentUser;
                db.Tasks.Add(_Task);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(_Task);
        }
示例#19
0
        public ActionResult AJAXCreate([Bind(Include = "Id,Description")] _Task _Task)
        {
            if (ModelState.IsValid)
            {
                string currentUserId = User.Identity.GetUserId();
                ApplicationUser currentUser = db.Users.FirstOrDefault(
                    x => x.Id == currentUserId);

                _Task.User = currentUser;
                _Task.IsDone = false;
                db.Tasks.Add(_Task);
                db.SaveChanges();
            }

            return PartialView("_TaskTable", Get_Tasks());
        }
示例#20
0
        private void AddBtn_Click(object sender, EventArgs e)
        {
            try
            {
                _Task task = new _Task(content, deadline);



                _Tasks.Add(task);
                TaskSerializer(_Tasks, path);
                Logger.Log($"Задание:{task.Content}, дедлайн {task.DeadLine}");
            }catch (Exception ex)
            {
                MessageBox.Show($"Возникла ошибка: {ex.Message}");
            }
        }
示例#21
0
 //写入鉴定结果文件路径
 void pQuant_Inter.pQuant_writeResultFile(_Task _task)
 {
     try
     {
         FileStream    fst     = new FileStream(_task.Path + "\\param\\pQuant.cfg", FileMode.Open);
         StreamReader  sr      = new StreamReader(fst, Encoding.Default);
         string        strLine = sr.ReadLine();
         List <string> text    = new List <string>();
         while (strLine != null)
         {
             if (strLine.Trim() == "")
             {
                 text.Add("");
             }
             else if (strLine.Trim().Length > 0 && strLine.Contains("=") && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("PATH_IDENTIFICATION_FILE"))
             {
                 string resultfile = ConfigHelper.getFileBySuffix(_task.Path + "result\\", "spectra");
                 text.Add("PATH_IDENTIFICATION_FILE=" + resultfile + "|;");
             }
             else
             {
                 text.Add(strLine);
             }
             strLine = sr.ReadLine();
         }
         sr.Close();
         fst.Close();
         fst = new FileStream(_task.Path + "\\param\\pQuant.cfg", FileMode.Open, FileAccess.Write);
         StreamWriter sw = new StreamWriter(fst, Encoding.Default);
         foreach (string str in text)
         {
             sw.WriteLine(str);
         }
         sw.Flush();
         sw.Close();
         fst.Close();
     }
     catch (Exception exe)
     {
         throw new Exception(exe.Message);
     }
 }
示例#22
0
            private static TResult DoRun(object taskData)
            {
                _Task <TResult, TState> task = ((Data <TResult, TState>)taskData).Task;

                if (task._prev != null)
                {
                    try
                    {
                        task._prev.Wait();
                    }
                    catch (AggregateException ex)
                    {
                        if (!(ex.InnerException is TaskCanceledException))
                        {
                            throw ex.InnerException;
                        }
                    }
                }
                return(task._config.RunFunction(task));
            }
示例#23
0
 public ActionResult AJAXEdit(int? id, bool value)
 {
     if (id == null)
     {
         return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
     }
     _Task _Task = db.Tasks.Find(id);
     if (_Task == null)
     {
         return HttpNotFound();
     }
     else
     {
         _Task.IsDone = value;
         db.Entry(_Task).State = EntityState.Modified;
         db.SaveChanges();
         return PartialView("_TaskTable", Get_Tasks());
     }
     
 }
        public void AddSubtasksFromTemplate(int taskId, int templateId, string authorName)
        {
            IEnumerable <TaskTemplateBLL> subtaskNames = GetSubtasksOfTemplate(templateId);

            if (!subtaskNames.Any())
            {
                throw new ArgumentException("subtasks from template with this Id wasn't found", "templateId");
            }

            if (string.IsNullOrWhiteSpace(authorName))
            {
                throw new ArgumentNullException("Name of author is null or empty", "authorName");
            }
            PersonBLL author = mapper.Map <Person, PersonBLL>(db.People.Find(p => (p.Name == authorName)).SingleOrDefault());

            if (author == null)
            {
                throw new ArgumentException("Author with tis name wasn't found", "authorName");
            }

            foreach (var subtaskName in subtaskNames)
            {
                var subtask = new TaskBLL
                {
                    Name     = subtaskName.Name,
                    ParentId = taskId,
                    ETA      = null,
                    DueDate  = null,
                    Comment  = null,
                    Author   = author
                };
                subtaskService.AddSubtask(subtask, taskId, false);
            }

            _Task parentTask = db.Tasks.Get(taskId);

            parentTask.Progress = subtaskService.CalculateProgressOfSubtask(taskId, subtaskNames.Count());
            db.Tasks.Update(parentTask);
            db.Save();
        }
示例#25
0
        void Run_Inter.JustSaveParams(_Task _task)
        {
            string pathName = _task.Path;

            Directory.CreateDirectory(pathName);
            CreateTaskFile(pathName, _task);
            Directory.CreateDirectory(pathName + "\\param");
            Directory.CreateDirectory(pathName + "\\result");

            if (_task.T_File.File_format.Equals("raw"))
            {
                //generate pParse.para,pQuant.qnt
                Factory.Create_pParse_Instance().pParse_write(_task);
                Factory.Create_pQuant_Instance().pQuant_write(_task);
            }
            //generate pFind.pfd
            Factory.Create_pFind_Instance().pFind_write(_task);
            if (_task.T_MS2Quant.Enable_ms2quant)
            {
                Factory.Create_pQuant_Instance().pIsobariQ_write(_task);
            }
        }
示例#26
0
        //read from pFind.pfd
        void pFind_Inter.readpFind_pfd(string task_path, bool pParse, ref _Task _task)
        {
            try
            {
                File              _file         = _task.T_File;
                SearchParam       _search       = _task.T_Search;
                FilterParam       _filter       = _task.T_Filter;
                QuantitationParam _quantitation = _task.T_Quantitation;

                FileStream   fst      = new FileStream(task_path + "\\param\\pFind.cfg", FileMode.Open);
                StreamReader sr       = new StreamReader(fst, Encoding.Default);
                string       strLine  = sr.ReadLine();
                string       subtitle = "";
                #region
                while (strLine != null)
                {
                    strLine = strLine.Trim();
                    if (strLine.Length > 0 && strLine[0] == '#')
                    {
                        strLine = sr.ReadLine();
                        continue;
                    }
                    if (strLine.Length > 0 && strLine[0] == '[' && strLine[strLine.Length - 1] == ']')
                    {
                        subtitle = strLine;
                    }
                    else
                    {
                        #region [param]
                        if (subtitle.Equals("[param]"))
                        {
                            if (strLine.Length > 15 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("activation_type"))
                            {
                                _file.Instrument = strLine.Substring(strLine.LastIndexOf("=") + 1);
                                _file.setInstrument_index();
                            }
                            else if (strLine.Length > 5 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("mstol"))
                            {
                                _search.Ptl.Tl_value = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 8 && strLine.Substring(0, 8).Equals("mstolppm"))
                            {
                                _search.Ptl.Isppm = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 7 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("msmstol"))
                            {
                                _search.Ftl.Tl_value = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 10 && strLine.Substring(0, 10).Equals("msmstolppm"))
                            {
                                _search.Ftl.Isppm = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }

                            else if (strLine.Length > 10 && strLine.Substring(0, 10).Equals("temppepnum"))
                            {
                                _search.Search_advanced.Temppepnum = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 6 && strLine.Substring(0, 6).Equals("pepnum"))
                            {
                                _search.Search_advanced.Pepnum = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 10 && strLine.Substring(0, 10).Equals("selectpeak"))
                            {
                                _search.Search_advanced.Selectpeak = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 9 && strLine.Substring(0, 9).Equals("maxprolen"))
                            {
                                _search.Search_advanced.Maxprolen = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 7 && strLine.Substring(0, 7).Equals("maxspec"))
                            {
                                _search.Search_advanced.Maxspec = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > "IeqL".Length && strLine.Substring(0, "IeqL".Length).Equals("IeqL"))
                            {
                                _search.Search_advanced.IeqL = (strLine.Substring(strLine.LastIndexOf("=") + 1) == "1") ? true : false;
                            }
                            else if (strLine.Length > "npep".Length && strLine.Substring(0, "npep".Length).Equals("npep"))
                            {
                                _search.Search_advanced.NPeP = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > "maxdelta".Length && strLine.Substring(0, "maxdelta".Length).Equals("maxdelta"))
                            {
                                _search.Search_advanced.MAXDelta = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 9 && strLine.Substring(0, 9).Equals("selectmod"))
                            {
                                string tmpvar = strLine.Trim();
                                string tmpfix = sr.ReadLine().Trim();
                                if (tmpvar.Equals("selectmod="))
                                {
                                    if (tmpfix.Equals("fixmod="))
                                    {
                                        //_search.Open_search = true;
                                    }
                                    _search.Var_mods.Clear();
                                }
                                else
                                {
                                    tmpvar = tmpvar.Substring(strLine.LastIndexOf("=") + 1);
                                    //_search.Open_search = false;
                                    string[] tmpv = tmpvar.Split(';');
                                    foreach (string c in tmpv)
                                    {
                                        if (c != "")
                                        {
                                            _search.Var_mods.Add(c);
                                        }
                                    }
                                }
                                if (tmpfix.Equals("fixmod="))
                                {
                                    _search.Fix_mods.Clear();
                                }
                                else
                                {
                                    tmpfix = tmpfix.Substring(tmpfix.LastIndexOf("=") + 1);
                                    //_search.Open_search = false;
                                    string[] tmpf = tmpfix.Split(';');
                                    foreach (string c in tmpf)
                                    {
                                        if (c != null)
                                        {
                                            _search.Fix_mods.Add(c);
                                        }
                                    }
                                }
                            }
                            else if (strLine.Length > 6 && strLine.Substring(0, 6).Equals("maxmod"))
                            {
                                _search.Search_advanced.Maxmod = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 6 && strLine.Substring(0, 6).Equals("enzyme"))
                            {
                                _search.Enzyme       = strLine.Substring(strLine.LastIndexOf("=") + 1);
                                _search.Enzyme_index = _search.setEnzymeIndex();
                            }
                            else if (strLine.Length > 6 && strLine.Substring(0, 6).Equals("digest"))
                            {
                                int digestway = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                                if (digestway == 3)
                                {
                                    _search.Enzyme_Spec_index = 0;
                                }
                                else if (digestway > 0)
                                {
                                    _search.Enzyme_Spec_index = 1;
                                }
                                else
                                {
                                    _search.Enzyme_Spec_index = 2;
                                }
                                _search.setEnzymeSpec();
                            }
                            else if (strLine.Length > 13 && strLine.Substring(0, 13).Equals("max_clv_sites"))
                            {
                                _search.Cleavages = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                        }
                        #endregion
                        #region [filter]
                        if (subtitle.Equals("[filter]"))
                        {
                            if (strLine.Length > 7 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("psm_fdr"))
                            {
                                _filter.Fdr.Fdr_value = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1)) * 100;
                            }
                            else if (strLine.Length > 12 && strLine.Substring(0, 8).Equals("psm_fdr_type"))
                            {
                                _filter.Fdr.IsPeptides = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 10 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("mass_lower"))
                            {
                                _filter.Pep_mass_range.Left_value = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 10 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("mass_upper"))
                            {
                                _filter.Pep_mass_range.Right_value = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 9 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("len_lower"))
                            {
                                _filter.Pep_length_range.Left_value = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 9 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("len_upper"))
                            {
                                _filter.Pep_length_range.Right_value = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 11 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("pep_per_pro"))
                            {
                                _filter.Min_pep_num = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 7 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("pro_fdr"))
                            {
                                _filter.Protein_Fdr = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1)) * 100;
                            }
                        }
                        #endregion

                        else if (subtitle.Equals("[engine]"))
                        {
                            if (strLine.Length > 4 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("open"))
                            {
                                _search.Open_search = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1)) == 1 ? true : false;
                            }
                            else if (strLine.Length > 12 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("open_tag_len"))
                            {
                                _search.Search_advanced.Open_tag_len = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 18 && strLine.Substring(0, 18).Equals("rest_tag_iteration"))
                            {
                                _search.Search_advanced.Rest_tag_iteration = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 12 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("rest_tag_len"))
                            {
                                _search.Search_advanced.Rest_tag_len = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 12 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("rest_mod_num"))
                            {
                                _search.Search_advanced.Rest_mod_num = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 15 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("salvo_iteration"))
                            {
                                _search.Search_advanced.Salvo_iteration = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                            else if (strLine.Length > 13 && strLine.Substring(0, strLine.LastIndexOf("=")).Equals("salvo_mod_num"))
                            {
                                _search.Search_advanced.Salvo_mod_num = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            }
                        }
                        #region file
                        else if (subtitle.Equals("[file]"))
                        {
                            if (strLine.Length > 9 && strLine.Substring(0, 9).Equals("fastapath"))
                            {
                                string db_path = strLine.Substring(strLine.LastIndexOf("=") + 1);
                                if (db_path.Trim().Length > 0)
                                {
                                    DB db = new DB();
                                    db.Db_path = db_path;
                                    if (ConfigHelper.ReDBmap.Contains(db.Db_path))
                                    {
                                        db.Db_name       = ConfigHelper.ReDBmap[db.Db_path].ToString();
                                        _search.Db       = db;
                                        _search.Db_index = _search.setDatabaseIndex();
                                    }
                                    else     //the database is damaged
                                    {
                                        _search.Db_index = -1;
                                        _search.Db       = db;
                                    }
                                }
                                else   //when new a task
                                {
                                    _search.Db_index = -1;
                                    _search.Db       = new DB();
                                }
                                #region Todo
                                //当不存在指定数据库时
                                #endregion
                            }
                            else if (strLine.Length > 10 && strLine.Substring(0, 10).Equals("outputpath"))
                            {
                                string tpath = strLine.Substring(strLine.LastIndexOf("=") + 1);

                                if (tpath.Trim().Length > 0)
                                {
                                    if (task_path.EndsWith("\\"))
                                    {
                                        task_path = task_path.Substring(0, task_path.Length - 1);
                                    }
                                    _task.Path      = task_path + "\\";
                                    _task.Task_name = task_path.Substring(task_path.LastIndexOf("\\") + 1);
                                    sr.ReadLine();
                                }
                            }
                        }
                        #endregion
                        #region [datalist]
                        else if (subtitle.Equals("[datalist]"))
                        {
                            //if (strLine.Length > 7 && strLine.Substring(0, 7).Equals("msmsnum") && (!pParse))
                            //{
                            //    #region
                            //    //默认:raw经处理后统一用PF2,只要是MGF文件,则必定是用户添加的
                            //    #endregion
                            //    //if new a task, then dtnum=0
                            //    int msmsnum = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                            //    _file.Data_file_list.Clear();
                            //    for (int i = 0; i < msmsnum; i++)
                            //    {
                            //        strLine = sr.ReadLine().Trim();
                            //        if (strLine.Length > 8 && strLine.Substring(0, 8).Equals("msmspath"))
                            //        {
                            //            string filep = strLine.Substring(strLine.LastIndexOf("=") + 1);
                            //            if (filep.Substring(filep.LastIndexOf(".") + 1).Equals("mgf") || filep.Substring(filep.LastIndexOf(".") + 1).Equals("MGF"))
                            //            {
                            //                _file.File_format_index = (int)FormatOptions.MGF;
                            //                _file.File_format = "mgf";
                            //            }
                            //            if (System.IO.File.Exists(filep))
                            //            {
                            //                _file.Data_file_list.Add(new _FileInfo(filep));
                            //            }
                            //            else
                            //            {
                            //                System.Windows.MessageBox.Show("\"" + filep + "\" does not exist.");
                            //            }
                            //        }
                            //    }
                            //}
                        }
                        #endregion
                        #region Todo quant
                        else if (subtitle.Equals("[quant]"))
                        {
                            if (strLine.Length > 5 && strLine.Substring(0, 5).Equals("quant"))
                            {
                                string   qt      = strLine.Substring(strLine.LastIndexOf("=") + 1);
                                string[] lb      = qt.Split('|');
                                int      lbcount = lb.GetUpperBound(0);
                                int      lbnum   = int.Parse(lb[0]);
                                #region 如果是MGF文件怎么办
                                #endregion
                                //labeling
                                if (lbnum == 1 && (lb[1].Equals("none") || lb[1].Equals("None")))
                                {
                                    _quantitation.Quantitation_type           = (int)Quant_Type.Labeling_None;
                                    _quantitation.Labeling.Multiplicity       = 1;
                                    _quantitation.Labeling.Multiplicity_index = 0;
                                    _quantitation.Labeling.Medium_label.Add(lb[1]);
                                }
                                else
                                {
                                    _quantitation.Quantitation_type           = (int)Quant_Type.Labeling_SILAC; //if 15N, it will be changed in pQuant_Read
                                    _quantitation.Labeling.Multiplicity       = lbnum;
                                    _quantitation.Labeling.Multiplicity_index = lbnum - 1;
                                    if (lbnum == 1)
                                    {
                                        /*
                                         * string[] lbs = lb[1].Split(',');
                                         * foreach (string c in lbs)
                                         * {
                                         *  if (c.Trim() != ""&&c.ToLower()!="none")
                                         *  {
                                         *      _quantitation.Labeling.Medium_label.Add(c.Trim());
                                         *  }
                                         * }*/
                                        _quantitation.Labeling.Medium_label.Add(lb[1]);
                                    }
                                    else if (lbnum == 2)
                                    {
                                        if (lb[1].Equals(ConfigHelper.N15_label) || lb[2].Equals(ConfigHelper.N15_label))
                                        {
                                            _quantitation.Quantitation_type = (int)Quant_Type.Labeling_15N;
                                        }

                                        _quantitation.Labeling.Light_label.Add(lb[1]);

                                        _quantitation.Labeling.Heavy_label.Add(lb[2]);
                                    }
                                    else if (lbnum == 3)
                                    {
                                        _quantitation.Labeling.Light_label.Add(lb[1]);

                                        _quantitation.Labeling.Medium_label.Add(lb[2]);

                                        _quantitation.Labeling.Heavy_label.Add(lb[3]);
                                    }
                                }
                            }
                        }
                        #endregion
                    }
                    strLine = sr.ReadLine();
                }
                #endregion
                sr.Close();
                fst.Close();
            }
            catch (Exception exe)
            {
                throw new Exception(exe.Message);
            }
        }
示例#27
0
        //generate pFind.pfd
        void pFind_Inter.pFind_write(_Task _task)
        {
            try
            {
                File              _file         = _task.T_File;
                SearchParam       _search       = _task.T_Search;
                FilterParam       _filter       = _task.T_Filter;
                QuantitationParam _quantitation = _task.T_Quantitation;
                StreamReader      sr            = new StreamReader(@"pFind.ini", Encoding.Default);
                string            strLine       = sr.ReadLine();
                string            thread        = "";
                while (strLine != null)
                {
                    if (strLine.Length > 6 && strLine.Substring(0, 6).Equals("thread"))
                    {
                        thread = strLine.Substring(strLine.LastIndexOf("=") + 1);
                    }
                    if (thread != "")
                    {
                        break;
                    }
                    strLine = sr.ReadLine();
                }
                string       filepath = _task.Path + "param\\pFind.cfg";
                FileStream   pFfst    = new FileStream(filepath, FileMode.Create, FileAccess.Write);
                StreamWriter pFsw     = new StreamWriter(pFfst, Encoding.Default);
                pFsw.WriteLine("# This is a standard pFind configure file");
                pFsw.WriteLine("# For help: mail to [email protected]");
                pFsw.WriteLine("# Time: " + DateTime.Now.ToString());
                pFsw.WriteLine();
                pFsw.WriteLine("[Version]");
                pFsw.WriteLine("pFind_Version=EVA.3.0.11");
                pFsw.WriteLine();
                pFsw.WriteLine("[param]");
                pFsw.WriteLine("thread=" + thread);
                pFsw.WriteLine("activation_type=" + _file.Instrument);
                pFsw.WriteLine("mstol=" + _search.Ptl.Tl_value.ToString());
                pFsw.WriteLine("mstolppm=" + _search.Ptl.Isppm.ToString());
                pFsw.WriteLine("msmstol=" + _search.Ftl.Tl_value.ToString());
                pFsw.WriteLine("msmstolppm=" + _search.Ftl.Isppm.ToString());
                pFsw.WriteLine("temppepnum=" + _search.Search_advanced.Temppepnum.ToString()); //中间结果数目,Hidden parameters
                pFsw.WriteLine("pepnum=" + _search.Search_advanced.Pepnum.ToString());         //number of output_peptides
                pFsw.WriteLine("selectpeak=" + _search.Search_advanced.Selectpeak.ToString()); //预处理保存谱峰数目,Hidden parameters
                pFsw.WriteLine("maxprolen=" + _search.Search_advanced.Maxprolen.ToString());   //切分数据库长度限制,Hidden parameters or advanced
                pFsw.WriteLine("maxspec=" + _search.Search_advanced.Maxspec.ToString());       //切分谱图规模限制,Hidden parameters or advanced
                pFsw.WriteLine("IeqL=" + (_search.Search_advanced.IeqL?"1":"0"));
                pFsw.WriteLine("npep=" + _search.Search_advanced.NPeP.ToString());
                pFsw.WriteLine("maxdelta=" + _search.Search_advanced.MAXDelta.ToString()); //
                string varmods = "selectmod=";
                string fixmods = "fixmod=";
                //if (!_search.Open_search)   //开放和限定都要写修饰信息
                {
                    for (int i = 0; i < _search.Var_mods.Count; i++)
                    {
                        if (_search.Var_mods[i].Trim().Length > 0)
                        {
                            varmods += _search.Var_mods[i] + ";";
                        }
                    }
                    for (int i = 0; i < _search.Fix_mods.Count; i++)
                    {
                        if (_search.Fix_mods[i].Trim().Length > 0)
                        {
                            fixmods += _search.Fix_mods[i] + ";";
                        }
                    }
                }
                pFsw.WriteLine(varmods);
                pFsw.WriteLine(fixmods);
                pFsw.WriteLine("maxmod=" + _search.Search_advanced.Maxmod);    //when beam search, advanced
                pFsw.WriteLine("enzyme=" + _search.Enzyme);
                int digest = 3;
                if (_search.Enzyme_Spec_index == 1)
                {
                    digest = 1;
                }
                else if (_search.Enzyme_Spec_index == 2)
                {
                    digest = 0;
                }
                pFsw.WriteLine("digest=" + digest);
                pFsw.WriteLine("max_clv_sites=" + _search.Cleavages.ToString());
                pFsw.WriteLine();
                pFsw.WriteLine("[filter]");
                pFsw.WriteLine("psm_fdr=" + (_filter.Fdr.Fdr_value / 100).ToString());
                pFsw.WriteLine("psm_fdr_type=" + _filter.Fdr.IsPeptides.ToString());    //1是peptide,0是spectra
                pFsw.WriteLine("mass_lower=" + _filter.Pep_mass_range.Left_value.ToString());
                pFsw.WriteLine("mass_upper=" + _filter.Pep_mass_range.Right_value.ToString());
                pFsw.WriteLine("len_lower=" + _filter.Pep_length_range.Left_value.ToString());
                pFsw.WriteLine("len_upper=" + _filter.Pep_length_range.Right_value.ToString());
                pFsw.WriteLine("pep_per_pro=" + _filter.Min_pep_num.ToString());
                pFsw.WriteLine("pro_fdr=" + (_filter.Protein_Fdr / 100).ToString());
                pFsw.WriteLine();

                pFsw.WriteLine("[engine]");
                pFsw.WriteLine("open=" + (_search.Open_search ? "1" : "0"));                       //open search default param
                pFsw.WriteLine("open_tag_len=" + _search.Search_advanced.Open_tag_len.ToString()); //open search default param
                pFsw.WriteLine();
                pFsw.WriteLine("rest_tag_iteration=" + _search.Search_advanced.Rest_tag_iteration.ToString());
                pFsw.WriteLine("rest_tag_len=" + _search.Search_advanced.Rest_tag_len.ToString());
                pFsw.WriteLine("rest_mod_num=" + _search.Search_advanced.Rest_mod_num.ToString());
                pFsw.WriteLine();
                pFsw.WriteLine("salvo_iteration=" + _search.Search_advanced.Salvo_iteration.ToString());
                pFsw.WriteLine("salvo_mod_num=" + _search.Search_advanced.Salvo_mod_num.ToString());    //
                pFsw.WriteLine();
                pFsw.WriteLine("[file]");
                string modpath = "modpath=";
                //获取modification.ini路径
                //获取启动了应用程序的可执行文件的路径,不包括可执行文件的名称
                modpath += ConfigHelper.startup_path;
                modpath += "\\modification.ini";   //relative path
                pFsw.WriteLine(modpath);
                pFsw.WriteLine("fastapath=" + _search.Db.Db_path);
                pFsw.WriteLine("outputpath=" + _task.Path + "result\\");
                pFsw.WriteLine("outputname=" + _task.Task_name);
                pFsw.WriteLine();
                pFsw.WriteLine("[datalist]");
                pFsw.WriteLine("msmsnum=" + _file.Data_file_list.Count.ToString());
                string format = "PF2";
                string instr  = "_";
                if (_file.File_format.Equals("raw") || _file.File_format.Equals("wiff"))
                {
                    switch (_file.Instrument_index)  // TODO: 冗余! 可直接调用 setInstrument()
                    {
                    case (int)InstrumentOptions.CID_FTMS: instr += "CIDFT"; break;

                    case (int)InstrumentOptions.HCD_ITMS: instr += "HCDIT"; break;

                    case (int)InstrumentOptions.HCD_FTMS: instr += "HCDFT"; break;

                    case (int)InstrumentOptions.CID_ITMS: instr += "CIDIT"; break;
                    }
                    for (int i = 0; i < _file.Data_file_list.Count; i++)
                    {
                        string pfpath = _file.Data_file_list[i].FilePath;
                        pfpath = pfpath.Substring(0, pfpath.LastIndexOf(".")) + instr + ".pf2";   //原raw的路径
                        pFsw.WriteLine("msmspath" + (i + 1).ToString() + "=" + pfpath);
                    }
                }
                else if (_file.File_format.Equals("mgf"))
                {
                    format = "MGF";
                    instr  = "";
                    for (int i = 0; i < _file.Data_file_list.Count; i++)
                    {
                        string mgfpath = _file.Data_file_list[i].FilePath;
                        pFsw.WriteLine("msmspath" + (i + 1).ToString() + "=" + mgfpath);
                    }
                }

                //else
                //{
                //    format = _file.File_format.ToUpper();
                //    for (int i = 0; i < _file.Data_file_list.Count; i++)
                //    {
                //        string pfpath = _file.Data_file_list[i].FilePath;
                //        pFsw.WriteLine("msmspath" + (i + 1).ToString() + "=" + pfpath);
                //    }
                //}
                pFsw.WriteLine("msmstype=" + format);
                pFsw.WriteLine();
                #region Quant
                pFsw.WriteLine("[quant]");
                if (_quantitation.Quantitation_type == (int)Quant_Type.Labeling_None)
                {
                    pFsw.WriteLine("quant=1|None");
                }
                else if (_quantitation.Quantitation_type == (int)Quant_Type.Labeling_15N || _quantitation.Quantitation_type == (int)Quant_Type.Labeling_SILAC)
                {
                    string labels = "quant=" + _quantitation.Labeling.Multiplicity.ToString();    //Multiplicity
                    if (_quantitation.Labeling.Multiplicity == 1)
                    {
                        if (_quantitation.Labeling.Medium_label.Count == 0)
                        {
                            labels += "|None";
                        }
                        else
                        {
                            labels += "|" + _quantitation.Labeling.Medium_label[0];
                        }
                    }
                    else if (_quantitation.Labeling.Multiplicity == 2)
                    {
                        if (_quantitation.Labeling.Light_label.Count == 0)   //light label
                        {
                            labels += "|None";
                        }
                        else
                        {
                            labels += "|" + _quantitation.Labeling.Light_label[0];
                        }
                        if (_quantitation.Labeling.Heavy_label.Count == 0)   //heavy label
                        {
                            labels += "|None";
                        }
                        else
                        {
                            labels += "|" + _quantitation.Labeling.Heavy_label[0];
                        }
                    }
                    else if (_quantitation.Labeling.Multiplicity == 3)
                    {
                        if (_quantitation.Labeling.Light_label.Count == 0)   //light label
                        {
                            labels += "|None";
                        }
                        else
                        {
                            labels += "|" + _quantitation.Labeling.Light_label[0];
                        }

                        /*
                         * for (int i = 1; i < _quantitation.Labeling.Light_label.Count; i++)
                         * {
                         *  labels += "," + _quantitation.Labeling.Light_label[i];
                         * }*/
                        if (_quantitation.Labeling.Medium_label.Count == 0)   //medium label
                        {
                            labels += "|None";
                        }
                        else
                        {
                            labels += "|" + _quantitation.Labeling.Medium_label[0];
                        }
                        if (_quantitation.Labeling.Heavy_label.Count == 0)   //heavy label
                        {
                            labels += "|None";
                        }
                        else
                        {
                            labels += "|" + _quantitation.Labeling.Heavy_label[0];
                        }
                    }
                    pFsw.WriteLine(labels);
                }
                else if (_quantitation.Quantitation_type == (int)Quant_Type.Label_free)
                {
                }
                pFsw.WriteLine();
                #endregion
                pFsw.WriteLine("[system]");
                pFsw.WriteLine("log=LOG_INFO");
                pFsw.Close();
                pFfst.Close();
            }
            catch (Exception exe)
            {
                throw new Exception(exe.Message);
            }
        }
示例#28
0
            private static void DoContinue(Task <TResult> baseTask)
            {
                _Task <TResult, TState> task = (_Task <TResult, TState>)baseTask;

                task._config.ContinueAction(task);
            }
示例#29
0
        //read from pParse.para
        void pParse_Inter.pParse_read(string task_path, ref _Task _task)
        {
            string strLine = "";

            try
            {
                pTop.classes.File _file = _task.T_File;
                FileStream        fst   = new FileStream(task_path + "\\param\\pParseTD.cfg", FileMode.Open);
                StreamReader      sr    = new StreamReader(fst, Encoding.Default);
                strLine = sr.ReadLine();
                string subtitle = "";
                ObservableCollection <_FileInfo> dfl = new ObservableCollection <_FileInfo>();
                #region
                while (strLine != null)
                {
                    strLine = strLine.Trim();
                    if (strLine.Length > 0 && strLine.StartsWith("#"))
                    {
                    }
                    else if (strLine.Length > 0 && strLine[0] == '[' && strLine[strLine.Length - 1] == ']')
                    {
                        subtitle = strLine;
                    }
                    else if (strLine.Length > 0 && strLine.LastIndexOf("=") > -1)
                    {
                        if (subtitle.Equals("[Basic Options]"))
                        {
                            if (strLine.Length > 7 && strLine.Substring(0, 7).Equals("datanum"))
                            {
                                //if new a task, then dtnum=0
                                int dtnum = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                                for (int i = 0; i < dtnum; i++)
                                {
                                    strLine = sr.ReadLine();
                                    strLine = strLine.Substring(strLine.LastIndexOf("=") + 1);
                                    if (System.IO.File.Exists(@strLine))
                                    {
                                        _FileInfo _fi = new _FileInfo(strLine);
                                        dfl.Add(_fi);
                                    }
                                    else
                                    {
                                        System.Windows.MessageBox.Show("\"" + strLine + "\" does not exist.");
                                    }
                                }
                            }
                            else if (strLine.Length > 12 && strLine.Substring(0, 12).Equals("input_format"))
                            {
                                _file.File_format = strLine.Substring(strLine.LastIndexOf("=") + 1);
                                if (_file.File_format.Equals("raw"))                  //raw
                                {
                                    _file.File_format_index = (int)FormatOptions.RAW; //format改变会引起Data_file_list的清空
                                }
                                else if (_file.File_format.Equals("mgf"))
                                {
                                    _file.File_format_index = (int)FormatOptions.MGF;
                                }
                                _file.Data_file_list.Clear();
                                for (int i = 0; i < dfl.Count; i++)
                                {
                                    _file.Data_file_list.Add(dfl[i]);
                                }
                            }
                        }
                        #region
                        else if (subtitle.Equals("[Advanced Options]"))
                        {
                            if (strLine.Length > ("max_charge").Length && strLine.Substring(0, ("max_charge").Length).Equals("max_charge"))
                            {
                                _file.Pparse_advanced.Max_charge = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1).Trim());
                            }
                            else if (strLine.Length > ("max_mass").Length && strLine.Substring(0, ("max_mass").Length).Equals("max_mass"))
                            {
                                _file.Pparse_advanced.Max_mass = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1).Trim());
                            }
                            else if (strLine.Length > ("SN_threshold").Length && strLine.Substring(0, ("SN_threshold").Length).Equals("SN_threshold"))
                            {
                                _file.Pparse_advanced.Sn_ratio = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1).Trim());
                            }
                            else if (strLine.Length > ("mz_error_tolerance").Length && strLine.Substring(0, ("mz_error_tolerance").Length).Equals("mz_error_tolerance"))
                            {
                                _file.Pparse_advanced.Mz_tolerance = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1).Trim());
                            }
                            else if (strLine.Length > 8 && strLine.Substring(0, 8).Equals("co-elute"))
                            {
                                if (strLine.Substring(strLine.LastIndexOf("=") + 1).Equals("1"))
                                {
                                    _file.Pparse_advanced.Mix_spectra = true;
                                }
                                else
                                {
                                    _file.Pparse_advanced.Mix_spectra = false;
                                }
                            }

                            else if (strLine.Length > 15 && strLine.Substring(0, 15).Equals("isolation_width"))
                            {
                                _file.Pparse_advanced.Isolation_width = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1).Trim());
                            }
                            else if (strLine.Length > ("model_type").Length && strLine.Substring(0, ("model_type").Length).Equals("model_type"))
                            {
                                _file.Pparse_advanced.Model = strLine.Substring(strLine.LastIndexOf("=") + 1).Trim().ToLower().Equals("svm") ? (int)ModelOptions.SVM : (int)ModelOptions.MARS;
                            }
                            else if (strLine.Length > 14 && strLine.Substring(0, 14).Equals("mars_threshold"))
                            {
                                _file.Pparse_advanced.Threshold = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1).Trim());
                            }
                        }
                        #endregion

                        else if (subtitle.Equals("[About pXtract]"))
                        {
                            if (strLine.Length > 3 && strLine.Substring(0, 3).Equals("m/z"))
                            {
                                _file.Pparse_advanced.Mz_decimal       = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                                _file.Pparse_advanced.Mz_decimal_index = _file.Pparse_advanced.Mz_decimal - 1;
                            }
                            else if (strLine.Length > 9 && (strLine.Substring(0, 9).Equals("intensity") || strLine.Substring(0, 9).Equals("Intensity")))
                            {
                                _file.Pparse_advanced.Intensity_decimal       = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                                _file.Pparse_advanced.Intensity_decimal_index = _file.Pparse_advanced.Intensity_decimal - 1;
                            }
                        }
                    }
                    strLine = sr.ReadLine();
                }
                sr.Close();
                fst.Close();
                #endregion
            }
            catch (Exception exe)
            {
                throw new Exception("[pParseTD_read] line: " + strLine + "\n" + exe.Message);
            }
        }
示例#30
0
 //read from pParse.para
 void pParse_Inter.readpParse_para(string task_path, ref _Task _task)
 {
     try
     {
         File         _file    = _task.T_File;
         FileStream   fst      = new FileStream(task_path + "\\param\\pParse.cfg", FileMode.Open);
         StreamReader sr       = new StreamReader(fst, Encoding.Default);
         string       strLine  = sr.ReadLine();
         string       subtitle = "";
         ObservableCollection <_FileInfo> dfl = new ObservableCollection <_FileInfo>();
         #region
         while (strLine != null)
         {
             strLine = strLine.Trim();
             if (strLine.Length > 0 && strLine.StartsWith("#"))
             {
             }
             else if (strLine.Length > 0 && strLine[0] == '[' && strLine[strLine.Length - 1] == ']')
             {
                 subtitle = strLine;
             }
             else
             {
                 if (subtitle.Equals("[Basic Options]"))
                 {
                     if (strLine.Length > 7 && strLine.Substring(0, 7).Equals("datanum"))
                     {
                         //if new a task, then dtnum=0
                         int dtnum = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                         for (int i = 0; i < dtnum; i++)
                         {
                             strLine = sr.ReadLine();
                             strLine = strLine.Substring(strLine.LastIndexOf("=") + 1);
                             if (System.IO.File.Exists(@strLine))
                             {
                                 _FileInfo _fi = new _FileInfo(strLine);
                                 dfl.Add(_fi);
                             }
                             else
                             {
                                 System.Windows.MessageBox.Show("\"" + strLine + "\" does not exist.");
                             }
                         }
                     }
                 }
                 #region
                 else if (subtitle.Equals("[Advanced Options]"))
                 {
                     if (strLine.Length > 8 && strLine.Substring(0, 8).Equals("co-elute"))
                     {
                         if (strLine.Substring(strLine.LastIndexOf("=") + 1).Equals("1"))
                         {
                             _file.Mix_spectra = true;
                         }
                         else
                         {
                             _file.Mix_spectra = false;
                         }
                     }
                     else if (strLine.Length > 12 && strLine.Substring(0, 12).Equals("input_format"))
                     {
                         _file.File_format = strLine.Substring(strLine.LastIndexOf("=") + 1);
                         if (_file.File_format.Equals("raw"))                  //raw
                         {
                             _file.File_format_index = (int)FormatOptions.RAW; //format改变会引起Data_file_list的清空
                         }
                         else if (_file.File_format.Equals("mgf"))
                         {
                             _file.File_format_index = (int)FormatOptions.MGF;
                         }
                         else if (_file.File_format.Equals("wiff"))
                         {
                             _file.File_format_index = (int)FormatOptions.WIFF;
                         }
                         _file.Data_file_list.Clear();
                         for (int i = 0; i < dfl.Count; i++)
                         {
                             _file.Data_file_list.Add(dfl[i]);
                         }
                     }
                     else if (strLine.Length > 15 && strLine.Substring(0, 15).Equals("isolation_width"))
                     {
                         _file.Pparse_advanced.Isolation_width = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1).Trim());
                     }
                     else if (strLine.Length > 14 && strLine.Substring(0, 14).Equals("mars_threshold"))
                     {
                         _file.Threshold = double.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1).Trim());
                     }
                     else if (strLine.Length > 8 && strLine.Substring(0, 8).Equals("ipv_file"))
                     {
                         _file.Pparse_advanced.Ipv_file = strLine.Substring(strLine.LastIndexOf("=") + 1).Trim();
                     }
                     else if (strLine.Length > 11 && strLine.Substring(0, 11).Equals("trainingset"))
                     {
                         _file.Pparse_advanced.Trainingset = strLine.Substring(strLine.LastIndexOf("=") + 1).Trim();
                     }
                 }
                 #endregion
                 #region
                 else if (subtitle.Equals("[Internal Switches]"))
                 {
                     if (strLine.Length > 13 && strLine.Substring(0, 13).Equals("output_mars_y"))
                     {
                         _file.Pparse_advanced.Output_mars_y = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                     }
                     else if (strLine.Length > 10 && strLine.Substring(0, 10).Equals("delete_msn"))
                     {
                         _file.Pparse_advanced.Output_msn = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1)) == 0 ? 1 : 0;
                     }
                     else if (strLine.Length > 10 && strLine.Substring(0, 10).Equals("output_mgf"))
                     {
                         _file.Pparse_advanced.Output_mgf = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                     }
                     else if (strLine.Length > 9 && strLine.Substring(0, 9).Equals("output_pf"))
                     {
                         _file.Pparse_advanced.Output_pf = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                     }
                     else if (strLine.Length > 10 && strLine.Substring(0, 10).Equals("debug_mode"))
                     {
                         _file.Pparse_advanced.Debug_mode = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                     }
                     else if (strLine.Length > ("check_activationcenter").Length && strLine.Substring(0, ("check_activationcenter").Length).Equals("check_activationcenter"))
                     {
                         _file.Pparse_advanced.Check_activationcenter = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                     }
                     else if (strLine.Length > ("output_all_mars_y").Length && strLine.Substring(0, ("output_all_mars_y").Length).Equals("output_all_mars_y"))
                     {
                         _file.Pparse_advanced.Output_all_mars_y = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                     }
                     else if (strLine.Length > 13 && strLine.Substring(0, 13).Equals("rewrite_files"))
                     {
                         _file.Pparse_advanced.Rewrite_files = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                     }
                     else if (strLine.Length > ("export_unchecked_mono").Length && strLine.Substring(0, ("export_unchecked_mono").Length).Equals("export_unchecked_mono"))
                     {
                         _file.Pparse_advanced.Export_unchecked_mono = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                     }
                     else if (strLine.Length > ("cut_similiar_mono").Length && strLine.Substring(0, ("cut_similiar_mono").Length).Equals("cut_similiar_mono"))
                     {
                         _file.Pparse_advanced.Cut_similiar_mono = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                     }
                     else if (strLine.Length > 10 && strLine.Substring(0, 10).Equals("mars_model"))
                     {
                         _file.Model      = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                         _file.ModelIndex = ConfigHelper.mars_model.IndexOf(_file.Model);
                         //if the value is invalid
                         if (_file.ModelIndex == -1)
                         {
                             _file.ModelIndex = 0;
                             _file.Model      = ConfigHelper.mars_model[_file.ModelIndex];
                         }
                     }
                     else if (strLine.Length > ("output_trainingdata").Length && strLine.Substring(0, ("output_trainingdata").Length).Equals("output_trainingdata"))
                     {
                         _file.Pparse_advanced.Output_trainingdata = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                     }
                 }
                 #endregion
                 else if (subtitle.Equals("[About pXtract]"))
                 {
                     if (strLine.Length > 3 && strLine.Substring(0, 3).Equals("m/z"))
                     {
                         _file.Mz_decimal       = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                         _file.Mz_decimal_index = _file.Mz_decimal - 1;
                     }
                     else if (strLine.Length > 9 && (strLine.Substring(0, 9).Equals("intensity") || strLine.Substring(0, 9).Equals("Intensity")))
                     {
                         _file.Intensity_decimal       = int.Parse(strLine.Substring(strLine.LastIndexOf("=") + 1));
                         _file.Intensity_decimal_index = _file.Intensity_decimal - 1;
                     }
                 }
             }
             strLine = sr.ReadLine();
         }
         sr.Close();
         fst.Close();
         #endregion
     }
     catch (Exception exe)
     {
         throw new Exception(exe.Message);
     }
 }