<commit_before>// main.cpp

// headers C
extern "C" {
// your functions here for the header

}

// headers C++
// #include <stdlib.h>
// #include <stdio.h> // printf
// #include <string.h> // strcpy, memcpy
// #include <new> // delete
// #include <ctype.h> // getopt - stuff
// #include <unistd.h> // getopt - stuff
#include <vector>
// #include <utility>
// #include <algorithm> // bool & sort
#include <iostream>
#include <iomanip> // setw
// #include <fstream> //
// #include <map> // map
#include "boost/tuple/tuple.hpp"

// boost
// #include "boost/multi_array.hpp"


// my headers
#include "debug.h"
// #include "readfile.h"
// #include "chain.h"
#include "md.h"
#include "ReadPDBfile.hpp"
#include "system.hpp"
#include "dcd.h"
#include "contacts.hpp"
#include "microtubule.hpp"
// #include "mt.hpp"
// #include "config.hpp"
// #include "ConfigFile.h"
// #include "Chameleon.h"
// // #include "contacts.h"
// #include "topology.h"
// #include "topology_charmm.h"
// #include "curvature.h"
// #include "chi.h"


// VMD
// #ifndef _DCDIO_H_
// #define _DCDIO_H_
// #include "dcdio.h"
// #endif

// namespaces

