예제 #1
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;
        }
예제 #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);
        }