Example #1
0
 public Bond(Node node1, Node node2, int order)
 {
     this.node1 = node1;
     this.node2 = node2;
     this.bondOrder = order;
     this.whichSide = false;
 }
Example #2
0
        private static void ParseAtomBlock(StreamReader reader, ref Molecule mol)
        {
            //It goes xxxxx.xxxxyyyyy.yyyyzzzzz.zzzz aaaddcccssshhhbbbvvvHHHrrriiimmmnnneee for each atom
            //From the counts line we know how many atoms to expect
            for (int i = 1; i <= mol.NumberOfAtoms; i++)
            {
                string line = reader.ReadLine();
                //First the coords
                Node atomToAdd = new Node();
                double x, y, z;
                bool result = double.TryParse(line.Substring(0, 10), out x);
                if (!result)
                    Console.WriteLine("Could not parse x coords");
                result = double.TryParse(line.Substring(10, 10), out y);
                if (!result)
                    Console.WriteLine("Could not parse y coords");

                result = double.TryParse(line.Substring(20,10), out z);
                if (!result)
                    Console.WriteLine("Could not parse z coords");
                if (z == 0) z = 0.0000;

                Vector3 coords = new Vector3(x, y, z);
                atomToAdd.Position = coords;

                //Next we split the string into parts and the 3rd entry is the atomic symbol
                string[] delim = { " " };
                string[] parts = line.Split(delim, StringSplitOptions.RemoveEmptyEntries);
                atomToAdd.Symbol = parts[3];

                //The fourth is mass difference ?!?!? NOT added
                int massDifference;
                result = int.TryParse(parts[4], out massDifference);
                if (!result)
                    Console.WriteLine("Could not parse mass difference");
                else
                    atomToAdd.MassDiff = massDifference;
                //The fifth is charge
                int charge;
                result = int.TryParse(parts[5], out charge);
                if (!result)
                    Console.WriteLine("Could not parse atomic charge");
                else
                {
                    atomToAdd.Charge = charge;
                    Console.WriteLine("ATOM " + atomToAdd.Symbol + " CHARGE " + charge);
                }

                //The sixth is atom stereo parity which is ignored

                //The seventh is hydrogen count
                int hCount;
                result = int.TryParse(parts[7], out hCount);
                if (!result)
                    Console.WriteLine("Could not parse hydrogen count");
                else
                {
                    if (hCount > 0)
                        Console.WriteLine("hcount above 0");
                    Console.WriteLine("ATOM " + atomToAdd.Symbol + " HS " + hCount);
                    atomToAdd.RequiredHydrogens = hCount;
                }
                //Stereo care box is skipped
                //The ninth is valence 0 = no marking default, includes number of bonds on this atom including implied
                //hydrogens
                int valence;
                result = int.TryParse(parts[9], out valence);
                if (!result)
                    Console.WriteLine("Could not parse valence");
                else
                    atomToAdd.Valence = valence;

                atomToAdd.ID = i;
                //finally we add the atom to the list
                mol.Atoms.Add(i, atomToAdd);

            }
        }
Example #3
0
 public Bond(Node node1, Node node2)
 {
     this.node1 = node1;
     this.node2 = node2;
 }
Example #4
0
        bool whichSide; //which side a double bond is on

        #endregion Fields

        #region Constructors

        public Bond()
        {
            node1 = new Node();
            node2 = new Node();
        }