int main(int argc, char *argv[]) {

    debug(">> Welcome to SOPCC! (debug)\n");
    printf(">> Welcome to SOPCC!\n");

    if (argc < 3) {
        std::cout << "Usage: " << argv[0] \
                  << " <Filename-reference-PDB>" \
                  << " <Filename-timelater-DCD>"
                  << std::endl;
        exit(1);
    }


    /* ---------------------------------------------------------
       Procedure:
       --------------------------------------------------------- */
    // 1. Read the config file. <conf.sop>
    //    () read_config_file
    //    () alter_default_parameters. Alter the default parameters. <def_param.h>
    // 2. Read the PDB. <2KHO.pdb>
    //    () ReadPDBfile / Count the atoms.
    //    () Allocate for the Reference System. aa_ref
    //    () Populate some System parameters, like the total num_atoms.
    // 3. Open the DCD.
    //    3.0 allocate for aa_later.
    //    3.1 If DCD exists, read coordinates, velocities.
    //    3.2 If DCD does not exist, run minimization.
    // 4. Run MD.
    //    4.1 Write DCD every so often.
    //    4.2 Include PDBs
    // 5. Write final PDB.
    // 6. Close, Free up memory.

    int num_atoms;
    num_atoms = -1;



    // 0. Create the System.
    // System sys;
    // sys.print_prop();


    // 1. read the config file!


    // 2. Read the pdb.
    // () ReadPDBfile
    // () Count the total "num_atoms".
    Atom a1[0];
    std::cout << "1. Currently, there are " << num_atoms << " atoms." << std::endl;
    num_atoms = ReadPDBfile(argv[1],num_atoms,a1);
    // delete[] a1;
    // delete a1;
    // delete ?
    std::cout << "2. Currently, there are " << num_atoms << " atoms." << std::endl;


    // 2.1 Allocate for the Reference System.
    Atom *aa_ref;
    try
    {
        aa_ref = new Atom[num_atoms];
    }
    catch (std::bad_alloc xa)
    {
        std::cout << "Allocation Failure\n";
        exit(1);
    }
    num_atoms = ReadPDBfile(argv[1],num_atoms,aa_ref);

    // SUCCESS! Copy constructor implemented!
    Atom *aa_ref2 = aa_ref;
    Atom aa_ref2_1 = aa_ref[0];
    aa_ref2_1.print_coords();
    aa_ref[0].print_coords();
    printf("Copy Constructor example here.\n");
    // exit(0);


    // 2.2 Populate System Parameters
    int chainid, atoms_resid, cur_resid;
    std::string chain;

    chainid = 0;
    chain = aa_ref[0].chain.c_str(); // Get "A"
    // std::cout << "chain: " << chain << std::endl;
    // exit(0);

    // integer list of chains.
    std::vector <int> lst_chainid;
    std::vector <int>::iterator it;

    for(int i=0; i<num_atoms; i++)
    {
        // printf("atom: %d  chain: %d  resid: %d  atoms-resid: %d\n",
        //        aa_ref[i].index,aa_ref[i].chainid,aa_ref[i].resid,
        //        aa_ref[i].num_atoms_res);
        // printf("chain: %s\n",aa_ref[i].chain.c_str());

        if(aa_ref[i].chain.c_str() != chain)
        {
            chainid += 1;
            lst_chainid.push_back(chainid);
        }

        aa_ref[i].chainid = chainid;
        chain = aa_ref[i].chain.c_str();


        // printf("atom: %d  chain: %d  resid: %d  atoms-resid: %d\n",
        //        aa_ref[i].index,aa_ref[i].chainid,aa_ref[i].resid,
        //        aa_ref[i].num_atoms_res);
        // printf("chain: %s\n",aa_ref[i].chain.c_str());
    }

    chainid += 1;
    for(int i=0; i<num_atoms; i++)
    {
        // aa_ref[i].print_coords();
        // printf("%s  ",aa_ref[i].chain.c_str());
        // printf("%d\n",aa_ref[i].resid);
        aa_ref[i].num_atoms = num_atoms;
        aa_ref[i].num_chains = chainid;
    }
    // printf("frames: %d\n",dcd->nsets);




// #ifdef DEBUG // Selection
    /* ---------------------------------------------------------
       Begin Selection:
       Selection: H, precheck!
       --------------------------------------------------------- */
    // system_select() [overloaded] with/without return int (number of matches)
    // system_select(all_atom_sys,"selection string",num_select);
    //          opt: selected_atom_sys);
    int total_H = 0;
    for(int i=0; i<num_atoms; i++)
    {
        if(aa_ref[i].chain.compare("H") == 0)
        {
            total_H += 1;
        }
    }
    std::cout << "total_atoms_on_chain_H(4EZW-55?): " << total_H << std::endl;

    int num_select = -1;

    // CHAIN:
    // num_select = select(aa_ref,"chain","A",num_select);
    // Example 1.
    num_select = -1;
    num_select = system_select(aa_ref,"chain H",num_select);
    std::cout << "1. We found " << num_select << " atoms on chain H." << std::endl;

    // Example 2.
    num_select = -1;
    num_select = system_select(aa_ref,"chain D",num_select);
    std::cout << "2. We found " << num_select << " atoms on chain D." << std::endl;

    // Example 3.
    num_select = -1;
    num_select = system_select(aa_ref,"chain A",num_select);
    std::cout << "3. We found " << num_select << " atoms on chain A." << std::endl;


    // RESIDUE:
    // Example 4.
    num_select = -1;
    num_select = system_select(aa_ref,"resid 539 to 541",num_select);
    std::cout << "4. We found " << num_select << " atoms for residues 539 to 541." << std::endl;

    // Example 5.
    num_select = -1;
    num_select = system_select(aa_ref,"resid 397",num_select);
    std::cout << "5. We found " << num_select << " atoms for residues 397." << std::endl;


    // INDEX:
    // Example 6.
    num_select = -1;
    num_select = system_select(aa_ref,"index 150 to 350",num_select);
    std::cout << "6. We found " << num_select << " atoms for indices 150 to 350." << std::endl;

    // Example 7.
    num_select = -1;
    num_select = system_select(aa_ref,"index 1051",num_select);
    std::cout << "7. We found " << num_select << " atoms for index 1050." << std::endl;

    // Example 8.
    num_select = -1;
    num_select = system_select(aa_ref,"chainid 0",num_select);
    std::cout << "8. We found " << num_select << " atoms for chainid 0." << std::endl;

    // Example 9.
    num_select = -1;
    num_select = system_select(aa_ref,"chainid 3",num_select);
    std::cout << "9. We found " << num_select << " atoms for chainid 3." << std::endl;

    // // Example 10.
    // num_select = -1;
    // num_select = system_select(aa_ref,"chainid 3",num_select);
    // std::cout << "10. We found " << num_select << " atoms for chainid 3." << std::endl;

    // Working Example.
    num_select = -1;
    const char *pickme = "resid 411 to 418";
    num_select = system_select(aa_ref,pickme,num_select);
    std::cout << "We found " << num_select << " atoms in this selection: " << pickme << std::endl;




    /* ---------------------------------------------------------
       Allocate for selection.
       --------------------------------------------------------- */
    Atom *aa_sel;
    try
    {
        aa_sel = new Atom[num_select];
    }
    catch (std::bad_alloc xa)
    {
        std::cout << "Allocation Failure\n";
        exit(1);
    }
    // Get selection.
    system_select(aa_ref,pickme,num_select,aa_sel);



    /* ---------------------------------------------------------
       Verify: aa_sel
       --------------------------------------------------------- */
    for(int i=0; i<num_select; i++)
    {
        aa_sel[i].num_atoms = num_select;
        // aa_ref[i].print_coords();
        // printf("%s  ",aa_ref[i].chain.c_str());
        // printf("%d\n",aa_ref[i].resid);

        std::cout << "select_i: " << ' '
                  << aa_sel[i].num_atoms << ' '
                  << aa_sel[i].index << ' '
                  << aa_sel[i].resid << ' '
                  << aa_sel[i].chain << ' '
                  << aa_sel[i].restype << ' '
                  << aa_sel[i].x << ' '
                  << aa_sel[i].y << ' '
                  << aa_sel[i].z << ' '
                  << std::endl;

        if(i>4)
        {
            break;
        }
    }

// #endif // Selection



    /* ---------------------------------------------------------
       Vector of chain-vectors of Atoms.
       --------------------------------------------------------- */
// #ifdef NDEBUG
    // Atom *aa_sel;
    // int num_select = 0;
// #endif

    std::vector<std::vector<Atom>> chain_ref;
    // std::vector<std::pair<int,int>> dimers;

    // ITERATORS: itchain, ita for chain, atom.
    std::vector<std::vector<Atom>>::iterator itchain;
    std::vector<Atom>::iterator ita;

    for(int i=0; i<aa_ref[0].num_chains; i++)
    {
        std::vector<Atom> atombin; // Empty?

        // Atom *aa_sel;
        std::string selection = "chainid " + std::to_string(i);
        const char *pickme = selection.c_str();
        // std::cout << i << ' ' << pickme << std::endl;
        num_select = system_select(aa_ref,pickme,num_select);

        // std::cout << i << ' '
        //           << "We found " << num_select
        //           << " atoms for this selection: "
        //           << selection
        //           << " : "
        //           << num_select
        //           << " atoms."
        //           << std::endl;
        // std::cout << "Number of chains in chain_ref(size): " << chain_ref.size() << std::endl;

        try
        {
            aa_sel = new Atom[num_select];
        }
        catch (std::bad_alloc xa)
        {
            std::cout << "Allocation Failure\n";
            exit(1);
        }
        system_select(aa_ref,pickme,num_select,aa_sel);


        for(int j=0; j<num_select; j++)
        {
            // aa_sel[j].print_coords();
            Atom a1 = aa_sel[j]; // Copy Constructor
            // a1.print_coords();
            atombin.push_back(a1);
            // atombin.push_back(&a1);
            // atombin.push_back(aa_sel[j]);

            // if(j>3)
            // {
            //     break;
            // }
        }
        chain_ref.push_back(atombin);
        // printf("\n");
        // std::cout << "binsize: " << atombin.size() << std::endl; // 439, 427, 2..


        // if(i>4)
        // {
        //     break;
        // }
        // break;
    }
    std::cout << "# of chains: " << chain_ref.size() << std::endl;

    // exit(0);


    // KEEP THIS.
    // // EXAMPLE Iteration: chain_ref
    // for(itchain = chain_ref.begin(); itchain != chain_ref.end(); itchain++)
    // {
    //     std::cout << "Atoms in chain: " << (*itchain).size() << std::endl;
    //     for(ita = (*itchain).begin(); ita != (*itchain).end(); ita++)
    //     {
    //         (*ita).print_coords();
    //     }
    //     break;
    // }
    // exit(0);


    /* ---------------------------------------------------------
       Vector of chain-vectors of Atoms. END.
       --------------------------------------------------------- */





#ifdef MTMAP_PRE
    // Pairs: A(~439) and B(427-8).
    DimerList dimers;
    // MtDomainIndexBoundaries mtdemarcations;
    // MtIndexMap mtmap_subdomain(chain_ref.size());
    // MtIndexMap mtmap_subdomain[chain_ref.size()];
    // std::vector<std::map<std::string,int>>
    MtIndexMap mtmap_subdomain;
    MtIndexMapEntry mtentry;

    // ACCESS chain_ref
    int imonomer = 0;
    int betabool = -1;
    int i_count = -1;
    // int high_index, low_index, Nterm1, Nterm2, Mterm1, Mterm2, Cterm1, Cterm2;
    // high_index = low_index = Nterm1 = Nterm2 = Mterm1 = Mterm2 = Cterm1 = Cterm2 = -1;
    int high_index, low_index, Nterm2, Mterm1, Mterm2, Cterm1;
    // high_index = low_index = Nterm2 = Mterm1 = Mterm2 = Cterm1 = -1;


    // std::cout << "mtmap-size: " << mtmap[0].size() << std::endl;
    //                                                   exit(0);

    for(auto c: chain_ref)
    {
        high_index = low_index = Nterm2 = Mterm1 = Mterm2 = Cterm1 = -1;
        i_count += 1;
        betabool = -1;
        imonomer += 1;

        // if(c.size() >= 433)
        if((c.size() >= 433) and (c.size() <= 442))
        {
            dimers.push_back(std::make_pair(imonomer-1,imonomer));
            betabool = 0;
        }
        else if ((c.size() > 420) and (c.size() < 433))
        {
            betabool = 1;
        }


        high_index = -1;
        for(auto a: c)
        {
            if (a.index > high_index)
            {
                high_index = a.index;
            }
        }

        low_index = high_index - c.size() + 1;

        if((c.size() > 420) and (c.size() < 442))
        {
            Nterm2 = low_index + 214;
            Mterm1 = Nterm2 + 1;
            Mterm2 = Mterm1 + 168;
            Cterm1 = Mterm2 + 1;
        }

        // std::cout << "chainid: " << imonomer - 1 << " \n"<commit_msg>added comments about the NMC terms in MT<commit_after>// main.cpp

// headers C
extern "C" {
// your functions here for the header

}

// headers C++
// #include <stdlib.h>
// #include <stdio.h> // printf
// #include <string.h> // strcpy, memcpy
// #include <new> // delete
// #include <ctype.h> // getopt - stuff
// #include <unistd.h> // getopt - stuff
#include <vector>
// #include <utility>
// #include <algorithm> // bool & sort
#include <iostream>
#include <iomanip> // setw
// #include <fstream> //
// #include <map> // map
#include "boost/tuple/tuple.hpp"

// boost
// #include "boost/multi_array.hpp"


// my headers
#include "debug.h"
// #include "readfile.h"
// #include "chain.h"
#include "md.h"
#include "ReadPDBfile.hpp"
#include "system.hpp"
#include "dcd.h"
#include "contacts.hpp"
#include "microtubule.hpp"
// #include "mt.hpp"
// #include "config.hpp"
// #include "ConfigFile.h"
// #include "Chameleon.h"
// // #include "contacts.h"
// #include "topology.h"
// #include "topology_charmm.h"
// #include "curvature.h"
// #include "chi.h"


// VMD
// #ifndef _DCDIO_H_
// #define _DCDIO_H_
// #include "dcdio.h"
// #endif

// namespaces

int main(int argc, char *argv[]) {

    debug(">> Welcome to SOPCC! (debug)\n");
    printf(">> Welcome to SOPCC!\n");

    if (argc < 3) {
        std::cout << "Usage: " << argv[0] \
                  << " <Filename-reference-PDB>" \
                  << " <Filename-timelater-DCD>"
                  << std::endl;
        exit(1);
    }


    /* ---------------------------------------------------------
       Procedure:
       --------------------------------------------------------- */
    // 1. Read the config file. <conf.sop>
    //    () read_config_file
    //    () alter_default_parameters. Alter the default parameters. <def_param.h>
    // 2. Read the PDB. <2KHO.pdb>
    //    () ReadPDBfile / Count the atoms.
    //    () Allocate for the Reference System. aa_ref
    //    () Populate some System parameters, like the total num_atoms.
    // 3. Open the DCD.
    //    3.0 allocate for aa_later.
    //    3.1 If DCD exists, read coordinates, velocities.
    //    3.2 If DCD does not exist, run minimization.
    // 4. Run MD.
    //    4.1 Write DCD every so often.
    //    4.2 Include PDBs
    // 5. Write final PDB.
    // 6. Close, Free up memory.

    int num_atoms;
    num_atoms = -1;



    // 0. Create the System.
    // System sys;
    // sys.print_prop();


    // 1. read the config file!


    // 2. Read the pdb.
    // () ReadPDBfile
    // () Count the total "num_atoms".
    Atom a1[0];
    std::cout << "1. Currently, there are " << num_atoms << " atoms." << std::endl;
    num_atoms = ReadPDBfile(argv[1],num_atoms,a1);
    // delete[] a1;
    // delete a1;
    // delete ?
    std::cout << "2. Currently, there are " << num_atoms << " atoms." << std::endl;


    // 2.1 Allocate for the Reference System.
    Atom *aa_ref;
    try
    {
        aa_ref = new Atom[num_atoms];
    }
    catch (std::bad_alloc xa)
    {
        std::cout << "Allocation Failure\n";
        exit(1);
    }
    num_atoms = ReadPDBfile(argv[1],num_atoms,aa_ref);

    // SUCCESS! Copy constructor implemented!
    Atom *aa_ref2 = aa_ref;
    Atom aa_ref2_1 = aa_ref[0];
    aa_ref2_1.print_coords();
    aa_ref[0].print_coords();
    printf("Copy Constructor example here.\n");
    // exit(0);


    // 2.2 Populate System Parameters
    int chainid, atoms_resid, cur_resid;
    std::string chain;

    chainid = 0;
    chain = aa_ref[0].chain.c_str(); // Get "A"
    // std::cout << "chain: " << chain << std::endl;
    // exit(0);

    // integer list of chains.
    std::vector <int> lst_chainid;
    std::vector <int>::iterator it;

    for(int i=0; i<num_atoms; i++)
    {
        // printf("atom: %d  chain: %d  resid: %d  atoms-resid: %d\n",
        //        aa_ref[i].index,aa_ref[i].chainid,aa_ref[i].resid,
        //        aa_ref[i].num_atoms_res);
        // printf("chain: %s\n",aa_ref[i].chain.c_str());

        if(aa_ref[i].chain.c_str() != chain)
        {
            chainid += 1;
            lst_chainid.push_back(chainid);
        }

        aa_ref[i].chainid = chainid;
        chain = aa_ref[i].chain.c_str();


        // printf("atom: %d  chain: %d  resid: %d  atoms-resid: %d\n",
        //        aa_ref[i].index,aa_ref[i].chainid,aa_ref[i].resid,
        //        aa_ref[i].num_atoms_res);
        // printf("chain: %s\n",aa_ref[i].chain.c_str());
    }

    chainid += 1;
    for(int i=0; i<num_atoms; i++)
    {
        // aa_ref[i].print_coords();
        // printf("%s  ",aa_ref[i].chain.c_str());
        // printf("%d\n",aa_ref[i].resid);
        aa_ref[i].num_atoms = num_atoms;
        aa_ref[i].num_chains = chainid;
    }
    // printf("frames: %d\n",dcd->nsets);




// #ifdef DEBUG // Selection
    /* ---------------------------------------------------------
       Begin Selection:
       Selection: H, precheck!
       --------------------------------------------------------- */
    // system_select() [overloaded] with/without return int (number of matches)
    // system_select(all_atom_sys,"selection string",num_select);
    //          opt: selected_atom_sys);
    int total_H = 0;
    for(int i=0; i<num_atoms; i++)
    {
        if(aa_ref[i].chain.compare("H") == 0)
        {
            total_H += 1;
        }
    }
    std::cout << "total_atoms_on_chain_H(4EZW-55?): " << total_H << std::endl;

    int num_select = -1;

    // CHAIN:
    // num_select = select(aa_ref,"chain","A",num_select);
    // Example 1.
    num_select = -1;
    num_select = system_select(aa_ref,"chain H",num_select);
    std::cout << "1. We found " << num_select << " atoms on chain H." << std::endl;

    // Example 2.
    num_select = -1;
    num_select = system_select(aa_ref,"chain D",num_select);
    std::cout << "2. We found " << num_select << " atoms on chain D." << std::endl;

    // Example 3.
    num_select = -1;
    num_select = system_select(aa_ref,"chain A",num_select);
    std::cout << "3. We found " << num_select << " atoms on chain A." << std::endl;


    // RESIDUE:
    // Example 4.
    num_select = -1;
    num_select = system_select(aa_ref,"resid 539 to 541",num_select);
    std::cout << "4. We found " << num_select << " atoms for residues 539 to 541." << std::endl;

    // Example 5.
    num_select = -1;
    num_select = system_select(aa_ref,"resid 397",num_select);
    std::cout << "5. We found " << num_select << " atoms for residues 397." << std::endl;


    // INDEX:
    // Example 6.
    num_select = -1;
    num_select = system_select(aa_ref,"index 150 to 350",num_select);
    std::cout << "6. We found " << num_select << " atoms for indices 150 to 350." << std::endl;

    // Example 7.
    num_select = -1;
    num_select = system_select(aa_ref,"index 1051",num_select);
    std::cout << "7. We found " << num_select << " atoms for index 1050." << std::endl;

    // Example 8.
    num_select = -1;
    num_select = system_select(aa_ref,"chainid 0",num_select);
    std::cout << "8. We found " << num_select << " atoms for chainid 0." << std::endl;

    // Example 9.
    num_select = -1;
    num_select = system_select(aa_ref,"chainid 3",num_select);
    std::cout << "9. We found " << num_select << " atoms for chainid 3." << std::endl;

    // // Example 10.
    // num_select = -1;
    // num_select = system_select(aa_ref,"chainid 3",num_select);
    // std::cout << "10. We found " << num_select << " atoms for chainid 3." << std::endl;

    // Working Example.
    num_select = -1;
    const char *pickme = "resid 411 to 418";
    num_select = system_select(aa_ref,pickme,num_select);
    std::cout << "We found " << num_select << " atoms in this selection: " << pickme << std::endl;




    /* ---------------------------------------------------------
       Allocate for selection.
       --------------------------------------------------------- */
    Atom *aa_sel;
    try
    {
        aa_sel = new Atom[num_select];
    }
    catch (std::bad_alloc xa)
    {
        std::cout << "Allocation Failure\n";
        exit(1);
    }
    // Get selection.
    system_select(aa_ref,pickme,num_select,aa_sel);



    /* ---------------------------------------------------------
       Verify: aa_sel
       --------------------------------------------------------- */
    for(int i=0; i<num_select; i++)
    {
        aa_sel[i].num_atoms = num_select;
        // aa_ref[i].print_coords();
        // printf("%s  ",aa_ref[i].chain.c_str());
        // printf("%d\n",aa_ref[i].resid);

        std::cout << "select_i: " << ' '
                  << aa_sel[i].num_atoms << ' '
                  << aa_sel[i].index << ' '
                  << aa_sel[i].resid << ' '
                  << aa_sel[i].chain << ' '
                  << aa_sel[i].restype << ' '
                  << aa_sel[i].x << ' '
                  << aa_sel[i].y << ' '
                  << aa_sel[i].z << ' '
                  << std::endl;

        if(i>4)
        {
            break;
        }
    }

// #endif // Selection



    /* ---------------------------------------------------------
       Vector of chain-vectors of Atoms.
       --------------------------------------------------------- */
// #ifdef NDEBUG
    // Atom *aa_sel;
    // int num_select = 0;
// #endif

    std::vector<std::vector<Atom>> chain_ref;
    // std::vector<std::pair<int,int>> dimers;

    // ITERATORS: itchain, ita for chain, atom.
    std::vector<std::vector<Atom>>::iterator itchain;
    std::vector<Atom>::iterator ita;

    for(int i=0; i<aa_ref[0].num_chains; i++)
    {
        std::vector<Atom> atombin; // Empty?

        // Atom *aa_sel;
        std::string selection = "chainid " + std::to_string(i);
        const char *pickme = selection.c_str();
        // std::cout << i << ' ' << pickme << std::endl;
        num_select = system_select(aa_ref,pickme,num_select);

        // std::cout << i << ' '
        //           << "We found " << num_select
        //           << " atoms for this selection: "
        //           << selection
        //           << " : "
        //           << num_select
        //           << " atoms."
        //           << std::endl;
        // std::cout << "Number of chains in chain_ref(size): " << chain_ref.size() << std::endl;

        try
        {
            aa_sel = new Atom[num_select];
        }
        catch (std::bad_alloc xa)
        {
            std::cout << "Allocation Failure\n";
            exit(1);
        }
        system_select(aa_ref,pickme,num_select,aa_sel);


        for(int j=0; j<num_select; j++)
        {
            // aa_sel[j].print_coords();
            Atom a1 = aa_sel[j]; // Copy Constructor
            // a1.print_coords();
            atombin.push_back(a1);
            // atombin.push_back(&a1);
            // atombin.push_back(aa_sel[j]);

            // if(j>3)
            // {
            //     break;
            // }
        }
        chain_ref.push_back(atombin);
        // printf("\n");
        // std::cout << "binsize: " << atombin.size() << std::endl; // 439, 427, 2..


        // if(i>4)
        // {
        //     break;
        // }
        // break;
    }
    std::cout << "# of chains: " << chain_ref.size() << std::endl;

    // exit(0);


    // KEEP THIS.
    // // EXAMPLE Iteration: chain_ref
    // for(itchain = chain_ref.begin(); itchain != chain_ref.end(); itchain++)
    // {
    //     std::cout << "Atoms in chain: " << (*itchain).size() << std::endl;
    //     for(ita = (*itchain).begin(); ita != (*itchain).end(); ita++)
    //     {
    //         (*ita).print_coords();
    //     }
    //     break;
    // }
    // exit(0);


    /* ---------------------------------------------------------
       Vector of chain-vectors of Atoms. END.
       --------------------------------------------------------- */





#ifdef MTMAP_PRE
    // Pairs: A(~439) and B(427-8).
    DimerList dimers;
    // MtDomainIndexBoundaries mtdemarcations;
    // MtIndexMap mtmap_subdomain(chain_ref.size());
    // MtIndexMap mtmap_subdomain[chain_ref.size()];
    // std::vector<std::map<std::string,int>>
    MtIndexMap mtmap_subdomain;
    MtIndexMapEntry mtentry;

    // ACCESS chain_ref
    int imonomer = 0;
    int betabool = -1;
    int i_count = -1;
    // int high_index, low_index, Nterm1, Nterm2, Mterm1, Mterm2, Cterm1, Cterm2;
    // high_index = low_index = Nterm1 = Nterm2 = Mterm1 = Mterm2 = Cterm1 = Cterm2 = -1;
    int high_index, low_index, Nterm2, Mterm1, Mterm2, Cterm1;
    // high_index = low_index = Nterm2 = Mterm1 = Mterm2 = Cterm1 = -1;


    // std::cout << "mtmap-size: " << mtmap[0].size() << std::endl;
    //                                                   exit(0);

    for(auto c: chain_ref)
    {
        high_index = low_index = Nterm2 = Mterm1 = Mterm2 = Cterm1 = -1;
        i_count += 1;
        betabool = -1;
        imonomer += 1;

        // if(c.size() >= 433)
        if((c.size() >= 433) and (c.size() <= 442))
        {
            dimers.push_back(std::make_pair(imonomer-1,imonomer));
            betabool = 0;
        }
        else if ((c.size() > 420) and (c.size() < 433))
        {
            betabool = 1;
        }


        high_index = -1;
        for(auto a: c)
        {
            if (a.index > high_index)
            {
                high_index = a.index;
            }
        }

        low_index = high_index - c.size() + 1;

        if((c.size() > 420) and (c.size() < 442))
        {
            Nterm2 = low_index + 214;
            Mterm1 = Nterm2 + 1;   // 215
            Mterm2 = Mterm1 + 168; // 383
            Cterm1 = Mterm2 + 1;   // 427/438
        }

        // std::cout << "chainid: " << imonomer - 1 << " \n"
{'fraction_non_alphanumeric': 0.21578293894244815, 'fraction_numerical': 0.018770084721004967, 'mean_word_length': 1.5842219496083798, 'pattern_counts': {'":': 0, '<': 555, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1010606', 'n_tokens_mistral': 9788, 'n_tokens_neox': 9178, 'n_words': 1921}