<commit_before>#include "mol_and_orb.h"

/*void mol_and_orb::write_pdb(string file, string name_mol="PPY", const int & n=0 ){
    
    ofstream fl;
    static bool first_time=true;
    if (first_time==true){
       fl.open(file.c_str());
       first_time=false;
    }
    else {
        fl.open(file.c_str(), ios::app);
    }
    fl.setf(ios::fixed);
    for (int i =0 ; i < N ;i++ ){
         fl << setw(6) << "HETATM"
           << setw(5) << n+i
           << setw(5) << atom_labels[i]._type
           << setw(4) << name_mol
           << setw(3) << atom_labels[i]._lbl
           << setw(3) << "1" 
           << setw(4) << " "
           << setw(8) << setprecision(3) << RA*((atom_pos[i]).getX())
           << setw(8) << setprecision(3) << RA*((atom_pos[i]).getY())
           << setw(8) << setprecision(3) << RA*((atom_pos[i]).getZ())
           << setw(6) << setprecision(2) << 1.0
           << setw(6) << setprecision(2) << 20.0
           << setw(10) << "TM" << endl;
    }
    fl.close();
}*/

void mol_and_orb::write_pdb(string file, string name_mol, const int & n=0 ){
    FILE* out_qm;
    if(n==0){
       out_qm = fopen(file.c_str(), "w");
    }
    else{
        out_qm = fopen(file.c_str(), "a");
    }
    for (int i=0 ; i < N ;i++ ){
        fprintf(out_qm, "ATOM  %5d %4c %3s %1s%4d    %8.3f%8.3f%8.3f%6.2f%6.2f\n", (n+i+1)%100000, (atom_labels[i]._type)[0],
name_mol.c_str(), " ", (n+1)/N, RA*((atom_pos[i]).getX()), RA*((atom_pos[i]).getY()), RA*((atom_pos[i]).getZ()), 1.0, 20.0);
    }
    fclose(out_qm);
}

int mol_and_orb::init_charges(const char * neutrfile, const char * crgfile){
    _neutr = new multipoles;
    _crged = new multipoles;
    _neutr->read_crg_eps(neutrfile);
    _crged->read_crg_eps(crgfile);
    return 0;
}

int mol_and_orb::init(const char * nameinput){
	int i=0, j=0 ;
	// read molecule//////////////////////////////////////////////////////////////////////////////////////

	ifstream in;
	in.open(nameinput);
	if(!in){cout << "Error, file " << nameinput << "does not exist" << endl; return 1;}
	string  xch,ych,zch;
	double x,y,z;
        n_el=0;
	centre.setX(0.);
	centre.setY(0.);
	centre.setZ(0.);
        
	string word;
        
	vec pos;
	
	int lbl;
	string type;
        char chtype;
	atom_type a_type;

	while ( in >> word){

		if(i%4==0){
		    if (word[0] != '#' ) {
                        type= word;
                        chtype= word[0];
                    }
		    else {getline(in, word); i--;}
		}
		else if (i%4==1) xch = word;
		else if (i%4==2) ych = word;
		else if (i%4==3) {
			zch = word;
			switch (chtype ){
			
			//set up labls, basis set ///////////////////////////////
			    case 'C': {  // definition of notation used:
				lbl = (5);
				n_el += _bs->get_nel_at(lbl);
				break;
				      }
			    case 'N': {
				lbl = ( 6);
				n_el += _bs->get_nel_at(lbl);
				break;
			
				      }
			    case 'O': {
				lbl = (7);
				n_el += _bs->get_nel_at(lbl);<commit_msg>added an error message if empty string is found in mol_and_orb reader<commit_after>#include "mol_and_orb.h"
#include <stdexcept>
using std::runtime_error;
/*void mol_and_orb::write_pdb(string file, string name_mol="PPY", const int & n=0 ){
    
    ofstream fl;
    static bool first_time=true;
    if (first_time==true){
       fl.open(file.c_str());
       first_time=false;
    }
    else {
        fl.open(file.c_str(), ios::app);
    }
    fl.setf(ios::fixed);
    for (int i =0 ; i < N ;i++ ){
         fl << setw(6) << "HETATM"
           << setw(5) << n+i
           << setw(5) << atom_labels[i]._type
           << setw(4) << name_mol
           << setw(3) << atom_labels[i]._lbl
           << setw(3) << "1" 
           << setw(4) << " "
           << setw(8) << setprecision(3) << RA*((atom_pos[i]).getX())
           << setw(8) << setprecision(3) << RA*((atom_pos[i]).getY())
           << setw(8) << setprecision(3) << RA*((atom_pos[i]).getZ())
           << setw(6) << setprecision(2) << 1.0
           << setw(6) << setprecision(2) << 20.0
           << setw(10) << "TM" << endl;
    }
    fl.close();
}*/

void mol_and_orb::write_pdb(string file, string name_mol, const int & n=0 ){
    FILE* out_qm;
    if(n==0){
       out_qm = fopen(file.c_str(), "w");
    }
    else{
        out_qm = fopen(file.c_str(), "a");
    }
    for (int i=0 ; i < N ;i++ ){
        fprintf(out_qm, "ATOM  %5d %4c %3s %1s%4d    %8.3f%8.3f%8.3f%6.2f%6.2f\n", (n+i+1)%100000, (atom_labels[i]._type)[0],
name_mol.c_str(), " ", (n+1)/N, RA*((atom_pos[i]).getX()), RA*((atom_pos[i]).getY()), RA*((atom_pos[i]).getZ()), 1.0, 20.0);
    }
    fclose(out_qm);
}

int mol_and_orb::init_charges(const char * neutrfile, const char * crgfile){
    _neutr = new multipoles;
    _crged = new multipoles;
    _neutr->read_crg_eps(neutrfile);
    _crged->read_crg_eps(crgfile);
    return 0;
}

int mol_and_orb::init(const char * nameinput){
	int i=0, j=0 ;
	// read molecule//////////////////////////////////////////////////////////////////////////////////////

	ifstream in;
	in.open(nameinput);
	if(!in){cout << "Error, file " << nameinput << "does not exist" << endl; return 1;}
	string  xch,ych,zch;
	double x,y,z;
        n_el=0;
	centre.setX(0.);
	centre.setY(0.);
	centre.setZ(0.);
        
	string word;
        
	vec pos;
	
	int lbl;
	string type;
        char chtype;
	atom_type a_type;

	while ( in >> word){

		if(i%4==0){
		    if (word[0] != '#' ) {
                        type= word;
                        chtype= word[0];
                    }
		    else {getline(in, word); i--;}
		}
                else if (word == "" )
                    throw runtime_error(string ("no empty lines in atomistic representation of qm molecule please. Bad file: " )
                            + string(nameinput) );

		else if (i%4==1) xch = word;
		else if (i%4==2) ych = word;
		else if (i%4==3) {
			zch = word;
			switch (chtype ){
			
			//set up labls, basis set ///////////////////////////////
			    case 'C': {  // definition of notation used:
				lbl = (5);
				n_el += _bs->get_nel_at(lbl);
				break;
				      }
			    case 'N': {
				lbl = ( 6);
				n_el += _bs->get_nel_at(lbl);
				break;
			
				      }
			    case 'O': {
				lbl = (7);
				n_el += _bs->get_nel_at(lbl);
{'fraction_non_alphanumeric': 0.22379194092149624, 'fraction_numerical': 0.025686305988120082, 'mean_word_length': 1.911214953271028, 'pattern_counts': {'":': 0, '<': 152, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3798714', 'n_tokens_mistral': 2649, 'n_tokens_neox': 2436, 'n_words': 478}