示例#1
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;
            }
        }
示例#2
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;
        }
示例#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);
        }