Example #1
0
        public Parameters GetParameters(IMatrixData mdata, ref string errorString)
        {
            var parameter = new SingleChoiceWithSubParams("Column type")
            {
                Values    = new [] { "Main", "Text", "Numeric", "Category" },
                SubParams = new []
                {
                    new RegexReplaceParam("Regex", new Regex("Column (.*)"), "$1", mdata.ColumnNames),
                    new RegexReplaceParam("Regex", new Regex("Column (.*)"), "$1", mdata.StringColumnNames),
                    new RegexReplaceParam("Regex", new Regex("Column (.*)"), "$1", mdata.NumericColumnNames),
                    new RegexReplaceParam("Regex", new Regex("Column (.*)"), "$1", mdata.CategoryColumnNames),
                }.Select(param => new Parameters(param)).ToArray()
            };

            return(new Parameters(parameter));
        }
        public Parameters GetParameters(IMatrixData mdata, ref string errorString)
        {
            SingleChoiceWithSubParams scwsp = new SingleChoiceWithSubParams("Action")
            {
                Values =
                    new[] { "Create", "Create from experiment name", "Edit", "Rename", "Delete", "Write template file", "Read from file" },
                SubParams =
                    new[] {
                    GetCreateParameters(mdata), GetCreateFromExperimentNamesParameters(mdata, ref errorString),
                    GetEditParameters(mdata), GetRenameParameters(mdata), GetDeleteParameters(mdata),
                    GetWriteTemplateFileParameters(mdata), GetReadFromFileParameters(mdata)
                },
                ParamNameWidth = 136,
                TotalWidth     = 731
            };

            return(new Parameters(new Parameter[] { scwsp }));
        }
