예제 #1
0
        /// <summary>
        /// Called by the contructor after creating the <see cref="Atom"/> objects to identify
        /// covalently bonded atoms. Uses a simple distance heuristic of six angstroms.
        /// </summary>
        private void CreateBonds()
        {
            for (int i = 0; i < this.atoms.Count - 1; i++)
            {
                Atom atom1 = this.atoms[i];

                if (atom1 is Water)
                {
                    continue;
                }

                double x1 = atom1.Position.X;
                double y1 = atom1.Position.Y;
                double z1 = atom1.Position.Z;

                for (int j = i + 1; j < this.atoms.Count; j++)
                {
                    Atom atom2 = this.atoms[j];

                    if (atom2 is Water)
                    {
                        continue;
                    }

                    double distanceSquared = Math.Pow(x1 - atom2.Position.X, 2);
                    if (distanceSquared > 3.6)
                    {
                        continue;
                    }

                    distanceSquared += Math.Pow(y1 - atom2.Position.Y, 2);
                    if (distanceSquared > 3.6)
                    {
                        continue;
                    }

                    distanceSquared += Math.Pow(z1 - atom2.Position.Z, 2);
                    if (distanceSquared > 3.6)
                    {
                        continue;
                    }

                    double distance = Math.Sqrt(distanceSquared);

                    atom1.Bonds.Add(atom2, distance);
                    atom2.Bonds.Add(atom1, distance);
                }
            }

            Atom.SetBFactorColors(this.atoms);
        }
예제 #2
0
        /// <summary>
        /// Parses a PDB stream and build the constituent objects.
        /// </summary>
        /// <param name="pdbStream">The PDB stream.</param>
        internal Molecule(Stream pdbStream)
        {
            this.CreateAtomsAndStructures(pdbStream);
            this.CreateBackbone();
            this.CreateBonds();
            this.CreateResidues();
            this.CreateChains();
            this.CreateMoleculeTransform();

            Atom.SetBFactorColors(this.atoms);

            this.SetStructureInfo();
            this.CreateRibbons();

            foreach (Atom atom in this.atoms)
            {
                atom.Initialize();
            }

            this.ShowCartoon = true;

            this.CreateModel();
        }