public new void InitializeWorkflow()
        {
            _resultsFolder = string.IsNullOrEmpty(ExecutorParameters.OutputFolderBase) ? RunUtilities.GetDatasetParentFolder(DatasetPath) : GetResultsFolder(ExecutorParameters.OutputFolderBase);

            MassTagsForTargetedAlignment = GetMassTagTargets(GetTargetFilePathForIqAlignment());

            var targetsFilePathIsEmpty = (String.IsNullOrEmpty(ExecutorParameters.TargetsFilePath));

            var currentTargetsFilePath = targetsFilePathIsEmpty ? TryFindTargetsForCurrentDataset() : ExecutorParameters.TargetsFilePath;

            Targets = CreateTargets(ExecutorParameters.TargetType, currentTargetsFilePath);

            if (ExecutorParameters.TargetType == Globals.TargetType.LcmsFeature)
            {
                UpdateTargetMissingInfo();
            }

            if (_workflowParameters == null)
            {
                _workflowParameters = WorkflowParameters.CreateParameters(ExecutorParameters.WorkflowParameterFile);
                _workflowParameters.LoadParameters(ExecutorParameters.WorkflowParameterFile);
            }

            if (ExecutorParameters.TargetedAlignmentIsPerformed)
            {
                if (string.IsNullOrEmpty(ExecutorParameters.TargetedAlignmentWorkflowParameterFile))
                {
                    throw new FileNotFoundException(
                              "Cannot initialize workflow. TargetedAlignment is requested but TargetedAlignmentWorkflowParameter file is not found. Check path for the 'TargetedAlignmentWorkflowParameterFile' ");
                }


                TargetedAlignmentWorkflowParameters = new TargetedAlignerWorkflowParameters();
                TargetedAlignmentWorkflowParameters.LoadParameters(ExecutorParameters.TargetedAlignmentWorkflowParameterFile);
            }

            TargetedWorkflow = TargetedWorkflow.CreateWorkflow(_workflowParameters);
        }
        public void InitializeWorkflow()
        {
            if (string.IsNullOrEmpty(ExecutorParameters.OutputFolderBase))
            {
                _resultsFolder = RunUtilities.GetDatasetParentFolder(DatasetPath);
            }
            else
            {
                _resultsFolder = GetResultsFolder(ExecutorParameters.OutputFolderBase);
            }

            if (ExecutorParameters.TargetedAlignmentIsPerformed)
            {
                MassTagsForTargetedAlignment = GetMassTagTargets(GetTargetFilePathForIqAlignment());
            }


            var targetsFilePathIsEmpty = (String.IsNullOrEmpty(ExecutorParameters.TargetsFilePath));

            string currentTargetsFilePath;

            if (targetsFilePathIsEmpty)
            {
                currentTargetsFilePath = TryFindTargetsForCurrentDataset();   //check for a _targets file specifically associated with dataset
            }
            else
            {
                currentTargetsFilePath = ExecutorParameters.TargetsFilePath;
            }

            Targets = CreateTargets(ExecutorParameters.TargetType, currentTargetsFilePath);

            Check.Ensure(Targets != null && Targets.TargetList.Count > 0,
                         "Target massTags is empty (or all peptides contain unknown modifications). Check the path to the massTag data file.");

            IqLogger.Log.Info("Total targets loaded= " + Targets.TargetList.Count);


            if (ExecutorParameters.TargetType == Globals.TargetType.LcmsFeature)
            {
                UpdateTargetMissingInfo();
            }

            if (TargetedWorkflow == null)
            {
                if (_workflowParameters == null)
                {
                    _workflowParameters = WorkflowParameters.CreateParameters(ExecutorParameters.WorkflowParameterFile);
                    _workflowParameters.LoadParameters(ExecutorParameters.WorkflowParameterFile);
                }
                TargetedWorkflow = TargetedWorkflow.CreateWorkflow(_workflowParameters);
            }
            else
            {
                _workflowParameters = TargetedWorkflow.WorkflowParameters;
            }

            if (ExecutorParameters.TargetedAlignmentIsPerformed)
            {
                if (string.IsNullOrEmpty(ExecutorParameters.TargetedAlignmentWorkflowParameterFile))
                {
                    throw new FileNotFoundException(
                              "Cannot initialize workflow. TargetedAlignment is requested but TargetedAlignmentWorkflowParameter file is not found. Check path for the 'TargetedAlignmentWorkflowParameterFile' ");
                }


                TargetedAlignmentWorkflowParameters = new TargetedAlignerWorkflowParameters();
                TargetedAlignmentWorkflowParameters.LoadParameters(ExecutorParameters.TargetedAlignmentWorkflowParameterFile);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// A factory method for creating the WorkflowParameters class. Based on the 'WorkflowType' parameter of the xml file.
        /// </summary>
        /// <param name="xmlFilepath"></param>
        /// <returns></returns>
        public static WorkflowParameters CreateParameters(string xmlFilepath)
        {
            Check.Require(File.Exists(xmlFilepath), "Workflow parameter file could not be loaded. File not found: " + xmlFilepath);
            var doc      = XDocument.Load(xmlFilepath);
            var xElement = doc.Element("WorkflowParameters");

            if (xElement == null)
            {
                throw new Exception("WorkflowParameters element not found in " + xmlFilepath);
            }

            var query = xElement.Elements();

            var parameterTableFromXML = new Dictionary <string, string>();

            foreach (var item in query)
            {
                var paramName  = item.Name.ToString();
                var paramValue = item.Value;

                if (!parameterTableFromXML.ContainsKey(paramName))
                {
                    parameterTableFromXML.Add(paramName, paramValue);
                }
            }

            Globals.TargetedWorkflowTypes workflowType;

            var successfulEnum = Enum.TryParse(parameterTableFromXML["WorkflowType"], out workflowType);

            WorkflowParameters workflowParameters;

            if (successfulEnum)
            {
                switch (workflowType)
                {
                case Globals.TargetedWorkflowTypes.Undefined:
                    workflowParameters = new BasicTargetedWorkflowParameters();
                    break;

                case Globals.TargetedWorkflowTypes.UnlabelledTargeted1:
                    workflowParameters = new BasicTargetedWorkflowParameters();
                    break;

                case Globals.TargetedWorkflowTypes.O16O18Targeted1:
                    workflowParameters = new O16O18WorkflowParameters();
                    break;

                case Globals.TargetedWorkflowTypes.N14N15Targeted1:
                    workflowParameters = new N14N15Workflow2Parameters();
                    break;

                case Globals.TargetedWorkflowTypes.SipperTargeted1:
                    workflowParameters = new SipperTargetedWorkflowParameters();
                    break;

                case Globals.TargetedWorkflowTypes.TargetedAlignerWorkflow1:
                    workflowParameters = new TargetedAlignerWorkflowParameters();
                    break;

                case Globals.TargetedWorkflowTypes.BasicTargetedWorkflowExecutor1:
                    workflowParameters = new BasicTargetedWorkflowExecutorParameters();
                    break;

                case Globals.TargetedWorkflowTypes.LcmsFeatureTargetedWorkflowExecutor1:
                    workflowParameters = new LcmsFeatureTargetedWorkflowExecutorParameters();
                    break;

                case Globals.TargetedWorkflowTypes.SipperWorkflowExecutor1:
                    workflowParameters = new SipperWorkflowExecutorParameters();
                    break;

                case Globals.TargetedWorkflowTypes.TopDownTargeted1:
                    workflowParameters = new TopDownTargetedWorkflowParameters();
                    break;

                case Globals.TargetedWorkflowTypes.TopDownTargetedWorkflowExecutor1:
                    workflowParameters = new TopDownTargetedWorkflowExecutorParameters();
                    break;

                case Globals.TargetedWorkflowTypes.UIMFTargetedMSMSWorkflowCollapseIMS:
                    workflowParameters = new UIMFTargetedMSMSWorkflowCollapseIMSParameters();
                    break;

                default:
                    workflowParameters = new BasicTargetedWorkflowParameters();
                    break;
                }
            }
            else
            {
                throw new ArgumentOutOfRangeException(
                          "Tried to create WorkflowParameter object. But WorkflowType is unknown.");
            }

            workflowParameters.LoadParameters(xmlFilepath);

            return(workflowParameters);
        }