Example #3
0
        public void TestSingleChoiceWithSubParamsInParameters()
        {
            SingleChoiceWithSubParams param = new SingleChoiceWithSubParams("choice", 1)
            {
                Values = new List <string> {
                    "c1", "b2"
                }, SubParams = new []
                {
                    new Parameters(new Parameter[0]),
                    new Parameters(new IntParam("sub2", 82))
                }
            };
            SingleChoiceWithSubParams param2 = (SingleChoiceWithSubParams)param.ToXmlAndBack();

            Assert.AreEqual(param.Name, param2.Name);
            Assert.AreEqual(param.Value, param2.Value);
            Assert.IsTrue(param.Values.SequenceEqual(param2.Values));
            Assert.IsNotNull(param2.SubParams[0]);
            Assert.AreEqual(82, param2.SubParams[1].GetParam <int>("sub2").Value);
        }
 public Parameters GetParameters(IMatrixData mdata, ref string errorString)
 {
     SingleChoiceWithSubParams scwsp = new SingleChoiceWithSubParams("Action"){
         Values = new[]{"Create", "Edit", "Rename", "Delete"},
         SubParams =
             new[]{GetCreateParameters(mdata), GetEditParameters(mdata), GetRenameParameters(mdata), GetDeleteParameters(mdata)},
         ParamNameWidth = 136, TotalWidth = 731
     };
     return new Parameters(new Parameter[]{scwsp});
 }
        protected void AddStudyVariableParameters(IList<Parameter> list, IList<StudyVariable> studyVariables,
                                                  IList<ParameterDescription> help, bool defineNumber)
        {
            StudyVariable[] array = studyVariables.Any() ? studyVariables.ToArray() : null;

            if (defineNumber) {
                SingleChoiceWithSubParams group = new SingleChoiceWithSubParams(MetadataElement.STUDY_VARIABLE.Name) {
                    ParamNameWidth = 0,
                    TotalWidth = 700
                };
                int count = array == null ? 10 : array.Length;
                group.Values = new List<string>();
                group.SubParams = new List<Parameters>();

                int[] temp = new[] { count };
                foreach (int n in temp){
                    if (n < 1) {
                        continue;
                    }
                    @group.Values.Add(n.ToString(CultureInfo.InvariantCulture));
                    @group.SubParams.Add(new Parameters(new StudyVariableParam(array != null && array.Length >= n
                                                                                  ? ArrayUtils.SubArray(array, n)
                                                                                  : new StudyVariable[n], true, cv)));
                }

                if (array != null && group.SubParams.Count >= array.Length) {
                    group.Value = group.Values.IndexOf(array.Length.ToString(CultureInfo.InvariantCulture));
                }

                list.Add(group);
            } else {
                list.Add(new StudyVariableParam(array, false, cv, MetadataElement.STUDY_VARIABLE.Name));
            }
        }
        protected void AddMsRunParameters(IList<Parameter> list, IList<MsRunImpl> runs, IList<ParameterDescription> help,
                                          bool defineGroupNumber)
        {
            string name = MetadataElement.MS_RUN.Name;
            string desc = null;
            CheckIfDescriptionExists(help, name, ref desc, null);

            MsRunImpl[] array = runs.Any() ? runs.ToArray() : null;

            IList<MsRunImpl> groups = MsRunPanel.UniqueGroups(runs);

            if (defineGroupNumber) {
                SingleChoiceWithSubParams group = new SingleChoiceWithSubParams(name) {
                    ParamNameWidth = 0,
                    TotalWidth = 700,
                    Help = desc
                };

                int count = groups == null ? 5 : groups.Count;

                group.Values = new List<string>();
                group.SubParams = new List<Parameters>();

                for (int i = 1; i < count; i++) {
                    int n = i + 1;
                    if (n < 1) {
                        continue;
                    }
                    group.Values.Add(n.ToString(CultureInfo.InvariantCulture));
                    group.SubParams.Add(new Parameters(new MsRunParam(n, array, cv, true)));
                }

                if (groups != null && group.SubParams.Count >= groups.Count) {
                    group.Value = group.Values.IndexOf(groups.Count.ToString(CultureInfo.InvariantCulture));
                }

                list.Add(group);
            } else {
                list.Add(new MsRunParam(groups.Count, array, cv, false, name) { Help = desc });
            }
        }
 /// <summary>
 /// Convert <see cref="BaseLib.Param"/> to <see cref="BaseLibS.Param"/>
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public static Parameter Convert(Parameter p)
 {
     if (p.Type == ParamType.Server){
         return p;
     }
     if (p is RegexReplaceParamWf){
         RegexReplaceParamWf q = (RegexReplaceParamWf) p;
         RegexReplaceParam b = new RegexReplaceParam(q.Name, q.Value.Item1, q.Value.Item2, q.Previews){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is RegexMatchParamWf){
         RegexMatchParamWf q = (RegexMatchParamWf) p;
         RegexMatchParam b = new RegexMatchParam(q.Name, q.Value, q.Previews){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is BoolParamWf){
         BoolParamWf q = (BoolParamWf) p;
         BoolParam b = new BoolParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is BoolWithSubParamsWf){
         BoolWithSubParamsWf q = (BoolWithSubParamsWf) p;
         q.SubParamsFalse?.Convert(Convert);
         q.SubParamsTrue?.Convert(Convert);
         BoolWithSubParams b = new BoolWithSubParams(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             SubParamsFalse = q.SubParamsFalse,
             SubParamsTrue = q.SubParamsTrue,
             Default = q.Default,
             ParamNameWidth = q.ParamNameWidth,
             TotalWidth = q.TotalWidth,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is DictionaryIntValueParamWf){
         DictionaryIntValueParamWf q = (DictionaryIntValueParamWf) p;
         DictionaryIntValueParam b = new DictionaryIntValueParam(q.Name, q.Value, q.Keys){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is DoubleParamWf){
         DoubleParamWf q = (DoubleParamWf) p;
         DoubleParam b = new DoubleParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is FileParamWf){
         FileParamWf q = (FileParamWf) p;
         FileParam b = new FileParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Filter = q.Filter,
             ProcessFileName = q.ProcessFileName,
             Save = q.Save,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is FolderParamWf){
         FolderParamWf q = (FolderParamWf) p;
         FolderParam b = new FolderParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is IntParamWf){
         IntParamWf q = (IntParamWf) p;
         IntParam b = new IntParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is LabelParamWf){
         LabelParamWf q = (LabelParamWf) p;
         LabelParam b = new LabelParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is MultiChoiceMultiBinParamWf){
         MultiChoiceMultiBinParamWf q = (MultiChoiceMultiBinParamWf) p;
         MultiChoiceMultiBinParam b = new MultiChoiceMultiBinParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Values = q.Values,
             Bins = q.Bins,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is MultiChoiceParamWf){
         MultiChoiceParamWf q = (MultiChoiceParamWf) p;
         MultiChoiceParam b = new MultiChoiceParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Repeats = q.Repeats,
             Values = q.Values,
             Default = q.Default,
             DefaultSelections = q.DefaultSelections,
             DefaultSelectionNames = q.DefaultSelectionNames,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is MultiFileParamWf){
         MultiFileParamWf q = (MultiFileParamWf) p;
         MultiFileParam b = new MultiFileParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Filter = q.Filter,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is MultiStringParamWf){
         MultiStringParamWf q = (MultiStringParamWf) p;
         MultiStringParam b = new MultiStringParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is SingleChoiceParamWf){
         SingleChoiceParamWf q = (SingleChoiceParamWf) p;
         SingleChoiceParam b = new SingleChoiceParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Values = q.Values,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is SingleChoiceWithSubParamsWf){
         SingleChoiceWithSubParamsWf q = (SingleChoiceWithSubParamsWf) p;
         foreach (Parameters param in q.SubParams){
             param?.Convert(Convert);
         }
         SingleChoiceWithSubParams b = new SingleChoiceWithSubParams(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Values = q.Values,
             Default = q.Default,
             SubParams = new Parameters[q.SubParams.Count],
             ParamNameWidth = q.ParamNameWidth,
             TotalWidth = q.TotalWidth,
             Url = q.Url
         };
         for (int i = 0; i < q.SubParams.Count; i++){
             b.SubParams[i] = q.SubParams[i];
         }
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is StringParamWf){
         StringParamWf q = (StringParamWf) p;
         StringParam b = new StringParam(q.Name, q.Value){
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     if (p is Ms1LabelParamWf){
         Ms1LabelParamWf q = (Ms1LabelParamWf) p;
         Ms1LabelParam b = new Ms1LabelParam(q.Name, q.Value){
             Values = q.Values,
             Multiplicity = q.Multiplicity,
             Help = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers()){
             b.ValueChanged += act;
         }
         return b;
     }
     throw new Exception("Could not convert ParamWfeter");
 }
Example #8
0
        protected override Parameter[] SpecificParameters(IMatrixData data, ref string errString)
        {
            if (data.StringColumnCount == 0)
            {
                errString = "Please add at least one string column";
                return(null);
            }


            var ConditionColumn1Param = new SingleChoiceParam("Condition column, eg R.FileName")
            {
                Values = data.StringColumnNames,
                Value  = Math.Max(0, data.StringColumnNames.FindIndex(col => col.ToLower().Equals("r.filename"))),
                Help   = "Chose experimental condition column, such as R.FileName, which will be used to create wide-format intensity columns. Has to be a text column."
            };

            var PerlParam = new SingleChoiceWithSubParams("Condition grouping")
            {
                Values = new[] { "Group by condition column", "Skip" },
                Value  = 0,
                Help   = "Chose if input should be grouped from long-format (e.g. Spectronaut report or MaxQuant LFQ evidence) or mixed-format " +
                         "(e.g. MaxQuant TMT evidence with conditions) into wide-format required for this plugin. Chose skip if data is already in wide-format " +
                         "(e.g. MaxQuant TMT evidence without conditions).",
                SubParams = new Parameters[] {             // Define the different sub-parameter groups
                    new Parameters(ConditionColumn1Param), // condition grouping
                    new Parameters()                       // Skip
                }
            };



            var Cutoff1aParam = new DoubleParam("Localization cutoff", 0.75)
            {
                Help = "Localization cutoff to be used to filter PTM localization. Can be between 0 and 1. Setting to 0 will not filter anything."
            };
            var Cutoff1bParam = new DoubleParam("Localization cutoff", 0.75)
            {
                Help = "Localization cutoff to be used to filter PTM localization. Can be between 0 and 1. Setting to 0 will not filter anything."
            };
            var Cutoff2aParam = new DoubleParam("Localization cutoff", 0.75)
            {
                Help = "Localization cutoff to be used to filter PTM localization. Can be between 0 and 1. Setting to 0 will not filter anything."
            };
            var Cutoff2bParam = new DoubleParam("Localization cutoff", 0.75)
            {
                Help = "Localization cutoff to be used to filter PTM localization. Can be between 0 and 1. Setting to 0 will not filter anything."
            };
            var Cutoff2cParam = new DoubleParam("Localization cutoff", 0.75)
            {
                Help = "Localization cutoff to be used to filter PTM localization. Can be between 0 and 1. Setting to 0 will not filter anything."
            };
            var Cutoff3aParam = new DoubleParam("Localization cutoff", 0.75)
            {
                Help = "Localization cutoff to be used to filter PTM localization. Can be between 0 and 1. Setting to 0 will not filter anything."
            };
            var Cutoff3bParam = new DoubleParam("Localization cutoff", 0.75)
            {
                Help = "Localization cutoff to be used to filter PTM localization. Can be between 0 and 1. Setting to 0 will not filter anything."
            };

            var PTMPosCol1Param = new SingleChoiceParam("PTM position column type")
            {
                Values = new[] { "EG.PTMLocalizationProbabilities (SN)", "EG.PrecursorId (SN)" },
                Help   = "Chose which column PTM positions should be extracted from. Requires respective columns."
            };
            var PTMPosCol2Param = new SingleChoiceParam("PTM position column type")
            {
                Values = new[] { "EG.PTMLocalizationProbabilities (SN)", "EG.PrecursorId (SN)", "Modified sequence (MQ)" },
                Help   = "Chose which column PTM positions should be extracted from. Requires respective columns."
            };
            var PTMPosCol3Param = new SingleChoiceParam("PTM position column type")
            {
                Values = new[] { "EG.PTMLocalizationProbabilities (SN)", "EG.PrecursorId (SN)" },
                Help   = "Chose which column PTM positions should be extracted from. Requires respective columns."
            };

            var PTMPosCol2cParam = new SingleChoiceParam("Target PTM Probabilities column")
            {
                Values = data.StringColumnNames,
                Value  = Math.Max(0, data.StringColumnNames.FindIndex(col => col.ToLower().Equals("phospho (sty) probabilities"))),
                Help   = "Chose which column PTM target probabilities should be extracted from. Requires respective columns."
            };

            var ProbType1Param = new SingleChoiceWithSubParams("Probability column type")
            {
                Values = new[] { "EG.PTMLocalizationProbabilities (SN)", "EG.PTMAssayProbability (SN)", "No probability column" },
                Help   = "Chose which column probabilities and PTM positions should be extracted from. Requires resepctive columns. " +
                         "EG.PTMAssayProbability will extract PTM positions from EG.PrecursorId.",
                SubParams = new Parameters[] {      // Define the different sub-parameter groups
                    new Parameters(Cutoff1aParam),  // EG.PTMLocalizationProbabilities
                    new Parameters(Cutoff1bParam),  // EG.PTMAssayProbability
                    new Parameters(PTMPosCol1Param) // Ignored
                }
            };
            var ProbType2Param = new SingleChoiceWithSubParams("Probability column type")
            {
                Values = new[] { "EG.PTMLocalizationProbabilities (SN)", "EG.PTMAssayProbability (SN)",
                                 "No probability column", "Modified sequence (MQ)" },
                Help = "Chose which column probabilities and PTM positions should be extracted from. Requires resepctive columns. " +
                       "EG.PTMAssayProbability will extract PTM positions from EG.PrecursorId. Modified sequence will extract probabilities from provided PTM Probabilities columns.",
                SubParams = new Parameters[] {                      // Define the different sub-parameter groups
                    new Parameters(Cutoff2aParam),                  // EG.PTMLocalizationProbabilities
                    new Parameters(Cutoff2bParam),                  // EG.PTMAssayProbability
                    new Parameters(PTMPosCol2Param),                // Ignored
                    new Parameters(Cutoff2cParam, PTMPosCol2cParam) // Modified sequence
                }
            };
            var ProbType3Param = new SingleChoiceWithSubParams("Probability column type")
            {
                Values = new[] { "EG.PTMLocalizationProbabilities (SN)", "EG.PTMAssayProbability (SN)", "No probability column" },
                Help   = "Chose which column probabilities and PTM positions should be extracted from. Requires resepctive columns. " +
                         "EG.PTMAssayProbability will extract PTM positions from EG.PrecursorId.",
                SubParams = new Parameters[] {      // Define the different sub-parameter groups
                    new Parameters(Cutoff3aParam),  // EG.PTMLocalizationProbabilities
                    new Parameters(Cutoff3bParam),  // EG.PTMAssayProbability
                    new Parameters(PTMPosCol3Param) // Ignored
                }
            };

            var GenesParam = new SingleChoiceParam("Genes or protein groups")
            {
                Values = new[] { "PG.Genes", "PG.ProteinGroups" },
                Help   = "Chose if sites should be collapsed on gene or protein level."
            };
            var FastaFileParam = new FileParam("FASTA file (optional)")
            {
                Help = "Define file location of FASTA file for PTM motif sequence annotation. Leaving blank will skip annotation."
            };
            var FastaStringParam = new StringParam("FASTA identifier rule", ".*GN=([^ ]*) .*")
            {
                Help = "If FASTA file is provided, define identifier parsing rule. This is crucial to allow gene or protein name matching as defined above. Set e.g." +
                       ".*GN=([^ ]*) .* for gene readout, or .*\\|(.*)\\|.* for protein readout"
            };
            var StoichParam = new SingleChoiceParam("Stoichiometry calculation")
            {
                Values = new[] { "Calculate stoichiometries", "Skip" },
                Help   = "Chose if target PTM stoichiometries should be calculated."
            };


            var CollapseParam = new SingleChoiceWithSubParams("Collapse level")
            {
                Values = new[] { "Target PTM site-level, e.g. ABC1_S15_M1", "Target PTM peptide-level, e.g. FS[ph]EAMST[ph]R (stoichiometry possible)",
                                 "ModSpec peptide-level, e.g. FSEAMSTR_2[ph];1[ox]" },
                Value     = 0,
                Help      = "Chose if precursors should be collapsed on peptide- or site-level. Site-level requires PEP.PeptidePosition column.",
                SubParams = new Parameters[] {                                                    // Define the different sub-parameter groups
                    new Parameters(ProbType1Param, GenesParam, FastaFileParam, FastaStringParam), // Localized Site
                    new Parameters(ProbType2Param, StoichParam),                                  // Localized Peptide
                    new Parameters(ProbType3Param)                                                // ModSpec Peptide
                }
            };



            var PTMTypesParam = new StringParam("Variable PTMs, target PTM first", "[Phospho (STY)];[Deamidation (NQ)];[Oxidation (M)];[Carbamidomethyl (C)]")
            {
                Help = "List PTMs as listed in EG.PrecursorId, separated by semicolon. If target site- or target peptide-level collapse is performed, " +
                       "target PTM needs to be listed first."
            };



            var AggParam = new SingleChoiceParam("Aggregation type")
            {
                Values = new[] { "Linear modeling based", "Summing" },
                Help   = "Chose if peptide intensities should be aggregated based on a linear model or simply summed."
            };


            var NumberOfCoresParam = new IntParam("CPUcores", 8)
            {
                Help = "Number of CPU threads to be created by the plugin where possible. Set to 1 for lowest CPU usage. Do not set higher than actual number of available CPU threads."
            };


            return(new Parameter[]
            {
                PerlParam,
                CollapseParam,
                PTMTypesParam,
                AggParam,
                NumberOfCoresParam,
            });
        }
 public Parameters GetParameters(IMatrixData mdata, ref string errorString)
 {
     SingleChoiceWithSubParams scwsp = new SingleChoiceWithSubParams("Action"){
         Values = new[]{"Create", "Create from experiment name", "Edit", "Rename", "Delete", "Write template file", "Read from file"},
         SubParams =
             new[]{
                 GetCreateParameters(mdata), GetCreateFromExperimentNamesParameters(mdata, ref errorString), GetEditParameters(mdata),
                 GetRenameParameters(mdata), GetDeleteParameters(mdata),
                 GetWriteTemplateFileParameters(mdata), GetReadFromFileParameters(mdata)
             },
         ParamNameWidth = 136, TotalWidth = 731
     };
     return new Parameters(new Parameter[]{scwsp});
 }
        private void AddSoftware(IList<Parameter> list, List<Software> software, Dictionary<string, string> parameters,
                                 IList<ParameterDescription> help)
        {
            string name = MetadataElement.SOFTWARE.Name;
            string desc = null;
            name = CheckIfDescriptionExists(help, name, ref desc, null);

            Software[] array = software.Any() ? software.ToArray() : null;
            SingleChoiceWithSubParams group = new SingleChoiceWithSubParams(name){
                Help = desc,
                ParamNameWidth = 0,
                TotalWidth = 800,
                Value = 0,
                Values = new[]{"1", "2", "3"},
                SubParams = new Parameters[3]
            };

            group.SubParams[0] =
                new Parameters(new Parameter[]{
                    new SoftwareParam(
                                   array != null && array.Length >= 1 ? ArrayUtils.SubArray(array, 1) : new Software[1],
                                   cv, parameters)
                });
            group.SubParams[1] = new Parameters(new Parameter[]{
                new SoftwareParam(array != null && array.Length >= 2
                                      ? ArrayUtils.SubArray(array, 2)
                                      : new Software[2], cv, parameters)
            });
            group.SubParams[2] = new Parameters(new Parameter[]{
                new SoftwareParam(array != null && array.Length >= 3
                                      ? ArrayUtils.SubArray(array, 3)
                                      : new Software[3], cv, parameters)
            });

            if (array != null && group.SubParams.Count >= array.Length){
                group.Value = array.Length - 1;
            }

            list.Add(group);
        }
        private void AddSampleProcessingParameters(IList<Parameter> list, IList<ParameterDescription> help,
                                                   IList<SplitList<Lib.Model.Param>> steps)
        {
            string name = MetadataElement.SAMPLE_PROCESSING.Name;
            string desc = null;
            name = CheckIfDescriptionExists(help, name, ref desc, null);

            SplitList<Lib.Model.Param>[] array = steps.Any() ? steps.ToArray() : null;
            SingleChoiceWithSubParams group = new SingleChoiceWithSubParams(name){
                Help = desc,
                ParamNameWidth = 0,
                TotalWidth = 800,
                Value = 0,
                Values = new[]{"1", "2", "3"},
                SubParams =
                    new[]{
                        new Parameters(new Parameter[]{
                            new SampleProcessingParam(
                                           array != null && array.Length >= 1
                                               ? ArrayUtils.SubArray(array, 1)
                                               : new SplitList<Lib.Model.Param>[1], cv)
                        }),
                        new Parameters(new Parameter[]{
                            new SampleProcessingParam(array != null && array.Length >= 2
                                                          ? ArrayUtils.SubArray(array, 2)
                                                          : new SplitList<Lib.Model.Param>[2], cv)
                        }),
                        new Parameters(new Parameter[]{
                            new SampleProcessingParam(array != null && array.Length >= 3
                                                          ? ArrayUtils.SubArray(array, 3)
                                                          : new SplitList<Lib.Model.Param>[3], cv)
                        })
                    }
            };
            if (array != null && group.SubParams.Count >= array.Length){
                group.Value = array.Length - 1;
            }

            list.Add(group);
        }
        private void AddPublicationParameters(IList<Parameter> list, IList<Publication> publications,
                                              IList<ParameterDescription> help)
        {
            string name = MetadataElement.PUBLICATION.Name;
            string desc = null;
            name = CheckIfDescriptionExists(help, name, ref desc, null);

            Publication[] array = publications.Any() ? publications.ToArray() : null;
            SingleChoiceWithSubParams group = new SingleChoiceWithSubParams(name){
                Help = desc,
                ParamNameWidth = 0,
                TotalWidth = 800
            };

            int count = array == null ? 3 : array.Length;
            group.Values = new string[count];
            group.SubParams = new Parameters[count];

            for (int i = 0; i < count; i++){
                int n = i + 1;
                group.Values[i] = n.ToString(CultureInfo.InvariantCulture);
                group.SubParams[i] = new Parameters(new PublicationParam(array != null && array.Length >= n
                                                                             ? ArrayUtils.SubArray(array, n)
                                                                             : new Publication[n], cv));
            }

            group.Value = 0;

            if (array != null && group.SubParams.Count >= array.Length){
                group.Value = array.Length - 1;
            }

            list.Add(group);
        }
        private void AddDatabaseParameters(IList<Parameter> list, IList<Database> databases,
                                           IList<ParameterDescription> help)
        {
            string name = "database";
            string desc = null;
            name = CheckIfDescriptionExists(help, name, ref desc, null);

            Database[] array = databases.Any() ? databases.ToArray() : null;
            SingleChoiceWithSubParams group = new SingleChoiceWithSubParams(name){
                Help = desc,
                ParamNameWidth = 0,
                TotalWidth = 800
            };
            int count = array == null ? 3 : Math.Max(array.Length + 1, 3);
            group.Values = new string[count];
            group.SubParams = new Parameters[count];

            for (int i = 0; i < count; i++){
                int n = i + 1;
                group.Values[i] = n.ToString(CultureInfo.InvariantCulture);
                group.SubParams[i] = new Parameters(new DatabaseParam(array != null && array.Length >= n
                                                                          ? ArrayUtils.SubArray(array, n)
                                                                          : new Database[n]));
            }

            group.Value = 0;

            if (array != null && group.SubParams.Count >= array.Length){
                group.Value = array.Length - 1;
            }

            list.Add(group);
        }
        protected override Parameter[] SpecificParameters(IMatrixData data, ref string errString)

        {
            if (data.StringColumnCount == 0)

            {
                errString = "Please add at least one string column";

                return(null);
            }

            if (data.CategoryColumnCount == 0)

            {
                errString = "Please add at least one categorical column";

                return(null);
            }

            var NumberOfCoresParam = new StringParam("CPUcores", "8")

            {
                Help = "Number of CPU cores to be used by the plugin in certain steps, set to 1 for lowest CPU usage."
            };

            var ConditionColumnParam = new SingleChoiceParam("Condition column, eg R.FileName")

            {
                Values = data.CategoryColumnNames,

                Value = Math.Max(0, data.CategoryColumnNames.FindIndex(col => col.ToLower().Equals("r.filename"))),

                Help = "Chose experimental condition column, such as R.FileName. Has to be a categorical column."
            };

            var ConditionOldParam = new StringParam("Rename condition old", "20171125_QE7_nLC14_DBJ_SA_DIAphos_RPE1_pilot2_")

            {
                Help = "Write parsing rule of condition column to be changed from. Leave blank if no change wanted."
            };

            var ConditionNewParam = new StringParam("Rename condition new", "DIA_")

            {
                Help = "Write parsing rule of condition column to be changed into. Leave blank if no change wanted."
            };

            var PerlParam = new SingleChoiceParam("Parsing type")

            {
                Values = new[] { "fixed", "perl" },

                Help = "Chose if perl compatibility should be enabled for parsing."
            };

            var ProbParam = new SingleChoiceWithSubParams("Prob param")                                    // Hierarchical parameter with sub parameters
            {
                Values    = new [] { "Local", "Global" },                                                  // Name the different sub-parameter groups
                SubParams = new Parameters[] {                                                             // Define the different sub-parameter groups
                    new Parameters(ConditionColumnParam, ConditionOldParam, ConditionNewParam, PerlParam), // Local
                    new Parameters(PTMProbParam)                                                           // Global
                }
            };
            var PTMProbParam = new SingleChoiceParam("EG.PTMLocalizationProbabilities")

            {
                Values = data.StringColumnNames,

                Value = Math.Max(0, data.StringColumnNames.FindIndex(col => col.ToLower().Equals("eg.ptmlocalizationprobabilities"))),

                Help = "Chose localization probability column, such as EG.PTMLocalizationProbabilities. Has to be a string column."
            };

            var PTMSeqParam = new SingleChoiceParam("EG.PrecursorId")

            {
                Values = data.StringColumnNames,

                Value = Math.Max(0, data.StringColumnNames.FindIndex(col => col.ToLower().Equals("eg.precursorid"))),

                Help = "Chose sequence column, such as EG.PrecursorId. Has to be a string column."
            };

            var GenesParam = new SingleChoiceParam("PG.Genes or PG.ProteinGroups")

            {
                Values = data.StringColumnNames,

                Value = Math.Max(0, data.StringColumnNames.FindIndex(col => col.ToLower().Equals("pg.genes"))),

                Help = "Chose gene or protein group column. Has to be a string column."
            };

            var PeptidePosParam = new SingleChoiceParam("PEP.PeptidePosition")

            {
                Values = data.StringColumnNames,

                Value = Math.Max(0, data.StringColumnNames.FindIndex(col => col.ToLower().Equals("pep.peptideposition"))),

                Help = "Chose peptide position column, such as PEP.PeptidePosition. Has to be a string column."
            };

            var AggParam = new SingleChoiceParam("Aggregation type")

            {
                Values = new[] { "Linear modeling based", "Summing" },

                Help = "Chose if peptide intensities should be aggregated based on a linear model or simply summed."
            };

            var CutoffParam = new StringParam("Localization cutoff", "0")

            {
                Help = "Localization cutoff to be used to filter PTM localization. Can be between 0 and 1. Setting to 0 will not filter anything."
            };

            return(new Parameter[]

            {
                NumberOfCoresParam,

                ProbParam, // Use ProbParam instead of other parameters.
                PTMSeqParam,

                GenesParam,

                PeptidePosParam,

                AggParam,

                CutoffParam,
            });
        }
 public void TestSingleChoiceWithSubParamsInParameters()
 {
     var param = new SingleChoiceWithSubParams("choice", 1) { Values = new List<string> {"c1", "b2"}, SubParams = new []
     {
         new Parameters(new Parameter[0]),
         new Parameters(new IntParam("sub2", 82))
     }};
     var param2 = (SingleChoiceWithSubParams) param.ToXmlAndBack();
     Assert.AreEqual(param.Name, param2.Name);
     Assert.AreEqual(param.Value, param2.Value);
     Assert.IsTrue(param.Values.SequenceEqual(param2.Values));
     Assert.IsNotNull(param2.SubParams[0]);
     Assert.AreEqual(82, param2.SubParams[1].GetParam<int>("sub2").Value );
 }
Example #16
0
 /// <summary>
 /// Convert <see cref="BaseLib.Param"/> to <see cref="BaseLibS.Param"/>
 /// </summary>
 /// <param name="p"></param>
 /// <returns></returns>
 public static Parameter Convert(Parameter p)
 {
     if (p.Type == ParamType.Server)
     {
         return(p);
     }
     if (p is RegexReplaceParamWf)
     {
         RegexReplaceParamWf q = (RegexReplaceParamWf)p;
         RegexReplaceParam   b = new RegexReplaceParam(q.Name, q.Value.Item1, q.Value.Item2, q.Previews)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is RegexMatchParamWf)
     {
         RegexMatchParamWf q = (RegexMatchParamWf)p;
         RegexMatchParam   b = new RegexMatchParam(q.Name, q.Value, q.Previews)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is BoolParamWf)
     {
         BoolParamWf q = (BoolParamWf)p;
         BoolParam   b = new BoolParam(q.Name, q.Value)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is BoolWithSubParamsWf)
     {
         BoolWithSubParamsWf q = (BoolWithSubParamsWf)p;
         q.SubParamsFalse?.Convert(Convert);
         q.SubParamsTrue?.Convert(Convert);
         BoolWithSubParams b = new BoolWithSubParams(q.Name, q.Value)
         {
             Help           = q.Help,
             Visible        = q.Visible,
             SubParamsFalse = q.SubParamsFalse,
             SubParamsTrue  = q.SubParamsTrue,
             Default        = q.Default,
             ParamNameWidth = q.ParamNameWidth,
             TotalWidth     = q.TotalWidth,
             Url            = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is DictionaryIntValueParamWf)
     {
         DictionaryIntValueParamWf q = (DictionaryIntValueParamWf)p;
         DictionaryIntValueParam   b = new DictionaryIntValueParam(q.Name, q.Value, q.Keys)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is DoubleParamWf)
     {
         DoubleParamWf q = (DoubleParamWf)p;
         DoubleParam   b = new DoubleParam(q.Name, q.Value)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is FileParamWf)
     {
         FileParamWf q = (FileParamWf)p;
         FileParam   b = new FileParam(q.Name, q.Value)
         {
             Help            = q.Help,
             Visible         = q.Visible,
             Default         = q.Default,
             Filter          = q.Filter,
             ProcessFileName = q.ProcessFileName,
             Save            = q.Save,
             Url             = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is FolderParamWf)
     {
         FolderParamWf q = (FolderParamWf)p;
         FolderParam   b = new FolderParam(q.Name, q.Value)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is IntParamWf)
     {
         IntParamWf q = (IntParamWf)p;
         IntParam   b = new IntParam(q.Name, q.Value)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is LabelParamWf)
     {
         LabelParamWf q = (LabelParamWf)p;
         LabelParam   b = new LabelParam(q.Name, q.Value)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is MultiChoiceMultiBinParamWf)
     {
         MultiChoiceMultiBinParamWf q = (MultiChoiceMultiBinParamWf)p;
         MultiChoiceMultiBinParam   b = new MultiChoiceMultiBinParam(q.Name, q.Value)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Values  = q.Values,
             Bins    = q.Bins,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is MultiChoiceParamWf)
     {
         MultiChoiceParamWf q = (MultiChoiceParamWf)p;
         MultiChoiceParam   b = new MultiChoiceParam(q.Name, q.Value)
         {
             Help                  = q.Help,
             Visible               = q.Visible,
             Repeats               = q.Repeats,
             Values                = q.Values,
             Default               = q.Default,
             DefaultSelections     = q.DefaultSelections,
             DefaultSelectionNames = q.DefaultSelectionNames,
             Url = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is MultiFileParamWf)
     {
         MultiFileParamWf q = (MultiFileParamWf)p;
         MultiFileParam   b = new MultiFileParam(q.Name, q.Value)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Filter  = q.Filter,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is MultiStringParamWf)
     {
         MultiStringParamWf q = (MultiStringParamWf)p;
         MultiStringParam   b = new MultiStringParam(q.Name, q.Value)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is SingleChoiceParamWf)
     {
         SingleChoiceParamWf q = (SingleChoiceParamWf)p;
         SingleChoiceParam   b = new SingleChoiceParam(q.Name, q.Value)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Values  = q.Values,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is SingleChoiceWithSubParamsWf)
     {
         SingleChoiceWithSubParamsWf q = (SingleChoiceWithSubParamsWf)p;
         foreach (Parameters param in q.SubParams)
         {
             param?.Convert(Convert);
         }
         SingleChoiceWithSubParams b = new SingleChoiceWithSubParams(q.Name, q.Value)
         {
             Help           = q.Help,
             Visible        = q.Visible,
             Values         = q.Values,
             Default        = q.Default,
             SubParams      = new Parameters[q.SubParams.Count],
             ParamNameWidth = q.ParamNameWidth,
             TotalWidth     = q.TotalWidth,
             Url            = q.Url
         };
         for (int i = 0; i < q.SubParams.Count; i++)
         {
             b.SubParams[i] = q.SubParams[i];
         }
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is StringParamWf)
     {
         StringParamWf q = (StringParamWf)p;
         StringParam   b = new StringParam(q.Name, q.Value)
         {
             Help    = q.Help,
             Visible = q.Visible,
             Default = q.Default,
             Url     = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     if (p is Ms1LabelParamWf)
     {
         Ms1LabelParamWf q = (Ms1LabelParamWf)p;
         Ms1LabelParam   b = new Ms1LabelParam(q.Name, q.Value)
         {
             Values       = q.Values,
             Multiplicity = q.Multiplicity,
             Help         = q.Help,
             Visible      = q.Visible,
             Default      = q.Default,
             Url          = q.Url
         };
         foreach (ValueChangedHandler act in q.GetPropertyChangedHandlers())
         {
             b.ValueChanged += act;
         }
         return(b);
     }
     throw new Exception("Could not convert ParamWfeter");
 }
        protected void AddAssayParameters(IList<Parameter> list, IList<Assay> assays, IList<ParameterDescription> help,
                                          bool defineGroupNumber)
        {
            Assay[] array = assays.Any() ? assays.ToArray() : null;

            IList<Assay> groups = AssayPanel.UniqueGroups(assays);

            if (defineGroupNumber) {
                SingleChoiceWithSubParams group = new SingleChoiceWithSubParams(MetadataElement.ASSAY.Name) {
                    ParamNameWidth = 0,
                    TotalWidth = 700
                };

                int count = groups == null ? 5 : groups.Count < 3 ? 3 : groups.Count + 1;
                @group.Values = new string[count];
                @group.SubParams = new Parameters[count];
                for (int i = 0; i < count; i++) {
                    int n = i + 1;
                    @group.Values[i] = n.ToString(CultureInfo.InvariantCulture);
                    @group.SubParams[i] = new Parameters(new AssayParam(n, array, true, cv));
                }

                @group.Value = 0;
                if (groups != null && @group.SubParams.Count >= groups.Count) {
                    @group.Value = groups.Count - 1;
                }

                list.Add(@group);
            } else {
                list.Add(new AssayParam(groups.Count, array, false, cv, MetadataElement.ASSAY.Name));
            }
        }
 internal static SingleChoiceWithSubParams GetFilterModeParamNew()
 {
     SingleChoiceWithSubParams p = new SingleChoiceWithSubParams("Filter mode"){
         Values = new[]{"Reduce matrix", "Add categorical column", "Split matrix"},
         SubParams =
             new List<Parameters>(new[]{new Parameters(GetModeParam1()), new Parameters(GetModeParam2()), new Parameters()})
     };
     return p;
 }
        protected void AddInstrumentParameters(IList<Parameter> list, IList<Instrument> instruments,
                                               IList<ParameterDescription> help)
        {
            string name = MetadataElement.INSTRUMENT.Name;
            string desc = null;
            name = CheckIfDescriptionExists(help, name, ref desc, null);

            Instrument[] array = instruments.Any() ? instruments.ToArray() : null;
            SingleChoiceWithSubParams group = new SingleChoiceWithSubParams(name) {
                Help = desc,
                ParamNameWidth = 0,
                TotalWidth = 800,
                Value = 0,
                Values = new[] { "1", "2", "3" },
                SubParams =
                    new[]{
                        new Parameters(new Parameter[]{
                            new InstrumentParam(array != null && array.Length >= 1
                                                    ? ArrayUtils.SubArray(array, 1)
                                                    : new Instrument[1], cv)
                        }),
                        new Parameters(new Parameter[]{
                            new InstrumentParam(array != null && array.Length >= 2
                                                    ? ArrayUtils.SubArray(array, 2)
                                                    : new Instrument[2], cv)
                        }),
                        new Parameters(new Parameter[]{
                            new InstrumentParam(array != null && array.Length >= 3
                                                    ? ArrayUtils.SubArray(array, 3)
                                                    : new Instrument[3], cv)
                        })
                    }
            };

            if (array != null && group.SubParams.Count >= array.Length) {
                group.Value = array.Length - 1;
            }

            list.Add(group);
        }