Skip to content

Commit

Permalink
Merge branch 'dev-vge' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinGuillaume committed Mar 13, 2024
2 parents c8e0412 + 33583d9 commit fa3b12b
Show file tree
Hide file tree
Showing 27 changed files with 14,614 additions and 68 deletions.
1 change: 0 additions & 1 deletion .github/workflows/cmake_tool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ jobs:
conan export ../app
conan export ../python_binding
conan export ../ui
conan export tools/mdprep/external/gromacs
conan export tools/mdprep
conan create . --build=missing --settings=compiler.cppstd=20
Expand Down
3 changes: 3 additions & 0 deletions dev/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@ def generate(self):

copy(self, "*.dll", self.dependencies["qt"].cpp_info.bindir, os.path.join(self.build_folder, self.cpp.build.libdirs[0]))
copy(self, "*.dll", os.path.join(self.dependencies["qt"].package_folder, "res/archdatadir/plugins"), os.path.join(self.build_folder, self.cpp.build.libdirs[0]))

copy(self, "*", os.path.join(self.dependencies["gromacs"].package_folder, "external"), os.path.join(self.build_folder, "external"))
copy(self, "*", os.path.join(self.dependencies["gromacs"].package_folder, "data", "tools","mdprep","gromacs","top"), os.path.join(self.build_folder, "data", "tools", "mdprep", "gromacs", "top" ))

def layout(self):
cmake_layout(self)
Expand Down
3 changes: 3 additions & 0 deletions lib/python_binding/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ find_package(vtx_io CONFIG REQUIRED)
find_package(pybind11 REQUIRED)

set(_VTX_PYTHON_BINDING_CONAN " ") # So the right target name can be linked

file(GLOB_RECURSE _VTX_PYTHON_BINDING_CMAKE_DIR_CONTENT "${CMAKE_CURRENT_LIST_DIR}/cmake/*")
message("VTX - _VTX_PYTHON_BINDING_CMAKE_DIR_CONTENT : <${_VTX_PYTHON_BINDING_CMAKE_DIR_CONTENT}>")
include(cmake/library.cmake)

install(TARGETS vtx_python_binding FILE_SET public_headers DESTINATION include)
Expand Down
2 changes: 1 addition & 1 deletion lib/python_binding/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class VTXPythonBindingRecipe(ConanFile):

generators = "CMakeDeps", "CMakeToolchain"

exports_sources = "CMakeLists.txt", "src/*", "include/*", "cmake/*", "python_script/*"
exports_sources = "CMakeLists.txt", "src/*", "include/*", "cmake/library.cmake", "cmake/vtx_python_binding_copy_files.cmake", "python_script/*"

def _generated_cmake_prefix(self):
return "pybind11-"
Expand Down
8 changes: 0 additions & 8 deletions lib/tool/tools/mdprep/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def requirements(self):
self.requires("vtx_app/1.0")
self.requires("vtx_ui/1.0")
self.requires("gromacs/2024.0")
self.requires("dylib/2.2.1")

def generate(self):
copy(self, "*.dll", self.dependencies["vtx_ui"].cpp_info.bindir, os.path.join(self.build_folder, self.cpp.build.libdirs[0]))
Expand All @@ -45,16 +44,9 @@ def build(self):
cmake.configure()
cmake.build()

gmx_bin_dir = os.path.join(self.dependencies["vtx-gromacs"].cpp_info.bindir, "bin")
gmx_bin_dest = os.path.join(self.build_folder, self.cpp.build.libdirs[0], "external", "tools", "mdprep", "gromacs")
for ext in ("*.exe", "*.dll", "*.a", "*.so", "*.dylib", "^[^.]$"): # No extension for executable in linux, right ? TODO !!!
copy(self, ext, gmx_bin_dir, gmx_bin_dest)


def package(self):
cmake = CMake(self)
cmake.install()
copy(self, "*.dll", (self.dependencies["vtx-gromacs"].build_folder), os.path.join(self.package_folder, "bin"))

