Example #1
0
        /// <summary>
        /// Creates a new <see cref="Residue" /> object.
        /// </summary>
        /// <param name="molecule">The molecule this residue belongs to.</param>
        /// <param name="atom">An atom in the residue. This is needed to obtain residue properties
        /// since there is no corresponding PDB file record.</param>
        internal Residue(Molecule molecule, Atom atom)
        {
            this.molecule = molecule;
            this.molecule.ShowCartoonChanged += this.MoleculeShowCartoonChanged;

            this.residueName = atom.ResidueName;
            this.chainIdentifier = atom.ChainIdentifier;
            this.residueSequenceNumber = atom.ResidueSequenceNumber;

            this.atoms = new List<Atom>();
            this.atoms.Add(atom);

            this.residueIdentifier = Residue.GetResidueIdentifier(this.residueName);
            this.residueColor = Residue.GetResidueColor(this.residueName);

            this.structureColor = this.residueIdentifier != "O" ? Colors.LightGray : Colors.Red;

            this.colorScheme = ColorScheme.Structure;

            this.residueStripItems = new List<ResidueStripItem>();
            foreach (char character in this.residueIdentifier)
            {
                ResidueStripItem residueStripItem = new ResidueStripItem(character.ToString());
                residueStripItem.Residue = this;
                this.residueStripItems.Add(residueStripItem);
            }

            this.model = new Model3DGroup();

            this.UpdateColorView();
        }
Example #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;
        }
Example #3
0
        /// <summary>
        /// Called when the entity is changed.
        /// </summary>
        protected override void OnEntityChanged()
        {
            if (this.Entity != null)
            {
                using (Stream pdbStream = this.Entity.GetStream())
                {
                    this.molecule = new Molecule(pdbStream);

                    this.structureControl.Molecule = this.molecule;
                    this.residueControl.Molecule = this.molecule;
                }

                this.actionPreviewTimer.Start();
            }
            else
            {
                this.molecule = null;

                this.structureControl.Molecule = null;
                this.residueControl.Molecule = null;

                this.actionPreviewTimer.Stop();
            }
        }
Example #4
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);
        }