From 3cd6e66d065781da6dd4565f0e5bf20cc316cb40 Mon Sep 17 00:00:00 2001 From: Pezhman Zarabadi-Poor Date: Thu, 29 Aug 2019 21:22:44 +0200 Subject: [PATCH 1/2] Adding output filename definition to visVoro - no format change --- .gitignore | 5 +++++ area_and_volume.cc | 18 ++++++++++------- area_and_volume.h | 2 +- arguments.cc | 15 ++++++++++++++ arguments.h | 1 + instructions.cc | 4 ++-- main.cc | 31 +++++++++++++++++++++++------ material.cc | 7 +++++-- material.h | 2 +- zeojobs.h | 49 +++++++++++++++++++++++++++++++++++++--------- 10 files changed, 106 insertions(+), 28 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..569ff9a --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +*.o +network +framework_builder +molecule_to_abstract + diff --git a/area_and_volume.cc b/area_and_volume.cc index 5b53178..1cb5ce9 100644 --- a/area_and_volume.cc +++ b/area_and_volume.cc @@ -1317,10 +1317,11 @@ void determineAccessibility(ATOM_NETWORK *atmnet, double r_probe_chan, double r_ } //create diagrams of 1) Voronoi network and 2) accessible Voronoi network in an adjacent cell if specified with shift; xyz and vtk output files generated -void visVoro(char* name, double probeRad, int skel_a, int skel_b, int skel_c, VORONOI_NETWORK* vornet, ATOM_NETWORK* atmnet) { - string filename_xyz = string(name).append("_voro.xyz"); - string filename2_xyz = string(name).append("_voro_accessible.xyz"); - string filename3_xyz = string(name).append("_voro_nonaccessible.xyz"); +void visVoro(char* name, string prefix, double probeRad, int skel_a, int skel_b, int skel_c, VORONOI_NETWORK* vornet, ATOM_NETWORK* atmnet, string filename_xyz, string filename2_xyz, string filename3_xyz, string filename_vtk, string filename2_vtk, string filename3_vtk) { +//void visVoro(char* name, string prefix, double probeRad, int skel_a, int skel_b, int skel_c, VORONOI_NETWORK* vornet, ATOM_NETWORK* atmnet) { + // string filename_xyz = string(name).append("_voro.xyz"); + // string filename2_xyz = string(name).append("_voro_accessible.xyz"); + // string filename3_xyz = string(name).append("_voro_nonaccessible.xyz"); vector accessInfo; vector nonaccessInfo; vector channels; @@ -1338,6 +1339,9 @@ void visVoro(char* name, double probeRad, int skel_a, int skel_b, int skel_c, VO }; //write Voronoi nodes as .xyz + // FILE *output_xyz; output_xyz = fopen(filename_xyz, "w"); + // FILE *output2_xyz; output2_xyz = fopen(filename2_xyz, "w"); + // FILE *output3_xyz; output3_xyz = fopen(filename3_xyz, "w"); FILE *output_xyz; output_xyz = fopen(filename_xyz.c_str(), "w"); FILE *output2_xyz; output2_xyz = fopen(filename2_xyz.c_str(), "w"); FILE *output3_xyz; output3_xyz = fopen(filename3_xyz.c_str(), "w"); @@ -1376,9 +1380,9 @@ void visVoro(char* name, double probeRad, int skel_a, int skel_b, int skel_c, VO // when printing (non)accesible network, all nodes are printed first //write Voronoi edges as .vtk - string filename_vtk = string(name).append("_voro.vtk"); - string filename2_vtk = string(name).append("_voro_accessible.vtk"); - string filename3_vtk = string(name).append("_voro_nonaccessible.vtk"); + // string filename_vtk = string(name).append("_voro.vtk"); + // string filename2_vtk = string(name).append("_voro_accessible.vtk"); + // string filename3_vtk = string(name).append("_voro_nonaccessible.vtk"); //start saving the addresses of (non)accessible nodes int *accessIndex; accessIndex = new int[accessInfo.size()]; diff --git a/area_and_volume.h b/area_and_volume.h index 982f401..fd0d0d2 100644 --- a/area_and_volume.h +++ b/area_and_volume.h @@ -63,7 +63,7 @@ double calcASA(ATOM_NETWORK *atmnet, ATOM_NETWORK *orgatmnet, bool highAccuracy, std::string calcASA(ATOM_NETWORK *atmnet, ATOM_NETWORK *orgatmnet, bool highAccuracy, double r_probe_chan, double r_probe, int numSamples, bool excludePockets, bool ExtendedOutputFlag); void determineAccessibility(ATOM_NETWORK *atmnet, double r_probe_chan, double r_probe, bool excludePockets, std::vector *isAccessible, VORONOI_NETWORK *pointSet); -void visVoro(char* name, double probeRad, int skel_a, int skel_b, int skel_c, VORONOI_NETWORK* vornet, ATOM_NETWORK* atmnet); +void visVoro(char* name, string prefix, double probeRad, int skel_a, int skel_b, int skel_c, VORONOI_NETWORK* vornet, ATOM_NETWORK* atmnet, string filename_xyz, string filename2_xyz, string filename3_xyz, string filename_vtk, string filename2_vtk, string filename3_vtk); //extract spherical substructures: this is a functionality designed for extracting local substructures of zeolites so that they can be scanned for potential guest molecule binding sites //this functionality writes out a number of xyz format files containing spherical substructures of the given radius, centred on given probe-accessible Voronoi nodes; if an element_type is given, a simplified Voronoi network is used, based only on atoms of that type diff --git a/arguments.cc b/arguments.cc index ac8e47c..03d5855 100644 --- a/arguments.cc +++ b/arguments.cc @@ -24,6 +24,21 @@ string processFilename(vector command, string name, string file_type, un } } +string processFilenameXtra(vector command, string name, string prefix, string file_type, unsigned int num_args_1, unsigned int num_args_2){ + if(command.size() == (num_args_1 + 1) || command.size() == (num_args_1 + 4)){ + return string(name).append(file_type); + } + else if (command.size() == (num_args_2 + 1) || command.size() == (num_args_2 + 4)){ + return string(prefix).append(file_type); + } + else { + cerr << "Error: " << command[0] << " option accepts " << num_args_1 << " or " << num_args_2 << " or " << num_args_1 + 3 << " or " << num_args_2 + 3 + << " arguments but " << command.size() - 1 << " arguments were supplied. " << "\n" + << "Exiting..." << "\n"; + // exit(1); + return ""; + } +} /** Assuming that -r was part of the command line parameters, this function examines the list of arguments to determine whether diff --git a/arguments.h b/arguments.h index 444b74f..a3c4342 100644 --- a/arguments.h +++ b/arguments.h @@ -9,6 +9,7 @@ using namespace std; string processFilename(vector command, string name, string file_type, unsigned int num_args_1, unsigned int num_args_2); +string processFilenameXtra(vector command, string name, string prefix, string file_type, unsigned int num_args_1, unsigned int num_args_2); void processRadialParameters(vector args); void processMassParameters(std::vector args); string processAccuracyParameters(vector args); diff --git a/instructions.cc b/instructions.cc index 41022ba..afc9913 100644 --- a/instructions.cc +++ b/instructions.cc @@ -29,7 +29,7 @@ cout << "Network commandline invocation syntax:" << "\n" << "\n" << " [-psd chan_radius probe_radius num_samples [outputfile_sa]] " << "\n" << " [-ray chan_radius probe_radius num_samples [outputfile_ray]] " << "\n" << " [-chan probe_radius [outputfile_chan]] " << "\n" - << " [-visVoro probe_radius [unit_cell_shifts: a b c]] " << "\n" + << " [-visVoro probe_radius [prefix] [unit_cell_shifts: a b c]] " << "\n" << " [-sphericalSubstructures probe_radius sphere_radius [element_type]]" << "\n" << " [-findTetrahedra element_type]" << "\n" << " [-cellmulti sphere_radius]" << "\n" @@ -105,7 +105,7 @@ cout << "Network commandline invocation syntax:" << "\n" << "\n" << " -gridG : Write distance grid in Gaussian cube format (inputfilename.cube). " << "\n" << " -gridGBohr : Write distance grid in Gaussian cube format, with distances converted from Angstrom to Bohr (inputfilename.cube). " << "\n" << " -chan probe_radius [outputfile_chan] : Determine the channels available to a probe of size $probe_radius. " << "\n" - << " -visVoro probe_radius [unit_cell_shifts: a b c] : For visualization: draw the Voronoi network as xyz and vtk formats, including only the accessible portion, which can be drawn in an adjacent unit cell with the provided shifts. " << "\n" + << " -visVoro probe_radius [prefix] [unit_cell_shifts: a b c] : For visualization: draw the Voronoi network as xyz and vtk formats, including only the accessible portion, which can be drawn in an adjacent unit cell with the provided shifts. " << "\n" << " -sphericalSubstructures probe_radius sphere_radius [element_type] : For zeolites: Write out a number of xyz format files containing spherical substructures of the given radius, centred on given probe-accessible Voronoi nodes; if an element_type is given, a simplified Voronoi network is used, based only on atoms of that type. " << "\n" << " -findTetrahedra element_type: Write to terminal the tetrahedrality (distortion) index for each tetrahedral arrangement of the specified atom type in the material" << "\n" << " -cellmulti sphere_radius: Write to terminal the number of cells required in each crystallographic axis in order to construct a supercell, where a sphere with the provided radius will not overlap with itself periodically" << "\n" diff --git a/main.cc b/main.cc index abe42b3..831fbce 100644 --- a/main.cc +++ b/main.cc @@ -1017,19 +1017,38 @@ int main(int argc, char * argv[]){ } //create skeleton diagram (prints Voronoi network to file, and accessible Voronoi network to a separate file, in an adjacent cell if specified with shift - xyz and vtk output files generated) else if(command[0].compare("-visVoro") == 0){ - if(command.size()!=2 && command.size()!=5) { - printf("Error: -visVoro option accepts 1 (probe radius) or 4 (probe radius and then a, b and c shifts for illustrating accessible part of network) arguments but %d arguments were supplied.\n", (int)(command.size() - 1)); - printf("Exiting...\n"); - // exit(1); - error=true; break; + string prefix; + //printf("%s\n",prefix.c_str()); + if(command.size()==3 || command.size() ==6) { + prefix = command[2].c_str(); + //printf("%s\n",prefix.c_str()); } + //printf("%s\n",prefix.c_str()); + string filename_xyz = processFilenameXtra(command, name, prefix, "_voro.xyz", 1, 2); + string filename2_xyz = processFilenameXtra(command, name, prefix, "_voro_accessible.xyz", 1, 2); + string filename3_xyz = processFilenameXtra(command, name, prefix, "_voro_nonaccessible.xyz", 1, 2); + string filename_vtk = processFilenameXtra(command, name, prefix, "_voro.vtk", 1, 2); + string filename2_vtk = processFilenameXtra(command, name, prefix, "_voro_accessible.vtk", 1, 2); + string filename3_vtk = processFilenameXtra(command, name, prefix, "_voro_nonaccessible.vtk", 1, 2); + + if(filename_xyz.empty() || filename2_xyz.empty() || filename3_xyz.empty() || filename_vtk.empty() || filename2_vtk.empty() || filename3_vtk.empty()) {error=true; break;} + // if(command.size()!=2 && command.size()!=5) { + // printf("Error: -visVoro option accepts 1 (probe radius) or 4 (probe radius and then a, b and c shifts for illustrating accessible part of network) arguments but %d arguments were supplied.\n", (int)(command.size() - 1)); + // printf("Exiting...\n"); + // // exit(1); + // error=true; break; + // } double probeRad = strtod(command[1].data(), NULL); int skel_a = 0, skel_b = 0, skel_c = 0; if(command.size()==5) { //if shift was provided skel_a = strtod(command[2].data(), NULL), skel_b = strtod(command[3].data(), NULL), skel_c = strtod(command[4].data(), NULL); } - visVoro(name, probeRad, skel_a, skel_b, skel_c, &vornet, &atmnet); + if(command.size()==6) { + //if shift was provided + skel_a = strtod(command[3].data(), NULL), skel_b = strtod(command[4].data(), NULL), skel_c = strtod(command[5].data(), NULL); + } + visVoro(name, prefix, probeRad, skel_a, skel_b, skel_c, &vornet, &atmnet, filename_xyz, filename2_xyz, filename3_xyz, filename_vtk, filename2_vtk, filename3_vtk); } //extract spherical substructures: this is a functionality designed for extracting local substructures of zeolites so that they can be scanned for potential guest molecule binding sites //this functionality writes out a number of xyz format files containing spherical substructures of the given radius, centred on given probe-accessible Voronoi nodes; if an element_type is given, a simplified Voronoi network is used, based only on atoms of that type diff --git a/material.cc b/material.cc index afea142..326612b 100644 --- a/material.cc +++ b/material.cc @@ -109,8 +109,11 @@ void MATERIAL::ASAreportPoints(ostream &output){ /* visVORO FUNCTION */ -void MATERIAL::visualizeVoroNet(char* name, double r, int skel_a, int skel_b, int skel_c){ - visVoro(name, r, skel_a, skel_b, skel_c, &vornet, &atmnet); +//void visVoro(char* name, string prefix, double probeRad, int skel_a, int skel_b, int skel_c, VORONOI_NETWORK* vornet, ATOM_NETWORK* atmnet, string *filename_xyz, string *filename2_xyz, string *filename3_xyz) { +//void visVoro(char* name, string prefix, double probeRad, int skel_a, int skel_b, int skel_c, VORONOI_NETWORK* vornet, ATOM_NETWORK* atmnet) { + +void MATERIAL::visualizeVoroNet(char* name, string prefix, double r, int skel_a, int skel_b, int skel_c, string filename_xyz, string filename2_xyz, string filename3_xyz, string filename_vtk, string filename2_vtk, string filename3_vtk){ + visVoro(name, prefix, r, skel_a, skel_b, skel_c, &vornet, &atmnet, filename_xyz, filename2_xyz, filename3_xyz, filename_vtk, filename2_vtk, filename3_vtk); }; // ends visVoro diff --git a/material.h b/material.h index 9204cc6..038a03e 100644 --- a/material.h +++ b/material.h @@ -169,7 +169,7 @@ class MATERIAL { void ASAcalc(double r, int sampleDensity,ostream &output, char *filename); void ASAreportPoints(ostream &output); - void visualizeVoroNet(char *, double, int, int, int); + void visualizeVoroNet(char *, string, double, int, int, int, string filename_xyz, string filename2_xyz, string filename3_xyz, string filename_vtk, string filename2_vtk, string filename3_vtk); void PLDcalc(double r, double seg_r, string seg_file, ostream &output, char *filename); void PLDcalcFromMolecules(double r, ostream &output, char *filename); diff --git a/zeojobs.h b/zeojobs.h index a347d39..dc6bb37 100644 --- a/zeojobs.h +++ b/zeojobs.h @@ -32,6 +32,7 @@ class zeoJob { std::vector< std::vector > commands; char name[256]; char extension[256]; + char prefix[256]; /* Run setting */ double probeRadius; // this stores a probe radius used in all Zeo++ analysis @@ -418,19 +419,49 @@ class zeoJob { output.close(); } else if(command[0].compare("-visVoro") == 0){ // for visualization - if(command.size()!=1 && command.size()!=4) { - printf("Error: -visVoro option accepts 0 or 3 (a, b and c shifts for illustrating accessible part of network) arguments but %d arguments were supplied.\n", (int)(command.size() - 1)); - printf("Exiting...\n"); - error=true; break; + string prefix = ""; + if(command.size()==3 || command.size() ==6) { + string prefix = command[2]; } + string filename_xyz = processFilenameXtra(command, name, prefix, "_voro.xyz", 1, 2); + string filename2_xyz = processFilenameXtra(command, name, prefix, "_voro_accessible.xyz", 1, 2); + string filename3_xyz = processFilenameXtra(command, name, prefix, "_voro_nonaccessible.xyz", 1, 2); + string filename_vtk = processFilenameXtra(command, name, prefix, "_voro.vtk", 1, 2); + string filename2_vtk = processFilenameXtra(command, name, prefix, "_voro_accessible.vtk", 1, 2); + string filename3_vtk = processFilenameXtra(command, name, prefix, "_voro_nonaccessible.vtk", 1, 2); + + if(filename_xyz.empty() || filename2_xyz.empty() || filename3_xyz.empty() || filename_vtk.empty() || filename2_vtk.empty() || filename3_vtk.empty()) {error=true; break;} + + + // string filename_xyz = processFilenameXtra(command, name, prefix, "_voro.xyz", 1, 2); + // string filename2_xyz = processFilenameXtra(command, name, prefix, "_voro_accessible.xyz", 1, 2); + // string filename3_xyz = processFilenameXtra(command, name, prefix, "_voro_nonaccessible.xyz", 1, 2); + // if(filename_xyz.empty() || filename2_xyz.empty() || filename3_xyz.empty()) {error=true; break;} + // if(command.size()!=1 && command.size()!=4) { + // printf("Error: -visVoro option accepts 0 or 3 (a, b and c shifts for illustrating accessible part of network) arguments but %d arguments were supplied.\n", (int)(command.size() - 1)); + // printf("Exiting...\n"); + // error=true; break; + // } + double probeRad = strtod(command[1].data(), NULL); int skel_a = 0, skel_b = 0, skel_c = 0; - if(command.size()==4) { + if(command.size()==5) { + //if shift was provided + skel_a = strtod(command[2].data(), NULL), skel_b = strtod(command[3].data(), NULL), skel_c = strtod(command[4].data(), NULL); + } + if(command.size()==6) { //if shift was provided - skel_a = strtod(command[1].data(), NULL), skel_b = strtod(command[2].data(), NULL), skel_c = strtod(command[3].data(), NULL); - }; + skel_a = strtod(command[3].data(), NULL), skel_b = strtod(command[4].data(), NULL), skel_c = strtod(command[5].data(), NULL); + } + + + // int skel_a = 0, skel_b = 0, skel_c = 0; + // if(command.size()==4) { + // //if shift was provided + // skel_a = strtod(command[1].data(), NULL), skel_b = strtod(command[2].data(), NULL), skel_c = strtod(command[3].data(), NULL); + // }; Material.runVoroFlat(); - // visVoro(name, probeRad, skel_a, skel_b, skel_c, &vornet, &atmnet); - Material.visualizeVoroNet(name, probeRadius, skel_a, skel_b, skel_c); + // visVoro(name, prefix, probeRad, skel_a, skel_b, skel_c, &vornet, &atmnet); + Material.visualizeVoroNet(name, prefix, probeRadius, skel_a, skel_b, skel_c, filename_xyz, filename2_xyz, filename3_xyz, filename_vtk, filename2_vtk, filename3_vtk); } //Rich: holograms as a separate flag, -holo From 743edae2a49ce35e7161c0bf5485742ecd324fe8 Mon Sep 17 00:00:00 2001 From: Pezhman Zarabadi-Poor Date: Wed, 9 Oct 2019 15:36:14 +0200 Subject: [PATCH 2/2] Changed naming of visVoro xyz output files --- main.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.cc b/main.cc index 831fbce..e589dd1 100644 --- a/main.cc +++ b/main.cc @@ -1024,9 +1024,12 @@ int main(int argc, char * argv[]){ //printf("%s\n",prefix.c_str()); } //printf("%s\n",prefix.c_str()); - string filename_xyz = processFilenameXtra(command, name, prefix, "_voro.xyz", 1, 2); - string filename2_xyz = processFilenameXtra(command, name, prefix, "_voro_accessible.xyz", 1, 2); - string filename3_xyz = processFilenameXtra(command, name, prefix, "_voro_nonaccessible.xyz", 1, 2); + string filename_xyz = processFilenameXtra(command, name, prefix, ".voro", 1, 2); + string filename2_xyz = processFilenameXtra(command, name, prefix, ".voro_accessible", 1, 2); + string filename3_xyz = processFilenameXtra(command, name, prefix, ".voro_nonaccessible", 1, 2); + // string filename_xyz = processFilenameXtra(command, name, prefix, "_voro.xyz", 1, 2); + // string filename2_xyz = processFilenameXtra(command, name, prefix, "_voro_accessible.xyz", 1, 2); + // string filename3_xyz = processFilenameXtra(command, name, prefix, "_voro_nonaccessible.xyz", 1, 2); string filename_vtk = processFilenameXtra(command, name, prefix, "_voro.vtk", 1, 2); string filename2_vtk = processFilenameXtra(command, name, prefix, "_voro_accessible.vtk", 1, 2); string filename3_vtk = processFilenameXtra(command, name, prefix, "_voro_nonaccessible.vtk", 1, 2);