def package_info(self):
self.cpp_info.libs = ["vtx_tool_mdprep"]
Expand Down
Binary file modified lib/tool/tools/mdprep/include/tools/mdprep/gromacs/editconf.hpp
Binary file not shown.
30 changes: 25 additions & 5 deletions lib/tool/tools/mdprep/include/tools/mdprep/gromacs/gromacs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,39 @@ namespace VTX::Tool::Mdprep::Gromacs
std::string stdout_;
std::string stderr_;
};
struct GromacsCommandArgs
struct JobReport
{
std::vector<std::string> arguments;
bool finished = false;
bool errorOccured = false;
std::vector<std::string> errors;
};
struct GromacsJobData
{
std::vector<std::string> arguments;
std::vector<size_t> expectedOutputFilesIndexes; // Meant to point toward specific argument indexes that hold
// path of output files to check
VTX::Util::DataLocker<Channels> channelsLocker;
JobReport report;
std::optional<Inputs>
interactiveSettings; // If the Inputs class is instanciated, the process is expected to be interactive.
bool operator==( const GromacsCommandArgs & ) const noexcept = default;
bool operator==( const GromacsJobData & ) const noexcept = default;
};

// The idea is to list output files from all previous job, in reverse chronological order. So we can access last
// files first. This is usefull because some job might need some files from a couple of jobs ago, but the last file
// of a given extension is always the right file. Therefore we can identify the right file to use for the job by
// taking the first one that matches the required extension.
struct CumulativeOuputFiles
{
std::vector<const std::string *> fileStringPtrs;
};

// Blindly execute gromacs with input arguments.
// Execute gromacs with input arguments then check if job issued and error
// Assumes relevant arguments have been provided and checked beforehand.
// Assumes gromacs have been instructed on where to find data files (env. var. GMXLIB) as well.
void submitGromacsCommand( const fs::path & p_gmx_exe, GromacsCommandArgs & p_args );
// Error issued by the job can be a specific string in output channels or if expected output files doesn't exists
// or are empty.
void submitGromacsJob( const fs::path & p_gmx_exe, GromacsJobData & p_args );
} // namespace VTX::Tool::Mdprep::Gromacs

#endif
Binary file modified lib/tool/tools/mdprep/include/tools/mdprep/gromacs/pdb2gmx.hpp
Binary file not shown.
Binary file not shown.
25 changes: 3 additions & 22 deletions lib/tool/tools/mdprep/include/tools/mdprep/gromacs/util.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef __VTX_TOOL_TOOLS_MDPREP_GROMACS_UTIL__
#define __VTX_TOOL_TOOLS_MDPREP_GROMACS_UTIL__

#include <array>
#include <filesystem>
namespace fs = std::filesystem;

Expand All @@ -23,28 +22,10 @@ namespace VTX::Tool::Mdprep::Gromacs
// Show gromacs where to look for forcefields
void declareFfDirectory( const fs::path & ) noexcept;

} // namespace VTX::Tool::Mdprep::Gromacs
// Fill the job report with results on the job data. Aims to indentify if all expected output files are here and if
// there is no error message in any of the chanels.
void checkJobResults( GromacsJobData & ) noexcept;

namespace VTX::Tool::Mdprep::Gromacs
{
struct GromacsCommandArgs;
struct solvateInstructions // WIP // TODO : move it in appropriate location
{
fs::path inputGro;
fs::path outputGro;
std::array<double, 3ull> box { 0., 0., 0. };
double radius = 0.105;
double scale = 0.57;
double shell = 0.;
int maxsol = 0;
bool vel = false;
};

// Write gromacs command arguments using input instructions
// Does nothing if the instructions have default values.
// Does not perform filesystem check on input gro
// If the output_gro is empty, will use the input filename root and append "solv"
void convert( const solvateInstructions &, GromacsCommandArgs & ) noexcept;
} // namespace VTX::Tool::Mdprep::Gromacs

#endif
Binary file modified lib/tool/tools/mdprep/src/gromacs/editconf.cpp
Binary file not shown.
6 changes: 3 additions & 3 deletions lib/tool/tools/mdprep/src/gromacs/gromacs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace VTX::Tool::Mdprep::Gromacs
out.clear();
}

