Skip to content

Commit

Permalink
Merge branch 'develop' into trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Jan 20, 2025
2 parents 8dd73fe + 86022bd commit e91295f
Show file tree
Hide file tree
Showing 16 changed files with 3,388 additions and 3,023 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ docs/conf.py
new-alphafill.conf
docroot/_sources/
docroot/_static/
docroot/dist/
docroot/.doctrees/
docroot/.buildinfo
docroot/**/index.html
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ cmake_minimum_required(VERSION 3.21)
# set the project name
project(
alphafill
VERSION 2.1.1
VERSION 2.2.0
LANGUAGES C CXX)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
Expand Down Expand Up @@ -132,7 +132,7 @@ if(NOT zeep_FOUND)
FetchContent_Declare(
zeep
GIT_REPOSITORY https://github.com/mhekkel/libzeep.git
GIT_TAG v6.0.11)
GIT_TAG v6.0.16)
FetchContent_MakeAvailable(zeep)
endif()

Expand Down
4 changes: 4 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 2.2.0
- 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
they are not unique.
Expand Down
7 changes: 6 additions & 1 deletion docroot/alphafill.json.schema
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"description": "Date of AlphaFill run",
"type": "string"
},
"source": {
"description": "Data source for input model",
"type": "string",
"enum": ["AFDB", "BFVD", "user"]
},
"file": {
"description": "Input file used for AlphaFill",
"type": "string"
Expand Down Expand Up @@ -277,4 +282,4 @@
},
"title": "Validation"
}
}}
}}
20 changes: 16 additions & 4 deletions docroot/model.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,22 @@ <h5 z:text="${title}"></h5>
<td><a z:href="@{/v1/aff/${af_id}/json}"
z:text="|${af_id}/json|"></a></td>
</tr>
<tr>
<td>Original AlphaFold model</td>
<td><a z:href="|https://alphafold.ebi.ac.uk/entry/${id}|"
z:text="|https://alphafold.ebi.ac.uk/entry/${id}|" target="_BLANK"></a></td>

<tr z:switch="${source}">
<z:block z:case="BFVD">
<td>Original BFVD model</td>
<td>
<a z:href="|https://bfvd.foldseek.com/cluster/${id}|"
z:text="|https://bfvd.foldseek.com/cluster/${id}|" target="_BLANK"></a>
</td>
</z:block>
<z:block z:case="*">
<td>Original AlphaFold model</td>
<td>
<a z:href="|https://alphafold.ebi.ac.uk/entry/${id}|"
z:text="|https://alphafold.ebi.ac.uk/entry/${id}|" target="_BLANK"></a>
</td>
</z:block>
</tr>
</table>

