Пример #1
0
        private ConfigFile GetConfigFile(string destinationProgram)
        {
            if (destinationProgram == "MyriMatch" ||
                destinationProgram == "DirecTag" ||
                destinationProgram == "TagRecon" ||
                destinationProgram == "Pepitome")
            {
                var config = new ConfigFile()
                {
                    DestinationProgram = destinationProgram,
                    PropertyList = new List<ConfigProperty>(),
                    FilePath = "--Custom--"
                };
                var tolerance = double.Parse(PrecursorToleranceBox.Text);
                if (destinationProgram == "DirecTag")
                {
                    if (PrecursorToleranceUnitsBox.Text == "ppm")
                        tolerance /= 1000;
                    config.PropertyList.Add(new ConfigProperty
                    {
                        Name = "PrecursorMzTolerance",
                        Value = tolerance.ToString(CultureInfo.InvariantCulture),
                        Type = "string",
                        ConfigAssociation = config
                    });
                }
                else if (destinationProgram == "TagRecon")
                    config.PropertyList.Add(new ConfigProperty
                        {
                            Name = "PrecursorMzTolerance",
                            Value = "\"" + tolerance.ToString(CultureInfo.InvariantCulture) + PrecursorToleranceUnitsBox.Text + "\"",
                            Type = "string",
                            ConfigAssociation = config
                        });
                else
                    config.PropertyList.Add(new ConfigProperty
                    {
                        Name = "MonoPrecursorMzTolerance",
                        Value = "\"" + tolerance.ToString(CultureInfo.InvariantCulture) + PrecursorToleranceUnitsBox.Text + "\"",
                        Type = "string",
                        ConfigAssociation = config
                    });
                if (!destinationProgram.Contains("Tag") && PrecursorToleranceUnitsBox.Text == "mz" && double.Parse(PrecursorToleranceBox.Text) > 0.2)
                    config.PropertyList.Add(new ConfigProperty
                    {
                        Name = "MonoisotopeAdjustmentSet",
                        Value = "\"0\"",
                        Type = "string",
                        ConfigAssociation = config
                    });
                tolerance = double.Parse(FragmentToleranceBox.Text);
                if (destinationProgram == "DirecTag")
                {
                    if (FragmentToleranceUnitsBox.Text == "ppm")
                        tolerance /= 1000;
                    config.PropertyList.Add(new ConfigProperty
                    {
                        Name = "FragmentMzTolerance",
                        Value = tolerance.ToString(CultureInfo.InvariantCulture),
                        Type = "string",
                        ConfigAssociation = config
                    });
                    config.PropertyList.Add(new ConfigProperty
                    {
                        Name = "ComplementMzTolerance",
                        Value = tolerance.ToString(CultureInfo.InvariantCulture),
                        Type = "string",
                        ConfigAssociation = config
                    });
                    config.PropertyList.Add(new ConfigProperty
                    {
                        Name = "IsotopeMzTolerance",
                        Value = tolerance.ToString(CultureInfo.InvariantCulture),
                        Type = "string",
                        ConfigAssociation = config
                    });
                }
                else
                    config.PropertyList.Add(new ConfigProperty
                        {
                            Name = "FragmentMzTolerance",
                            Value = "\"" + tolerance.ToString(CultureInfo.InvariantCulture) + FragmentToleranceUnitsBox.Text + "\"",
                            Type = "string",
                            ConfigAssociation = config
                        });

                if (destinationProgram != "DirecTag")
                {
                    if (SuffixBox.Checked)
                        config.PropertyList.Add(new ConfigProperty
                            {
                                Name = "OutputSuffix",
                                Value = "\"" + PrimarySuffixBox.Text + "\"",
                                Type = "string",
                                ConfigAssociation = config
                            });
                    config.PropertyList.Add(new ConfigProperty
                        {
                            Name = "CleavageRules",
                            Value = "\"" + CleavageAgentBox.Text + "\"",
                            Type = "string",
                            ConfigAssociation = config
                        });

                    config.PropertyList.Add(new ConfigProperty
                        {
                            Name = "MinTerminiCleavages",
                            Value = SpecificityBox.SelectedIndex.ToString(CultureInfo.InvariantCulture),
                            Type = "int",
                            ConfigAssociation = config
                        });
                    config.PropertyList.Add(new ConfigProperty
                    {
                        Name = "DecoyPrefix",
                        Value = "XXX_",
                        Type = "string",
                        ConfigAssociation = config
                    });
                }
                if (destinationProgram == "TagRecon" && BlindModBox.Checked)
                    config.PropertyList.Add(new ConfigProperty
                    {
                        Name = "ExplainUnknownMassShiftsAs",
                        Value = "\"blindptms\"",
                        Type = "string",
                        ConfigAssociation = config
                    });
                var staticMods = new List<string>();
                var dynamicMods = new List<string>();
                for (var x = 0; x < ModBox.Rows.Count; x++)
                {
                    var residue = ModBox.Rows[x].Cells[0].Value.ToString();
                    var massString =  ModBox.Rows[x].Cells[1].Value.ToString();
                    var type = ModBox.Rows[x].Cells[2].Value.ToString();
                    double mass;

                    if (string.IsNullOrEmpty(residue) || string.IsNullOrEmpty(massString) ||
                        !double.TryParse(massString, out mass) || string.IsNullOrEmpty(type))
                        continue;
                    if (type == "Static")
                    {
                        staticMods.Add(residue);
                        staticMods.Add(mass.ToString(CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        dynamicMods.Add(residue);
                        dynamicMods.Add("*");
                        dynamicMods.Add(mass.ToString(CultureInfo.InvariantCulture));
                    }
                }
                if (staticMods.Count > 0)
                    config.PropertyList.Add(new ConfigProperty
                        {
                            Name = "StaticMods",
                            Value = "\"" + string.Join(" ", staticMods) + "\"",
                            Type = "string",
                            ConfigAssociation = config
                        });
                if (dynamicMods.Count > 0)
                    config.PropertyList.Add(new ConfigProperty
                        {
                            Name = "DynamicMods",
                            Value = "\"" + string.Join(" ", dynamicMods) + "\"",
                            Type = "string",
                            ConfigAssociation = config
                        });
                
                return config;
            }
            if (destinationProgram == "Comet")
            {
                CometParams cometParams;
                if (FragmentLowRadio.Checked)
                    cometParams = CometParams.GetIonTrapParams();
                else if (FragmentMidRadio.Checked)
                    cometParams = CometParams.GetTofParams();
                else
                    cometParams = CometParams.GetHighResParams();
                cometParams.PrecursorTolerance = double.Parse(PrecursorToleranceBox.Text);
                cometParams.PrecursorUnit = PrecursorToleranceUnitsBox.Text == "mz"
                                                ? CometParams.PrecursorUnitOptions.Daltons
                                                : CometParams.PrecursorUnitOptions.PPM;
                cometParams.OutputSuffix = CometSuffixBox.Text;
                if (CometParams.CleavageAgentOptions.ContainsKey(CleavageAgentBox.Text))
                    cometParams.CleavageAgent = CometParams.CleavageAgentOptions[CleavageAgentBox.Text];
                else
                    MessageBox.Show("[Comet] Cannot use " + CleavageAgentBox.Text +
                                    " as a digestive enzyme for comet searches. Results may be unpredictable.");
                cometParams.Specificity = SpecificityBox.Text == "Fully-Specific"
                                              ? CometParams.SpecificityOptions.Tryptic
                                              : CometParams.SpecificityOptions.SemiTryptic;
                for (var x = 0; x < ModBox.Rows.Count; x++)
                {
                    var residue = ModBox.Rows[x].Cells[0].Value.ToString();
                    var massString = ModBox.Rows[x].Cells[1].Value.ToString();
                    var type = ModBox.Rows[x].Cells[2].Value.ToString();
                    double mass;

                    if (string.IsNullOrEmpty(residue) || string.IsNullOrEmpty(massString) ||
                        !double.TryParse(massString, out mass) || string.IsNullOrEmpty(type))
                        continue;

                    if (type == "Static" && residue == "C")
                    {
                        cometParams.StaticCysteineMod = mass;
                        continue;
                    }
                    //for now can only do static on cystine
                    if (type == "Static")
                        MessageBox.Show("[Comet] Warning, BumberDash can only apply static modifications "+
                            "to cystine at this time. Applying \'" +residue + ";" + mass + "\' as dynamic");
                    cometParams.DynamicModifications.Add(new CometParams.Modification(residue, mass));
                }
                var config = new ConfigFile
                    {
                        DestinationProgram = "Comet",
                        FilePath = "--Custom--"
                    };
                config.PropertyList = new List<ConfigProperty>
                    {
                        new ConfigProperty
                            {
                                Name = "config",
                                Value = CometHandler.CometParamsToFileContents(cometParams),
                                Type = "string",
                                ConfigAssociation = config
                            }
                    };
                return config;
            }
            if (destinationProgram == "MSGF")
            {
                var msgfParams = new MSGFParams();
                msgfParams.PrecursorTolerance = double.Parse(PrecursorToleranceBox.Text);
                msgfParams.PrecursorToleranceUnits = PrecursorToleranceUnitsBox.Text == "mz"
                                                         ? MSGFParams.PrecursorToleranceUnitOptions.Daltons
                                                         : MSGFParams.PrecursorToleranceUnitOptions.PPM;
                //msgfParams.FragmentationMethod = FragmentLowRadio.Checked
                //                                     ? MSGFParams.FragmentationMethodOptions.CID
                //                                     : MSGFParams.FragmentationMethodOptions.HCD;
                if (PrecursorLowRadio.Checked || FragmentLowRadio.Checked)
                    msgfParams.Instrument = MSGFParams.InstrumentOptions.LowResLTQ;
                else if (PrecursorMidRadio.Checked || FragmentMidRadio.Checked)
                    msgfParams.Instrument = MSGFParams.InstrumentOptions.TOF;
                else
                    msgfParams.Instrument = MSGFParams.InstrumentOptions.HighResLTQ;
                msgfParams.OutputSuffix = MSGFSuffixBox.Text;
                if (MSGFParams.CleavageAgentOptions.ContainsKey(CleavageAgentBox.Text))
                    msgfParams.CleavageAgent = MSGFParams.CleavageAgentOptions[CleavageAgentBox.Text];
                else if (CleavageAgentBox.Text != "Trypsin/P")
                    MessageBox.Show("[MSGF] Cannot use " + CleavageAgentBox.Text +
                                    " as a digestive enzyme for MS-GF+ searches. Results may be unpredictable.");
                msgfParams.Specificity = SpecificityBox.Text == "Fully-Specific"
                                              ? MSGFParams.SpecificityOptions.Tryptic
                                              : MSGFParams.SpecificityOptions.SemiTryptic;
                var msgfMods = new List<Util.Modification>();
                for (var x = 0; x < ModBox.Rows.Count; x++)
                {
                    var residue = ModBox.Rows[x].Cells[0].Value.ToString();
                    var massString = ModBox.Rows[x].Cells[1].Value.ToString();
                    var type = ModBox.Rows[x].Cells[2].Value.ToString();
                    double mass;

                    if (string.IsNullOrEmpty(residue) || string.IsNullOrEmpty(massString) ||
                        !double.TryParse(massString, out mass) || string.IsNullOrEmpty(type))
                        continue;

                    msgfMods.Add(new Util.Modification {Residue = residue, Mass = mass, Type = type});
                }
                var config = new ConfigFile
                    {
                        DestinationProgram = "MSGF",
                        FilePath = "--Custom--"
                    };
                config.PropertyList = new List<ConfigProperty>
                    {
                        new ConfigProperty
                            {
                                Name = "config",
                                Value = MSGFHandler.MSGFParamsToOverload(msgfParams),
                                Type = "string",
                                ConfigAssociation = config
                            },
                        new ConfigProperty
                            {
                                Name = "mods",
                                Value = MSGFHandler.ModListToModString(msgfMods, 2),
                                Type = "string",
                                ConfigAssociation = config
                            }
                    };
                return config;
            }
            throw new Exception("Invalid destination program, can't construct configuration");
        }
Пример #2
0
        public ConfigFile GetMSGFConfig()
        {
            if (!ProgramSelectMSGF.Checked)
                return null;
            var newConfig = new ConfigFile
            {
                DestinationProgram = "MSGF",
                Name = "--Custom--",
                FilePath = "--Custom--",
                PropertyList = new List<ConfigProperty>()
            };
            var msgfConfig = new MSGFParams();
            if (MSGFParams.CleavageAgentOptions.ContainsKey(MyriCleavageRulesBox.Text))
                msgfConfig.CleavageAgent = MSGFParams.CleavageAgentOptions[MyriCleavageRulesBox.Text];
            //msgfConfig.FragmentationMethod = MSGFFragmentMethodBox.SelectedIndex;
            msgfConfig.Instrument = MSGFInstrumentBox.SelectedIndex;
            msgfConfig.OutputSuffix = MSGFOutputSuffixBox.Text;
            msgfConfig.PrecursorTolerance = Double.Parse(MyriMonoPrecursorMzToleranceBox.Text);
            msgfConfig.PrecursorToleranceUnits = MyriMonoPrecursorMzToleranceUnitsList.SelectedIndex == 0
                                            ? MSGFParams.PrecursorToleranceUnitOptions.Daltons
                                            : MSGFParams.PrecursorToleranceUnitOptions.PPM;
            msgfConfig.Protocol = MSGFPhosphoBox.Checked
                                      ? MSGFiTRAQBox.Checked
                                            ? MSGFParams.ProtocolOptions.iTRAQPhospho
                                            : MSGFParams.ProtocolOptions.Phosphorylation
                                      : MSGFiTRAQBox.Checked
                                            ? MSGFParams.ProtocolOptions.iTRAQ
                                            : MSGFParams.ProtocolOptions.NoProtocol;
            msgfConfig.Specificity = MyriMinTerminiCleavagesBox.SelectedIndex;

            var modList = new List<Util.Modification>();
            foreach (DataGridViewRow row in MyriAppliedModBox.Rows)
            {
                modList.Add(new Util.Modification
                    {
                        Mass = double.Parse(row.Cells[MyriMassColumn.Index].Value.ToString()),
                        Residue = row.Cells[MyriMotifColumn.Index].Value.ToString(),
                        Type = row.Cells[MyriTypeColumn.Index].Value.ToString()
                    });
            }

            newConfig.PropertyList.Add(new ConfigProperty
                {
                    Name = "config",
                    Type = "string",
                    ConfigAssociation = newConfig,
                    Value = MSGFHandler.MSGFParamsToOverload(msgfConfig)
                });
            newConfig.PropertyList.Add(new ConfigProperty
                {
                    Name = "mods",
                    Type = "string",
                    ConfigAssociation = newConfig,
                    Value = MSGFHandler.ModListToModString(modList, (int) MyriMaxDynamicModsBox.Value)
                });
            return newConfig;
        }