void interactiveProcessManagement( QProcess & p_proc, bool & p_finished, GromacsCommandArgs & p_args ) noexcept
void interactiveProcessManagement( QProcess & p_proc, bool & p_finished, GromacsJobData & p_args ) noexcept
{
std::string unsentBuf, // Used when the stdout is not ready to be sent
bufErr, bufOut;
Expand Down Expand Up @@ -83,7 +83,7 @@ namespace VTX::Tool::Mdprep::Gromacs
fillMissingString( p_proc.readAllStandardOutput(), bufOut );
fillMissingString( *channels, bufErr, bufOut );
}
void simpleProcessManagement( QProcess & p_proc, bool & p_finished, GromacsCommandArgs & p_args ) noexcept
void simpleProcessManagement( QProcess & p_proc, bool & p_finished, GromacsJobData & p_args ) noexcept
{
QByteArray bufErr, bufOut;

Expand All @@ -101,7 +101,7 @@ namespace VTX::Tool::Mdprep::Gromacs
}
} // namespace

void submitGromacsCommand( const fs::path & p_gmxExe, GromacsCommandArgs & p_args )
void submitGromacsJob( const fs::path & p_gmxExe, GromacsJobData & p_args )
{
QString pgm { p_gmxExe.string().data() };
QStringList qtArgs;
Expand Down
Binary file modified lib/tool/tools/mdprep/src/gromacs/pdb2gmx.cpp
Binary file not shown.
Binary file added lib/tool/tools/mdprep/src/gromacs/solvate.cpp
Binary file not shown.
46 changes: 45 additions & 1 deletion lib/tool/tools/mdprep/src/gromacs/util.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include <regex>
//
#include "tools/mdprep/gromacs/inputs.hpp"
//
#include "tools/mdprep/gromacs/gromacs.hpp"
Expand Down Expand Up @@ -46,6 +48,48 @@ namespace VTX::Tool::Mdprep::Gromacs
qputenv( "GMXLIB", env_arg );
}

void convert( const solvateInstructions &, GromacsCommandArgs & ) noexcept {}
namespace
{
void checkErrMsg( JobReport & p_report, const std::string & p_text ) noexcept
{
const std::regex errRegex { "^[ \t]*Error (.|[\r\n])*?\n\n" };
for ( auto it = std::sregex_iterator( p_text.begin(), p_text.end(), errRegex );
it != std::sregex_iterator();
++it )
{
p_report.errors.push_back( it->operator[]( 0 ).str() );
}
}
} // namespace

void checkJobResults( GromacsJobData & p_in ) noexcept
{
{
auto channels = p_in.channelsLocker.open();
checkErrMsg( p_in.report, channels->stderr_ );
checkErrMsg( p_in.report, channels->stdout_ );
}

for ( auto & it : p_in.expectedOutputFilesIndexes )
{
fs::path f { p_in.arguments[ it ] };
if ( f.empty() )
continue;
if ( fs::exists( f ) == false || fs::is_regular_file( f ) == false )
{
p_in.report.errors.push_back(
fmt::format( "Expected output file <{}> not found.", p_in.arguments[ it ] )
);
break;
}
if ( fs::file_size( f ) == 0 )
{
p_in.report.errors.push_back( fmt::format( "Expected output file <{}> is empty.", p_in.arguments[ it ] )
);
break;
}
}
p_in.report.errorOccured = ( p_in.report.errors.empty() == false );
}

} // namespace VTX::Tool::Mdprep::Gromacs
15 changes: 4 additions & 11 deletions lib/tool/tools/mdprep/test/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,27 +24,20 @@ def requirements(self):
self.requires("qt/6.6.1", transitive_headers=True)
self.requires("vtx_tool_mdprep/1.0")
self.requires("catch2/3.4.0")
self.requires("gromacs/2024.0")

def generate(self):
copy(self, "*.dll", self.dependencies["vtx_tool_mdprep"].cpp_info.bindir, os.path.join(self.build_folder, self.cpp.build.libdirs[0]))
copy(self, "*", os.path.join(self.dependencies["gromacs"].package_folder, "external"), os.path.join(self.build_folder, "external"))
copy(self, "*", os.path.join(self.dependencies["gromacs"].package_folder, "data", "tools","mdprep","gromacs","top"), os.path.join(self.build_folder, "data", "tools", "mdprep", "gromacs", "top" ))

