示例#1
0
 private void button6_Click(object sender, EventArgs e)
 {
     if (savedRule == false)
     {
         label8.Show();
     }
     else
     {
         savedRule = false;
         comboBox1.DisplayMember = "fragmentName";
         fragmentationRule f = new fragmentationRule();
         comboBox1.Items.Add(f);
         Console.WriteLine(comboBox1.SelectedValue);
         comboBox1.SelectedIndex = comboBox1.Items.Count - 1;
         label8.Hide();
     }
 }
示例#2
0
        public Fragment(fragmentationRule rule)
        {
            fragmentName = rule.fragmentName;
            _bondId      = rule._bondId;
            _atomId1     = rule._atomId1;
            _atomId2     = rule._atomId2;

            _bondId2 = rule._bondId2;
            _atomId3 = rule._atomId3;
            _atomId4 = rule._atomId4;

            _MassShift1 = rule._MassShift1;
            _MassShift2 = rule._MassShift2;
            _MassShift3 = rule._MassShift3;
            _MassShift4 = rule._MassShift4;


            mass = 0;
        }
示例#3
0
        private double calculateRgrpMassShift(fragmentationRule rule, IndigoObject structure)
        {
            Console.Out.WriteLine(rule._MassShift1);
            double mshift = 0.00;

            foreach (IndigoObject atom in structure.iterateAtoms())
            {
                if (atom.symbol().Equals("R"))
                {
                    try
                    {
                        double RgrpMassShift = double.Parse(rmasses[rmasses.IndexOf(rmasses.Find(x => x.index == atom.index()))].interfaceText.Text);
                        mshift += RgrpMassShift;
                    }
                    catch (FormatException e)
                    {
                        MessageBox.Show("All R-Groups must have masses... R Group #" + atom.index() + " does not!");
                    }
                }
            }
            Console.Out.WriteLine("MASS SHIFT FINAL " + mshift);
            return(mshift);
        }
示例#4
0
        //start naive
        private List <Fragment> generateFragByNaive()
        {
            int percent = 0;

            progressBar1.Maximum = _chemStructures[0].countBonds();
            int PBar_Percent = 0;

            progressBar1.Value = PBar_Percent;
            progressBar1.Step  = 1;


            //Do this to preserve hydrogen numbers so that breaking bonds doesn't cause re-ordering.
            foreach (IndigoObject atom in _chemStructures[0].iterateAtoms())
            {
                atom.countHydrogens();
            }

            List <Fragment> _frags = new List <Fragment>();


            foreach (IndigoObject bond in _chemStructures[0].iterateBonds())
            {
                progressBar1.PerformStep();
                IndigoObject tempStructure = _chemStructures[0].clone();
                percent     = (int)(progressBar1.Value / (progressBar1.Maximum * 100));
                label3.Text = percent.ToString() + "%";

                fragmentationRule naiveFragment = new fragmentationRule();
                naiveFragment._atomId1 = bond.source().index();
                naiveFragment._atomId2 = bond.destination().index();
                naiveFragment._bondId  = bond.index();

                tempStructure.getBond(bond.index()).remove();

                if (tempStructure.countComponents() > 1)
                {
                    for (int i = 0; i < tempStructure.countComponents(); i++)
                    {
                        IndigoObject currFragment   = tempStructure.component(i).clone();
                        double       totalMassShift = 0.00;
                        //Get R Group Masses
                        foreach (IndigoObject rgroup in _chemStructures[0].iterateAtoms())
                        {
                            if (rgroup.symbol().Equals("R"))
                            {
                                if (rgroup.componentIndex() == i)
                                {
                                    try
                                    {
                                        double RgrpMassShift = double.Parse(rmasses[rmasses.IndexOf(rmasses.Find(x => x.index == rgroup.index()))].interfaceText.Text);
                                        Console.Out.WriteLine("BEFORE " + totalMassShift);
                                        totalMassShift += RgrpMassShift;
                                        Console.Out.WriteLine("AFTER " + totalMassShift);
                                    }
                                    catch (FormatException e)
                                    {
                                        MessageBox.Show("All R-Groups must have masses... R Group #" + rgroup.index() + " does not!");
                                    }
                                    //Console.Out.WriteLine(rgroup.index() + " has a mass of " +RgrpMassShift);
                                }
                            }
                        }

                        Fragment currFragAdd = new Fragment(naiveFragment);
                        currFragAdd.mass = (currFragment.monoisotopicMass() + totalMassShift);
                        _frags.Add(currFragAdd);
                    }
                }
            }
            return(_frags);
        }