Пример #1
0
        /// <summary>
        /// Creates the 3D model for the stick that represents backbone segment with another
        /// <see cref="CAlpha" />.
        /// </summary>
        /// <param name="cAlpha"></param>
        private void CreateBackboneBond(CAlpha cAlpha)
        {
            double x = cAlpha.Position.X - this.Position.X;
            double y = cAlpha.Position.Y - this.Position.Y;
            double z = cAlpha.Position.Z - this.Position.Z;

            double distance = Math.Sqrt(x * x + y * y + z * z);

            this.CreateBondStick(this.backboneModel, cAlpha, distance);
        }
Пример #2
0
        /// <summary>
        /// Called by the contructor after creating the <see cref="Atom"/> objects to identify the
        /// backbone atoms and connect them via referneces.
        /// </summary>
        private void CreateBackbone()
        {
            CAlpha previousCAlpha = null;

            foreach (Atom atom in this.atoms)
            {
                CAlpha nextCAlpha = atom as CAlpha;

                if (nextCAlpha != null)
                {
                    if (previousCAlpha != null &&
                        nextCAlpha.ChainIdentifier == previousCAlpha.ChainIdentifier)
                    {
                        previousCAlpha.NextCAlpha = nextCAlpha;
                        nextCAlpha.PreviousCAlpha = previousCAlpha;
                    }

                    previousCAlpha = nextCAlpha;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Static method for parsing atom entries in a pdb file and instantiating the correct
        /// <see cref="Atom" /> subclass.
        /// </summary>
        /// <param name="molecule">The molecule this atom belongs to.</param>
        /// <param name="pdbLine">An atom entry from a pdb file.</param>
        /// <returns>An instance of an <see cref="Atom" /> subclass.</returns>
        internal static Atom CreateAtom(Molecule molecule, string pdbLine)
        {
            Atom atom;

            string atomName = pdbLine.Substring(12, 4).Trim();
            string residueName = pdbLine.Substring(17, 3).Trim();

            if (Residue.IsAminoName(residueName))
            {
                if (atomName == "CA") atom = new CAlpha();
                else atom = new ChainAtom();
            }
            else
            {
                if (residueName == "HOH") atom = new Water();
                else atom = new HetAtom();
            }

            atom.molecule = molecule;

            atom.bonds = new Dictionary<Atom, double>();

            atom.atomName = pdbLine.Substring(12, 4).Trim();
            atom.residueName = pdbLine.Substring(17, 3).Trim();

            atom.residueSequenceNumber = Convert.ToInt32(pdbLine.Substring(22, 4));

            atom.chainIdentifier = pdbLine.Substring(21, 1);
            if (atom.residueName == "HOH") atom.chainIdentifier = "";
            else if (atom.chainIdentifier == " ") atom.chainIdentifier = "1";

            double x = Double.Parse(pdbLine.Substring(30, 8));
            double y = Double.Parse(pdbLine.Substring(38, 8));
            double z = Double.Parse(pdbLine.Substring(46, 8));

            atom.position = new Point3D(x, y, z);

            atom.temperatureFactor = Double.Parse(pdbLine.Substring(60, 6));

            if (atom.atomName.StartsWith("C")) atom.atomColor = Colors.LightGray;
            else if (atom.atomName.StartsWith("N")) atom.atomColor = Colors.Blue;
            else if (atom.atomName.StartsWith("O")) atom.atomColor = Colors.Red;
            else if (atom.atomName.StartsWith("H")) atom.atomColor = Colors.Purple;
            else if (atom.atomName.StartsWith("S")) atom.atomColor = Colors.Yellow;
            else atom.atomColor = Colors.Green;

            atom.structureColor = atom.atomColor;

            atom.colorScheme = ColorScheme.Structure;

            atom.diffuseMaterial = new DiffuseMaterial(new SolidColorBrush(atom.atomColor));

            atom.model = new Model3DGroup();

            atom.translationTransform = new TranslateTransform3D(
                atom.position.X, atom.position.Y, atom.position.Z);

            atom.CreateSelectionSphere();

            return atom;
        }
Пример #4
0
        /// <summary>
        /// Called by the constructor to set secondary structure related properties on the residues
        /// and atoms that compose each structure.
        /// </summary>
        private void SetStructureInfo()
        {
            foreach (Atom atom in this.atoms)
            {
                if (atom is ChainAtom)
                {
                    atom.StructureColor = Colors.LightGray;
                }
            }

            foreach (Residue residue in this.residues)
            {
                foreach (Structure structure in this.structures)
                {
                    if (residue.ChainIdentifier == structure.ChainIdentifier &&
                        residue.ResidueSequenceNumber >= structure.StartResidueSequenceNumber &&
                        residue.ResidueSequenceNumber <= structure.EndResidueSequenceNumber)
                    {
                        if (structure is Sheet)
                        {
                            residue.IsSheet = true;
                        }
                        else if (structure is Helix)
                        {
                            residue.IsHelix = true;
                        }

                        residue.StructureColor = structure.Color;

                        foreach (Atom atom in residue.Atoms)
                        {
                            atom.StructureColor = structure.Color;
                        }

                        break;
                    }
                }
            }

            Residue previousResidue = null;

            foreach (Residue residue in this.residues)
            {
                CAlpha    cAlpha         = null;
                ChainAtom carbonylOxygen = null;

                foreach (Atom atom in residue.Atoms)
                {
                    if (atom is CAlpha)
                    {
                        cAlpha = (CAlpha)atom;
                    }
                }

                if (cAlpha != null)
                {
                    foreach (Atom atom in residue.Atoms)
                    {
                        if (atom is ChainAtom && atom.AtomName == "O")
                        {
                            carbonylOxygen = (ChainAtom)atom;
                        }
                    }
                }

                if (cAlpha == null || carbonylOxygen == null)
                {
                    if (previousResidue != null)
                    {
                        previousResidue.IsStructureEnd = true;
                        previousResidue = null;
                    }

                    continue;
                }
                else
                {
                    residue.CAlphaPosition         = cAlpha.Position;
                    residue.CarbonylOxygenPosition = carbonylOxygen.Position;
                }

                if (previousResidue != null && previousResidue.Chain != residue.Chain)
                {
                    previousResidue.IsStructureEnd = true;
                    previousResidue = null;
                }

                if (previousResidue != null)
                {
                    previousResidue.NextResidue = residue;
                    residue.PreviousResidue     = previousResidue;

                    if (previousResidue.Chain != residue.Chain ||
                        previousResidue.IsSheet != residue.IsSheet ||
                        previousResidue.IsHelix != residue.IsHelix)
                    {
                        previousResidue.IsStructureEnd = true;
                        residue.IsStructureStart       = true;
                    }
                }
                else
                {
                    residue.IsStructureStart = true;
                }

                previousResidue = residue;
            }

            if (previousResidue != null)
            {
                previousResidue.IsStructureEnd = true;
            }
        }
Пример #5
0
        /// <summary>
        /// Creates the 3D model for the stick that represents backbone segment with another
        /// <see cref="CAlpha" />.
        /// </summary>
        /// <param name="cAlpha"></param>
        private void CreateBackboneBond(CAlpha cAlpha)
        {
            double x = cAlpha.Position.X - this.Position.X;
            double y = cAlpha.Position.Y - this.Position.Y;
            double z = cAlpha.Position.Z - this.Position.Z;

            double distance = Math.Sqrt(x * x + y * y + z * z);

            this.CreateBondStick(this.backboneModel, cAlpha, distance);
        }
Пример #6
0
        /// <summary>
        /// Static method for parsing atom entries in a pdb file and instantiating the correct
        /// <see cref="Atom" /> subclass.
        /// </summary>
        /// <param name="molecule">The molecule this atom belongs to.</param>
        /// <param name="pdbLine">An atom entry from a pdb file.</param>
        /// <returns>An instance of an <see cref="Atom" /> subclass.</returns>
        internal static Atom CreateAtom(Molecule molecule, string pdbLine)
        {
            Atom atom;

            string atomName    = pdbLine.Substring(12, 4).Trim();
            string residueName = pdbLine.Substring(17, 3).Trim();

            if (Residue.IsAminoName(residueName))
            {
                if (atomName == "CA")
                {
                    atom = new CAlpha();
                }
                else
                {
                    atom = new ChainAtom();
                }
            }
            else
            {
                if (residueName == "HOH")
                {
                    atom = new Water();
                }
                else
                {
                    atom = new HetAtom();
                }
            }

            atom.molecule = molecule;

            atom.bonds = new Dictionary <Atom, double>();

            atom.atomName    = pdbLine.Substring(12, 4).Trim();
            atom.residueName = pdbLine.Substring(17, 3).Trim();

            atom.residueSequenceNumber = Convert.ToInt32(pdbLine.Substring(22, 4));

            atom.chainIdentifier = pdbLine.Substring(21, 1);
            if (atom.residueName == "HOH")
            {
                atom.chainIdentifier = "";
            }
            else if (atom.chainIdentifier == " ")
            {
                atom.chainIdentifier = "1";
            }

            double x = Double.Parse(pdbLine.Substring(30, 8));
            double y = Double.Parse(pdbLine.Substring(38, 8));
            double z = Double.Parse(pdbLine.Substring(46, 8));

            atom.position = new Point3D(x, y, z);

            atom.temperatureFactor = Double.Parse(pdbLine.Substring(60, 6));

            if (atom.atomName.StartsWith("C"))
            {
                atom.atomColor = Colors.LightGray;
            }
            else if (atom.atomName.StartsWith("N"))
            {
                atom.atomColor = Colors.Blue;
            }
            else if (atom.atomName.StartsWith("O"))
            {
                atom.atomColor = Colors.Red;
            }
            else if (atom.atomName.StartsWith("H"))
            {
                atom.atomColor = Colors.Purple;
            }
            else if (atom.atomName.StartsWith("S"))
            {
                atom.atomColor = Colors.Yellow;
            }
            else
            {
                atom.atomColor = Colors.Green;
            }

            atom.structureColor = atom.atomColor;

            atom.colorScheme = ColorScheme.Structure;

            atom.diffuseMaterial = new DiffuseMaterial(new SolidColorBrush(atom.atomColor));

            atom.model = new Model3DGroup();

            atom.translationTransform = new TranslateTransform3D(
                atom.position.X, atom.position.Y, atom.position.Z);

            atom.CreateSelectionSphere();

            return(atom);
        }