Пример #1
0
    def __init__(self,
                 radius: float = 8.0,
                 max_neighbors: float = 12,
                 step: float = 0.2):
        """
    Parameters
    ----------
    radius: float (default 8.0)
      Radius of sphere for finding neighbors of atoms in unit cell.
    max_neighbors: int (default 12)
      Maximum number of neighbors to consider when constructing graph.
    step: float (default 0.2)
      Step size for Gaussian filter. This value is used when building edge features.
    """

        self.radius = radius
        self.max_neighbors = int(max_neighbors)
        self.step = step

        # load atom_init.json
        data_dir = get_data_dir()
        download_url(ATOM_INIT_JSON_URL, data_dir)
        atom_init_json_path = os.path.join(data_dir, 'atom_init.json')
        with open(atom_init_json_path, 'r') as f:
            atom_init_json = json.load(f)

        self.atom_features = {
            int(key): np.array(value, dtype=np.float32)
            for key, value in atom_init_json.items()
        }
        self.valid_atom_number = set(self.atom_features.keys())
Пример #2
0
    def __init__(self,
                 sixty_four_bits: bool = True,
                 pocket_finder: Optional[BindingPocketFinder] = None):
        """Initializes Vina Pose Generator

    Parameters
    ----------
    sixty_four_bits: bool, optional (default True)
      Specifies whether this is a 64-bit machine. Needed to download
      the correct executable.
    pocket_finder: BindingPocketFinder, optional (default None)
      If specified should be an instance of
      `dc.dock.BindingPocketFinder`.
    """
        data_dir = get_data_dir()
        if platform.system() == 'Linux':
            url = "http://vina.scripps.edu/download/autodock_vina_1_1_2_linux_x86.tgz"
            filename = "autodock_vina_1_1_2_linux_x86.tgz"
            dirname = "autodock_vina_1_1_2_linux_x86"
            self.vina_dir = os.path.join(data_dir, dirname)
            self.vina_cmd = os.path.join(self.vina_dir, "bin/vina")
        elif platform.system() == 'Darwin':
            if sixty_four_bits:
                url = "http://vina.scripps.edu/download/autodock_vina_1_1_2_mac_64bit.tar.gz"
                filename = "autodock_vina_1_1_2_mac_64bit.tar.gz"
                dirname = "autodock_vina_1_1_2_mac_catalina_64bit"
            else:
                url = "http://vina.scripps.edu/download/autodock_vina_1_1_2_mac.tgz"
                filename = "autodock_vina_1_1_2_mac.tgz"
                dirname = "autodock_vina_1_1_2_mac"
            self.vina_dir = os.path.join(data_dir, dirname)
            self.vina_cmd = os.path.join(self.vina_dir, "bin/vina")
        elif platform.system() == 'Windows':
            url = "http://vina.scripps.edu/download/autodock_vina_1_1_2_win32.msi"
            filename = "autodock_vina_1_1_2_win32.msi"
            self.vina_dir = "\\Program Files (x86)\\The Scripps Research Institute\\Vina"
            self.vina_cmd = os.path.join(self.vina_dir, "vina.exe")
        else:
            raise ValueError(
                "Unknown operating system.  Try using a cloud platform to run this code instead."
            )
        self.pocket_finder = pocket_finder
        if not os.path.exists(self.vina_dir):
            logger.info("Vina not available. Downloading")
            download_url(url, data_dir)
            downloaded_file = os.path.join(data_dir, filename)
            logger.info("Downloaded Vina. Extracting")
            if platform.system() == 'Windows':
                msi_cmd = "msiexec /i %s" % downloaded_file
                check_output(msi_cmd.split())
            else:
                with tarfile.open(downloaded_file) as tar:
                    tar.extractall(data_dir)
            logger.info("Cleanup: removing downloaded vina tar.gz")
            os.remove(downloaded_file)
Пример #3
0
    def __init__(self):
        """Initialize GNINA pose generator."""

        data_dir = get_data_dir()
        if platform.system() == 'Linux':
            url = "https://github.com/gnina/gnina/releases/download/v1.0/gnina"
            filename = 'gnina'
            self.gnina_dir = data_dir
            self.gnina_cmd = os.path.join(self.gnina_dir, filename)
        else:
            raise ValueError(
                "GNINA currently only runs on Linux. Try using a cloud platform to run this code instead."
            )

        if not os.path.exists(self.gnina_cmd):
            logger.info("GNINA not available. Downloading...")
            download_url(url, data_dir)
            downloaded_file = os.path.join(data_dir, filename)
            os.chmod(downloaded_file, 755)
            logger.info("Downloaded GNINA.")