Example #1
0
        private AminoAcidAngles GetAnglesFromGridPosition(Point2D gridPosition)
        {
            var angles = new AminoAcidAngles
            {
                Omega = 180.To(Unit.Degree),
                Phi   = (360 * (gridPosition.X + 0.5) / gridSteps - 180).To(Unit.Degree),
                Psi   = (180 - 360 * (gridPosition.Y + 0.5) / gridSteps).To(Unit.Degree)
            };

            return(angles);
        }
Example #2
0
        private static void ApplyOmegaDeviationForce(ApproximatedAminoAcid lastAminoAcid,
                                                     ApproximatedAminoAcid aminoAcid,
                                                     AminoAcidAngles aminoAcidAngles,
                                                     Dictionary <ApproximatedAminoAcid, ApproximateAminoAcidForces> forceDictionary)
        {
            if (lastAminoAcid == null)
            {
                return;
            }
            var omegaDeviation = aminoAcidAngles.Omega.In(Unit.Degree) < 0
                ? -180 - aminoAcidAngles.Omega.In(Unit.Degree)
                : 180 - aminoAcidAngles.Omega.In(Unit.Degree);

            if (!forceDictionary.ContainsKey(aminoAcid))
            {
                forceDictionary.Add(aminoAcid, new ApproximateAminoAcidForces());
            }
            var aminoAcidForces = forceDictionary[aminoAcid];

            if (!forceDictionary.ContainsKey(lastAminoAcid))
            {
                forceDictionary.Add(lastAminoAcid, new ApproximateAminoAcidForces());
            }
            var lastAminoAcidForces = forceDictionary[lastAminoAcid];

            var carbonNitrogenVector = lastAminoAcid.CarbonPosition
                                       .VectorTo(aminoAcid.NitrogenPosition)
                                       .In(SIPrefix.Pico, Unit.Meter);
            var previousCarbonCarbonAlphaVector = lastAminoAcid.CarbonPosition
                                                  .VectorTo(lastAminoAcid.CarbonAlphaPosition)
                                                  .In(SIPrefix.Pico, Unit.Meter);
            var forceMagnitude1 = forceScaling * omegaDeviation * 1.0.To(Unit.Newton);
            var forceDirection1 = previousCarbonCarbonAlphaVector
                                  .CrossProduct(carbonNitrogenVector)
                                  .Normalize()
                                  .ToVector3D();

            lastAminoAcidForces.CarbonAlphaForce += forceMagnitude1 * forceDirection1;

            var nitrogenCarbonAlphaVector = aminoAcid.NitrogenPosition
                                            .VectorTo(aminoAcid.CarbonAlphaPosition)
                                            .In(SIPrefix.Pico, Unit.Meter);
            var forceMagnitude2 = forceScaling * omegaDeviation * 1.0.To(Unit.Newton);
            var forceDirection2 = -nitrogenCarbonAlphaVector
                                  .CrossProduct(carbonNitrogenVector)
                                  .Normalize()
                                  .ToVector3D();

            aminoAcidForces.CarbonAlphaForce += forceMagnitude2 * forceDirection2;
        }