diff --git a/FPSim2/io/chem.py b/FPSim2/io/chem.py index a8957f6..085dce3 100644 --- a/FPSim2/io/chem.py +++ b/FPSim2/io/chem.py @@ -1,4 +1,4 @@ -from typing import Any, Callable, Iterable as IterableType, Dict, List, Tuple, Union +from typing import Any, Callable, Iterable as IterableType, Dict, Tuple, Union from FPSim2.FPSim2lib.utils import BitStrToIntList, PyPopcount from collections.abc import Iterable from rdkit.Chem import rdMolDescriptors diff --git a/FPSim2/src/utils.cpp b/FPSim2/src/utils.cpp index 457cab1..ae1fa92 100644 --- a/FPSim2/src/utils.cpp +++ b/FPSim2/src/utils.cpp @@ -23,8 +23,13 @@ namespace utils { py::list BitStrToIntList(const std::string &bit_string) { py::list efp; - for (size_t i = 0; i < bit_string.length(); i += 64) { - efp.append(std::stoull(bit_string.substr(i, 64), 0, 2)); + size_t len = bit_string.length(); + for (size_t i = 0; i < len; i += 64) { + uint64_t value = 0; + for (size_t j = 0; j < 64 && (i + j) < len; ++j) { + value = (value << 1) | (bit_string[i + j] - '0'); + } + efp.append(value); } return efp; }