예제 #1
0
파일: Atom.cs 프로젝트: frke/genome-tools
 public Atom(int protons, int neutrons)
 {
     Protons           = protons;
     Neutrons          = neutrons;
     Element           = ElementMap.FromProtonCount(Protons);
     Period            = PeriodicTable.GetPeriod(Element);
     Mass              = AtomPropertyCalculator.CalculateMass(Protons, Neutrons);
     Radius            = PeriodicTable.GetCovalentRadius(Element);
     ElectroNegativity = PeriodicTable.ElectroNegativity(Element);
     FormalCharge      = 0 * PhysicalConstants.ElementaryCharge;
     EffectiveCharge   = FormalCharge;
 }
예제 #2
0
        private static double[] Extents(IAtomContainer container, double[][] coords, bool withRadii)
        {
            double xmax = -1e30;
            double ymax = -1e30;
            double zmax = -1e30;

            double xmin = 1e30;
            double ymin = 1e30;
            double zmin = 1e30;

            int natom = container.Atoms.Count;

            for (int i = 0; i < natom; i++)
            {
                var coord = new double[coords[0].Length];
                Array.Copy(coords[i], 0, coord, 0, coords[0].Length);
                if (withRadii)
                {
                    var atom   = container.Atoms[i];
                    var radius = PeriodicTable.GetCovalentRadius(atom.Symbol).Value;
                    xmax = Math.Max(xmax, coord[0] + radius);
                    ymax = Math.Max(ymax, coord[1] + radius);
                    zmax = Math.Max(zmax, coord[2] + radius);

                    xmin = Math.Min(xmin, coord[0] - radius);
                    ymin = Math.Min(ymin, coord[1] - radius);
                    zmin = Math.Min(zmin, coord[2] - radius);
                }
                else
                {
                    xmax = Math.Max(xmax, coord[0]);
                    ymax = Math.Max(ymax, coord[1]);
                    zmax = Math.Max(zmax, coord[2]);

                    xmin = Math.Min(xmin, coord[0]);
                    ymin = Math.Min(ymin, coord[1]);
                    zmin = Math.Min(zmin, coord[2]);
                }
            }
            var ranges = new double[3];

            ranges[0] = xmax - xmin;
            ranges[1] = ymax - ymin;
            ranges[2] = zmax - zmin;
            return(ranges);
        }
        public static void PositionAminoAcid(ApproximatedAminoAcid aminoAcid,
                                             ApproximatedAminoAcid lastAminoAcid = null,
                                             UnitPoint3D startPosition           = null)
        {
            if (lastAminoAcid == null && startPosition == null)
            {
                throw new ArgumentNullException("Either last amino acid or start position must be non-null");
            }
            var nitrogenCarbonDistance = PeriodicTable.GetCovalentRadius(ElementName.Nitrogen) +
                                         PeriodicTable.GetCovalentRadius(ElementName.Carbon);
            var CaCDistance = 2 * PeriodicTable.GetCovalentRadius(ElementName.Carbon);

            UnitPoint3D carbonPosition;
            UnitPoint3D carbonAlphaPosition;
            Vector3D    carbonAlphaCarbonBondDirection;
            Vector3D    nitrogenCarbonAlphaBondDirection;

            if (lastAminoAcid == null)
            {
                carbonPosition                   = startPosition;
                carbonAlphaPosition              = startPosition + new UnitPoint3D(SIPrefix.Pico, Unit.Meter, -CaCDistance.In(SIPrefix.Pico, Unit.Meter), 0, 0);
                carbonAlphaCarbonBondDirection   = carbonAlphaPosition.VectorTo(carbonPosition);
                nitrogenCarbonAlphaBondDirection = new Vector3D(0, 1, 0);
            }
            else
            {
                carbonPosition                 = lastAminoAcid.CarbonPosition;
                carbonAlphaPosition            = lastAminoAcid.CarbonAlphaPosition;
                carbonAlphaCarbonBondDirection = carbonAlphaPosition
                                                 .VectorTo(carbonPosition);
                nitrogenCarbonAlphaBondDirection = lastAminoAcid.NitrogenPosition
                                                   .VectorTo(carbonAlphaPosition);
            }
            var omega            = aminoAcid.OmegaAngle ?? Math.PI.To(Unit.Radians);
            var phi              = aminoAcid.PhiAngle ?? 0.To(Unit.Radians);
            var psi              = lastAminoAcid?.PsiAngle ?? 0.To(Unit.Radians);
            var nitrogenPosition = CalculateAtomPosition(carbonPosition,
                                                         carbonAlphaCarbonBondDirection,
                                                         nitrogenCarbonAlphaBondDirection,
                                                         nitrogenCarbonDistance,
                                                         AminoAcidBondAngles.CaCNAngle,
                                                         psi);

            carbonAlphaPosition = CalculateAtomPosition(nitrogenPosition,
                                                        carbonPosition.VectorTo(nitrogenPosition),
                                                        carbonAlphaCarbonBondDirection,
                                                        nitrogenCarbonDistance,
                                                        AminoAcidBondAngles.CNCaAngle,
                                                        omega);
            carbonPosition = CalculateAtomPosition(carbonAlphaPosition,
                                                   nitrogenPosition.VectorTo(carbonAlphaPosition),
                                                   carbonPosition.VectorTo(nitrogenPosition),
                                                   CaCDistance,
                                                   AminoAcidBondAngles.NCaCAngle,
                                                   phi);
            aminoAcid.NitrogenPosition    = nitrogenPosition;
            aminoAcid.CarbonAlphaPosition = carbonAlphaPosition;
            aminoAcid.CarbonPosition      = carbonPosition;
            if (aminoAcid.OmegaAngle == null)
            {
                aminoAcid.OmegaAngle = omega;
            }
            if (aminoAcid.PhiAngle == null)
            {
                aminoAcid.PhiAngle = phi;
            }
            if (lastAminoAcid != null && lastAminoAcid.PsiAngle == null)
            {
                lastAminoAcid.PsiAngle = psi;
            }
        }
예제 #4
0
 public static UnitValue CalculateApproximate(ElementName element1, ElementName element2)
 {
     return(PeriodicTable.GetCovalentRadius(element1) + PeriodicTable.GetCovalentRadius(element2));
 }