Expand Down
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"@babel/runtime-corejs3": "^7.16.0",
"bootstrap": "^5.1.3",
"core-js": "^3.19.1",
"molstar": "^2.3.5"
"gyp": "^0.5.0",
"molstar": "^4.10.0"
},
"scripts": {
"build": "webpack --config webpack.config.js",
Expand All @@ -21,17 +22,21 @@
"@babel/preset-env": "^7.16.0",
"@babel/preset-typescript": "^7.16.0",
"@popperjs/core": "^2.10.2",
"babel-loader": "^8.2.3",
"babel-loader": "^9.2.1",
"clean-webpack-plugin": "^4.0.0",
"css-loader": "^6.5.0",
"css-loader": "^7.1.2",
"mini-css-extract-plugin": "^2.4.3",
"postcss": "^8.4.49",
"postcss-loader": "^8.1.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"sass": "^1.43.4",
"sass-loader": "^12.3.0",
"sass-loader": "^16.0.4",
"terser-webpack-plugin": "^5.2.5",
"ts-loader": "^9.2.6",
"uglifyjs-webpack-plugin": "^2.2.0",
"webpack": "^5.60.0",
"webpack-cli": "^4.9.1"
"webpack-cli": "^6.0.1"
},
"babel": {
"presets": [
Expand Down
35 changes: 30 additions & 5 deletions src/alphafill.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,8 @@ void check_blast_index()

// --------------------------------------------------------------------

zeep::json::element alphafill(cif::datablock &db, const std::vector<PAE_matrix> &v_pae, alphafill_progress_cb &&progress)
zeep::json::element alphafill(cif::datablock &db, const std::string &source,
const std::vector<PAE_matrix> &v_pae, alphafill_progress_cb &&progress)
{
using namespace std::literals;
using namespace cif::literals;
Expand Down Expand Up @@ -542,7 +543,8 @@ zeep::json::element alphafill(cif::datablock &db, const std::vector<PAE_matrix>
json result = {
{ "id", afID },
{ "date", ss.str() },
{ "alphafill_version", kVersionNumber }
{ "alphafill_version", kVersionNumber },
{ "source", source }
};

json &hits = result["hits"] = json::array();
Expand Down Expand Up @@ -970,6 +972,11 @@ zeep::json::element alphafill(cif::datablock &db, const std::vector<PAE_matrix>
auto entity_id = af_structure.create_non_poly_entity(comp_id);
auto asym_id = af_structure.create_non_poly(entity_id, res.atoms());

// Hack to get better molstar rendering
auto &rres = af_structure.get_residue(asym_id);
for (auto &atom : rres.atoms())
atom.set_property("label_alt_id", asym_id);

auto &hsp_t = r_hsp["transplants"].emplace_back(json{
{ "compound_id", comp_id },
// {"entity_id", entity_id},
Expand Down Expand Up @@ -1071,6 +1078,12 @@ zeep::json::element alphafill(cif::datablock &db, const std::vector<PAE_matrix>
// now fix up the newly created residue
ligand.modify(af_structure, asym_id);

// Give all the atoms in the newly created residue an alt_id with the same
// value as the asym_id, improves rendering in molstar

for (auto atom : res.atoms())
atom.set_property("label_alt_id", asym_id);

// validation info?
if (hsp.identity() == 1)
{
Expand Down Expand Up @@ -1105,11 +1118,15 @@ zeep::json::element alphafill(cif::datablock &db, const std::vector<PAE_matrix>
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;
}
Expand Down Expand Up @@ -1174,6 +1191,8 @@ int alphafill_main(int argc, char *const argv[])
mcfp::make_hidden_option<int>("blast-gap-open", 11, "Blast penalty for gap open"),
mcfp::make_hidden_option<int>("blast-gap-extend", 1, "Blast penalty for gap extend"),

mcfp::make_option("data-source", "user", "Data source for input model"),

mcfp::make_option<size_t>("threads,t", std::thread::hardware_concurrency(), "Number of threads to use, zero means all available cores"),

mcfp::make_hidden_option<std::string>("custom-dir", (fs::temp_directory_path() / "alphafill").string(), "Directory for custom built entries")
Expand Down Expand Up @@ -1215,6 +1234,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"))
Expand All @@ -1239,7 +1264,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)
{
Expand Down
3 changes: 2 additions & 1 deletion src/alphafill.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ struct alphafill_progress_cb

using PAE_matrix = cif::matrix<uint8_t>;

zeep::json::element alphafill(cif::datablock &db, const std::vector<PAE_matrix> &pae, alphafill_progress_cb &&progress);
zeep::json::element alphafill(cif::datablock &db, const std::string &source,
const std::vector<PAE_matrix> &pae, alphafill_progress_cb &&progress);
int alphafill_main(int argc, char *const argv[]);

int create_index(int argc, char *const argv[]);
Expand Down
1 change: 1 addition & 0 deletions src/blast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ struct DiagonalStartTable
{
DiagonalStartTable()
: mTable(nullptr)
, mTableLength(0)
{
}
~DiagonalStartTable() { delete[] mTable; }
Expand Down
2 changes: 1 addition & 1 deletion src/data-service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
19 changes: 9 additions & 10 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -38,9 +38,9 @@
#include <thread>

#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;
Expand Down Expand Up @@ -76,8 +76,7 @@ int rebuild_db_main(int argc, char *const argv[])

mcfp::make_option<size_t>("threads,t", std::thread::hardware_concurrency(), "Number of threads to use, zero means all available cores"),

mcfp::make_hidden_option<std::string>("custom-dir", (fs::temp_directory_path() / "alphafill").string(), "Directory for custom built entries")
);
mcfp::make_hidden_option<std::string>("custom-dir", (fs::temp_directory_path() / "alphafill").string(), "Directory for custom built entries"));

parse_argv(argc, argv, config);

Expand Down Expand Up @@ -199,19 +198,19 @@ 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
create-index Create a FastA file based on data in the PDB files
(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:
)";
Expand All @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,9 @@ void affd_html_controller::model(const zh::request &request, const zh::scope &sc
sub.put("title", e.what());
}

// Add the source
sub.put("source", data["source"]);

// TODO: These magic numbers should of course be configurable parameters
// 11.43, 3.04 voor global, en 3.10 en 0.92 voor local
sub.put("cutoff", json{
Expand Down Expand Up @@ -1202,7 +1205,7 @@ int server_main(int argc, char *const argv[])
if (config.has("no-daemon"))
result = server.run_foreground(address, port);
else
result = server.start(address, port, 1, 16, user);
result = server.start(address, port, 16, user);
}
else if (command == "stop")
result = server.stop();
Expand Down
32 changes: 0 additions & 32 deletions webapp/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,36 +101,4 @@ window.addEventListener('load', () => {

window.location = `v1/aff/${AF_ID}/stripped/${selected.join(',')}/${IDENTITY}`;
});

// // Update PAE matrices
// const cv = [...document.querySelectorAll("td.pae-matrix canvas")];
// cv.forEach(c => {
// const ctx = c.getContext("2d");

// const pae = JSON.parse(c.getAttribute("data-pae"));

// const dim = Math.sqrt(pae.length);
// const scale = 32.0 / dim;

// ctx.scale(scale, scale);

// let i = 0;
// for (let x = 0; x < dim; ++x)
// {
// for (let y = 0; y < dim; ++y)
// {
// const v = 1.0 * pae[i];
// i += 1;

// console.log(v);

// const clr = `hsl(220,60%,${Math.round(25 + 50 * (v / 32.0))}%)`;

// ctx.fillStyle = clr;
// ctx.fillRect(x, y, 1, 1);
// }
// }
// });


})
Loading

0 comments on commit e91295f

Please sign in to comment.