<commit_before>/*
     #################################################################
     ##                                                             ##
     ##  subroutine pdbatm2  --  single atom internal to Cartesian  ##
     ##                                                             ##
     #################################################################

    Parameters
    4 atoms - the atom where we want to set the coords (atom), and the three atoms nearby (atom_a, atom_b, atom_c)
    bond_length - length between atom and atom_a
    angle1deg - desired atom-atom_a-atom_b angle.  Units in degrees
    angle2deg - can either be the dihedral angle or the atom_b-angle_a-angle_c angle.  Units in degrees
    chiral_flag - if 0, then we are trying to fit atom (labeled A in diagram) to
        A---aa---ab---ac

        Else, it is +1 or -1, in which case we are trying to fit atom to model, with left-hand or right-hand chirality
                 ab
                /
               /
      A------aa
              \
               \
                ac
*/

#include "common.h"

void pdbatm2(Atom * atom, Atom * atom_a, Atom * atom_b, Atom * atom_c, double bond_length, double angle1deg, double angle2deg, int chiral_flag) {
    // convert angles to radians, and get their sines and cosines
    double eps = 0.00000001;
    double angle1rad = DEG2RAD(angle1deg), angle2rad = DEG2RAD(angle2deg);
    double sin1 = sin(angle1rad), cos1 = cos(angle1rad), sin2 = sin(angle2rad), cos2 = cos(angle2rad);
    double * new_coords = new double[3];

    // if no second site given, place the atom at the origin
    if (atom_a == NULL) {
        for (int i = 0; i < 3; i++)
            new_coords[i] = 0.0;
        atom->set_coords(new_coords);
    }// if no third site given, place the atom along the z-axis
    else if (atom_b == NULL) {
        for (int i = 0; i < 3; i++)
            new_coords[i] = atom_a->coords[i];
        new_coords[2] += bond_length;
        atom->set_coords(new_coords);
    }//if no fourth site given, place the atom in the x,z-plane
    else if (atom_c == NULL) {
        double rab = atom_a->distance_from(atom_b);
        double xab = (atom_a->coords[0] - atom_b->coords[0]) / rab;
        double yab = (atom_a->coords[1] - atom_b->coords[1]) / rab;
        double zab = (atom_a->coords[2] - atom_b->coords[2]) / rab;
        double cosb = zab, sinb = sqrt(xab*xab + yab*yab), cosg, sing, xtmp, ztmp;

        if (sinb == 0.0) {
            cosg = 1.0; 
            sing = 0.0;            
        } else {
            cosg = yab / sinb;
            sing = xab / sinb;
        }
        xtmp, ztmp = bond_length*sin1, rab - bond_length*cos1;

        for (int i = 0; i < 3; i++)
            new_coords[i] = atom_b->coords[i];

        new_coords[0] += xtmp * cosg + ztmp * sing * sinb;
        new_coords[1] += -xtmp * sing + ztmp * cosg * sinb;
        new_coords[2] += ztmp * cosb;
        atom->set_coords(new_coords);
    }//general case where the second angle is a dihedral angle
    else if (chiral_flag == 0) {
        double rab = atom_a->distance_from(atom_b), rbc = atom_b->distance_from(atom_c);
        double xab = (atom_a->coords[0] - atom_b->coords[0]) / rab;
        double yab = (atom_a->coords[1] - atom_b->coords[1]) / rab;<commit_msg>testing grow_side_chain<commit_after>/*
     #################################################################
     ##                                                             ##
     ##  subroutine pdbatm2  --  single atom internal to Cartesian  ##
     ##                                                             ##
     #################################################################

    Parameters
    4 atoms - the atom where we want to set the coords (atom), and the three atoms nearby (atom_a, atom_b, atom_c)
    bond_length - length between atom and atom_a
    angle1deg - desired atom-atom_a-atom_b angle.  Units in degrees
    angle2deg - can either be the dihedral angle or the atom_b-angle_a-angle_c angle.  Units in degrees
    chiral_flag - if 0, then we are trying to fit atom (labeled A in diagram) to
        A---aa---ab---ac

        Else, it is +1 or -1, in which case we are trying to fit atom to model, with left-hand or right-hand chirality
                 ab
                /
               /
      A------aa
              \
               \
                ac
*/

#include "common.h"

void pdbatm2(Atom * atom, Atom * atom_a, Atom * atom_b, Atom * atom_c, double bond_length, double angle1deg, double angle2deg, int chiral_flag) {
    // convert angles to radians, and get their sines and cosines
    double eps = 0.00000001;
    double angle1rad = DEG2RAD(angle1deg), angle2rad = DEG2RAD(angle2deg);
    double sin1 = sin(angle1rad), cos1 = cos(angle1rad), sin2 = sin(angle2rad), cos2 = cos(angle2rad);
    double * new_coords = new double[3];

    // if no second site given, place the atom at the origin
    if (atom_a == NULL) {
        for (int i = 0; i < 3; i++)
            new_coords[i] = 0.0;
        atom->set_coords(new_coords);
    }// if no third site given, place the atom along the z-axis
    else if (atom_b == NULL) {
        for (int i = 0; i < 3; i++)
            new_coords[i] = atom_a->coords[i];
        new_coords[2] += bond_length;
        atom->set_coords(new_coords);
    }//if no fourth site given, place the atom in the x,z-plane
    else if (atom_c == NULL) {
        double rab = atom_a->distance_from(atom_b);
        double xab = (atom_a->coords[0] - atom_b->coords[0]) / rab;
        double yab = (atom_a->coords[1] - atom_b->coords[1]) / rab;
        double zab = (atom_a->coords[2] - atom_b->coords[2]) / rab;
        double cosb = zab, sinb = sqrt(xab*xab + yab*yab), cosg, sing, xtmp, ztmp;

        if (sinb == 0.0) {
            cosg = 1.0; 
            sing = 0.0;            
        } else {
            cosg = yab / sinb;
            sing = xab / sinb;
        }
        xtmp = bond_length*sin1;
        ztmp = rab - bond_length*cos1;

        for (int i = 0; i < 3; i++)
            new_coords[i] = atom_b->coords[i];

        new_coords[0] += xtmp * cosg + ztmp * sing * sinb;
        new_coords[1] += -xtmp * sing + ztmp * cosg * sinb;
        new_coords[2] += ztmp * cosb;
        atom->set_coords(new_coords);
    }//general case where the second angle is a dihedral angle
    else if (chiral_flag == 0) {
        double rab = atom_a->distance_from(atom_b), rbc = atom_b->distance_from(atom_c);
        double xab = (atom_a->coords[0] - atom_b->coords[0]) / rab;
        double yab = (atom_a->coords[1] - atom_b->coords[1]) / rab;
{'fraction_non_alphanumeric': 0.153427144802542, 'fraction_numerical': 0.019670146769556664, 'mean_word_length': 1.9286663712893222, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3541532', 'n_tokens_mistral': 2244, 'n_tokens_neox': 2154, 'n_words': 628}