def layout(self):
cmake_layout(self)

def build(self):
"""
vtx_gromacs_shared = os.path.join(self.dependencies["vtx_tool_mdprep"].folders.build_folder, "vtx_gromacs")
ext = ".dll"
if self.settings.os == "iOS" :
ext = ".dylib"
if self.settings.os == "Linux" :
ext = ".so"
vtx_gromacs_shared += ext
"""
cmake = CMake(self)
cmake.configure()
cmake.build()
#self.run("ctest --rerun-failed --output-on-failure") # TODO uncomment this when build is stable
self.run("ctest --rerun-failed --output-on-failure") # TODO uncomment this when build is stable

def package(self):
cmake = CMake(self)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[ prot_sort ]
1 2 5 6 7 8 3 4 9 10 13 14 15 16 17
11 12 18 19 22 24 23 25 20 21 26 27 30 31 32
34 36 35 33 28 29 37 38 41 42 43 39 40 44 45
48 49 50 51 52 46 47 53 54 57 59 58 55 56 60
61 64 65 66 67 62 63 68 69 72 74 73 70 71 75
76 77 78 79 80 83 84 85 86 87 81 82 88 89 92
94 93 90 91 95 96 99 101 100 102 97 98 103 104 107
109 108 105 106 110 111 114 115 116 117 112 113 118 119 122
123 124 125 126 120 121 127 128 131 132 133 129 130 134 135
138 139 140 141 142 136 137 143 149 148 147 144 145 146 150
151 154 155 152 153 156 157 160 161 162 163 158 159 164 165
168 170 169 166 167 171 172 175 177 176 178 173 174 179 180
183 184 185 186 187 181 182 188 189 192 193 194 195 190 191
196 197 200 201 202 198 199 203 204 207 208 209 210 211 205
206 212 213 216 214 215 217 218 221 222 223 224 225 219 220
226 227 230 232 231 233 228 229 234 235 238 239 240 241 242
236 237 243 244 247 248 249 250 245 246 251 252 255 256 257
258 259 253 254 260 261 264 265 266 267 268 262 263 269 270
271 272 273 274 277 279 278 280 275 276 281 287 286 285 282
283 284 288 294 293 292 289 290 291 295 296 299 300 301 302
297 298 303 304 307 308 309 310 311 305 306 312 313 316 317
318 319 320 314 315 321 322 325 326 327 328 329 330 331 323
324 332 333 336 337 338 339 334 335 340 341 344 346 345 347
342 343 348 349 352 353 354 356 358 357 355 350 351 359 360
363 361 362 364 365 366 367 368 369 372 373 374 375 376 370
371 377 378 381 382 383 384 385 379 380 386 387 390 391 392
393 388 389 394 395 398 399 400 401 402 396 397 403 404 407
408 409 410 405 406 411 412 413 414 415 416 419 420 421 422
423 424 425 417 418 426 427 430 432 431 428 429 433 434 437
438 439 440 435 436 441 442 445 446 443 444 447 448 451 452
453 454 449 450 455 456 459 460 461 463 465 466 464 462 457
458 467 468 471 472 473 474 469 470 475 476 479 481 480 482
477 478 483 484 487 488 489 490 491 485 486 492 493 496 497
498 499 500 494 495 501 502 505 506 507 508 509 503 504 510
511 514 515 512 513 516 517 520 522 521 518 519 523 524 527
528 529 530 525 526 531 532 535 536 537 539 540 538 533 534
541 542 545 546 547 548 543 544 549 550 553 554 555 551 552
556 557 560 561 562 563 558 559 564 565 568 569 570 571 572
573 574 566 567 575 576 579 580 581 582 577 578 583 584 587
588 589 590 591 592 593 585 586 594 595 596 597 598 599 600
602 601
Loading

0 comments on commit fa3b12b

Please sign in to comment.