diff --git a/changelog b/changelog index 8a6a95b..e227ef4 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,6 @@ Version 2.2.0 -- Added support for +- Added option to write out source of data into json file +- Updated node modules Version 2.1.1 - Fix a bug that caused too many residues being placed where diff --git a/src/alphafill.cpp b/src/alphafill.cpp index 81333dc..360f380 100644 --- a/src/alphafill.cpp +++ b/src/alphafill.cpp @@ -143,7 +143,7 @@ std::tuple isUniqueLigand(const cif::mm::structure &str result = { UniqueType::MoreAtoms, np.get_asym_id() }; else result = { UniqueType::Seen, np.get_asym_id() }; - + break; } } @@ -158,7 +158,8 @@ std::tuple isUniqueLigand(const cif::mm::structure &str for (auto &a : lig.atoms()) atoms_a.emplace_back(a.get_label_atom_id(), a.get_location()); - sort(atoms_a.begin(), atoms_a.end(), [](auto &a, auto &b) { return std::get<0>(a) < std::get<0>(b); }); + sort(atoms_a.begin(), atoms_a.end(), [](auto &a, auto &b) + { return std::get<0>(a) < std::get<0>(b); }); for (auto &np : structure.non_polymers()) { @@ -169,7 +170,8 @@ std::tuple isUniqueLigand(const cif::mm::structure &str for (auto &a : np.atoms()) atoms_b.emplace_back(a.get_label_atom_id(), a.get_location()); - sort(atoms_b.begin(), atoms_b.end(), [](auto &a, auto &b) { return std::get<0>(a) < std::get<0>(b); }); + sort(atoms_b.begin(), atoms_b.end(), [](auto &a, auto &b) + { return std::get<0>(a) < std::get<0>(b); }); std::vector pa, pb; @@ -425,7 +427,7 @@ int create_index(int argc, char *const argv[]) fs::path file = fiter->path(); std::string name = file.filename().string(); - if (not (cif::ends_with(name, "_final.cif") or cif::ends_with(name, "_final.cif.gz"))) + if (not(cif::ends_with(name, "_final.cif") or cif::ends_with(name, "_final.cif.gz"))) continue; q1.push(file); @@ -490,7 +492,8 @@ void check_blast_index() // -------------------------------------------------------------------- -zeep::json::element alphafill(cif::datablock &db, const std::vector &v_pae, alphafill_progress_cb &&progress) +zeep::json::element alphafill(cif::datablock &db, const std::string &source, + const std::vector &v_pae, alphafill_progress_cb &&progress) { using namespace std::literals; using namespace cif::literals; @@ -540,7 +543,8 @@ zeep::json::element alphafill(cif::datablock &db, const std::vector json result = { { "id", afID }, { "date", ss.str() }, - { "alphafill_version", kVersionNumber } + { "alphafill_version", kVersionNumber }, + { "source", source } }; json &hits = result["hits"] = json::array(); @@ -573,7 +577,7 @@ zeep::json::element alphafill(cif::datablock &db, const std::vector auto j = seq.find(')', i + 1); if (j == std::string::npos or j > i + 2) throw std::runtime_error("Invalid sequence"); - + seq.erase(i, j - i + 1); i = seq.find('(', i + 1); } @@ -810,14 +814,10 @@ zeep::json::element alphafill(cif::datablock &db, const std::vector json r_hsp{ { "pdb_id", pdb_id }, { "pdb_asym_id", pdb_res.front()->get_asym_id() }, - { - "alignment", { - { "af_start", hsp.mQueryStart }, - { "identity", hsp.identity() }, - { "length", hsp.length() }, - { "pdb_start", hsp.mTargetStart } - } - }, + { "alignment", { { "af_start", hsp.mQueryStart }, + { "identity", hsp.identity() }, + { "length", hsp.length() }, + { "pdb_start", hsp.mTargetStart } } }, { "global_rmsd", rmsd } }; @@ -876,16 +876,15 @@ zeep::json::element alphafill(cif::datablock &db, const std::vector auto &rep_res = af_structure.get_residue(replace_id); if (cif::VERBOSE > 0) std::cerr << "Residue " << res << " has more atoms than the first transplant " << rep_res << '\n'; - + try { af_structure.remove_residue(rep_res); for (auto &hit : hits) { - auto ti = std::find_if(hit["transplants"].begin(), hit["transplants"].end(), [id=replace_id](json &e) { - return e["asym_id"] == id; - }); + auto ti = std::find_if(hit["transplants"].begin(), hit["transplants"].end(), [id = replace_id](json &e) + { return e["asym_id"] == id; }); if (ti != hit["transplants"].end()) { hit["transplants"].erase(ti); @@ -893,12 +892,12 @@ zeep::json::element alphafill(cif::datablock &db, const std::vector } } } - catch(const std::exception& e) + catch (const std::exception &e) { if (cif::VERBOSE > 0) std::cerr << "Failed to remove residue with asym ID " << replace_id << ": " << e.what() << '\n'; } - + break; } @@ -1110,11 +1109,15 @@ zeep::json::element alphafill(cif::datablock &db, const std::vector af_structure.cleanup_empty_categories(); auto &software = af_structure.get_category("software"); - software.emplace({ { "pdbx_ordinal", software.size() + 1 }, // TODO: should we check this ordinal number??? + software.emplace({ + // + { "pdbx_ordinal", software.size() + 1 }, // TODO: should we check this ordinal number??? { "name", "alphafill" }, { "version", kVersionNumber }, { "date", kRevisionDate }, - { "classification", "model annotation" } }); + { "classification", "model annotation" } + // + }); return result; } @@ -1179,6 +1182,8 @@ int alphafill_main(int argc, char *const argv[]) mcfp::make_hidden_option("blast-gap-open", 11, "Blast penalty for gap open"), mcfp::make_hidden_option("blast-gap-extend", 1, "Blast penalty for gap extend"), + mcfp::make_option("data-source", "user", "Data source for input model"), + mcfp::make_option("threads,t", std::thread::hardware_concurrency(), "Number of threads to use, zero means all available cores"), mcfp::make_hidden_option("custom-dir", (fs::temp_directory_path() / "alphafill").string(), "Directory for custom built entries") @@ -1220,6 +1225,12 @@ int alphafill_main(int argc, char *const argv[]) return 1; } + if (config.get("data-source") != "AFDB" and config.get("data-source") != "BFVD" and config.get("data-source") != "user") + { + std::cerr << "Invalid data-source, allowed values are 'AFDB', 'BFVD' and 'user'\n"; + return 1; + } + fs::path paein; if (config.has("pae-file")) @@ -1244,7 +1255,7 @@ int alphafill_main(int argc, char *const argv[]) if (fs::exists(paein)) v_pae = load_pae_from_file(paein); - json metadata = alphafill(f.front(), v_pae, my_progress{}); + json metadata = alphafill(f.front(), config.get("data-source"), v_pae, my_progress{}); if (config.operands().size() == 2) { diff --git a/src/alphafill.hpp b/src/alphafill.hpp index 9f7c948..10ab8c2 100644 --- a/src/alphafill.hpp +++ b/src/alphafill.hpp @@ -44,7 +44,8 @@ struct alphafill_progress_cb using PAE_matrix = cif::matrix; -zeep::json::element alphafill(cif::datablock &db, const std::vector &pae, alphafill_progress_cb &&progress); +zeep::json::element alphafill(cif::datablock &db, const std::string &source, + const std::vector &pae, alphafill_progress_cb &&progress); int alphafill_main(int argc, char *const argv[]); int create_index(int argc, char *const argv[]); diff --git a/src/data-service.cpp b/src/data-service.cpp index c1c8189..57e481e 100644 --- a/src/data-service.cpp +++ b/src/data-service.cpp @@ -632,7 +632,7 @@ void data_service::process_queued(const std::filesystem::path &xyzin, const std: fs::rename(paein, m_work_dir / paein.filename(), ec); } - auto metadata = alphafill(f.front(), pae_data, data_service_progress{ m_progress }); + auto metadata = alphafill(f.front(), "user", pae_data, data_service_progress{ m_progress }); try { diff --git a/src/main.cpp b/src/main.cpp index e67c046..ee167c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,9 +24,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "main.hpp" #include "alphafill.hpp" #include "config.hpp" -#include "main.hpp" #include "revision.hpp" #include "validate.hpp" @@ -38,9 +38,9 @@ #include #if defined(BUILD_WEB_APPLICATION) -#include "data-service.hpp" -#include "db-connection.hpp" -#include "server.hpp" +# include "data-service.hpp" +# include "db-connection.hpp" +# include "server.hpp" #endif namespace fs = std::filesystem; @@ -76,8 +76,7 @@ int rebuild_db_main(int argc, char *const argv[]) mcfp::make_option("threads,t", std::thread::hardware_concurrency(), "Number of threads to use, zero means all available cores"), - mcfp::make_hidden_option("custom-dir", (fs::temp_directory_path() / "alphafill").string(), "Directory for custom built entries") - ); + mcfp::make_hidden_option("custom-dir", (fs::temp_directory_path() / "alphafill").string(), "Directory for custom built entries")); parse_argv(argc, argv, config); @@ -199,7 +198,7 @@ int main(int argc, char *const argv[]) else { const std::string usage = -R"(usage: alphafill command [options] + R"(usage: alphafill command [options] where command is one of @@ -207,11 +206,11 @@ where command is one of (A FastA file is required to process files) process Process an AlphaFill structure)" #if defined(BUILD_WEB_APPLICATION) -R"( + R"( rebuild-db Rebuild the databank server Start a web server instance)" #endif -R"( + R"( The following options are always recognized: )"; @@ -235,7 +234,7 @@ The following options are always recognized: if (config.operands().empty()) std::cerr << "Missing command" - << "\n\n"; + << "\n\n"; std::cerr << config << '\n'; return config.has("help") ? 0 : 1;