Skip to content

Instantly share code, notes, and snippets.

@myociss
myociss / get_hits.jl
Created June 9, 2025 21:44
Protein docking: get hits in top n
cutoff_a = 2.5
l_u_copy = deepcopy(all_residues_dict["l_u"])
close_irmsds = []
for score_rank in 1:length(top_scores)
rotation_idx, t, score = top_scores[score_rank]
translation = voxel_size * ([t[1],t[2],t[3]] - [center_val+1,center_val+1,center_val+1])
all_residues_dict["l_u"] = apply_transformation(l_u_copy, get_rotation(rotation_vectors[rotation_idx,:]), translation)
i_rmsd = calc_interface_rmsd(all_residues_dict)
@myociss
myociss / scan_6D.jl
Created June 9, 2025 18:45
Protein docking: scan 6D
using Rotations
using LinearAlgebra
using ImageTransformations
using CoordinateTransformations
using Interpolations
using FFTW
using StatsBase
function scan_6d(rotation_vectors::Matrix{Float64}, receptor_volume::Array{ComplexF64, 3}, ligand_volume::Array{ComplexF64, 3})
top_scores = []
@myociss
myociss / discretize_molecules.jl
Created June 6, 2025 21:04
Protein Docking: discretization
volume_dim = 128
receptor_volume, ligand_volume = zeros(volume_dim, volume_dim, volume_dim), zeros(volume_dim, volume_dim, volume_dim)
vols = Dict('l' => ligand_volume, 'r' => receptor_volume)
asa_min = 1.0
# receptor -- iteration 1: [core: sqrt(1.5)*r, surface: sqrt(0.8)*r], iteration 2: [core: 0.0 (skip), surface: r + 3.4]
rr_iter1 = [receptor_atoms_asa[i] < asa_min ? sqrt(1.5)*receptor_radius_list[i] : sqrt(0.8)*receptor_radius_list[i] for i in 1:length(receptor_atoms_asa)]
rr_iter2 = [receptor_atoms_asa[i] < asa_min ? 0.0 : receptor_radius_list[i]+3.4 for i in 1:length(receptor_atoms_asa)]
@myociss
myociss / get_asa.jl
Last active June 6, 2025 21:58
Protein Docking: get accessible surface area
function get_sphere_points(n::Int)
dl = pi * (3.0 - sqrt(5.0))
dz = 2.0 / n
longitude = 0
z = 1 - dz / 2
coords = zeros(n, 3)
for k in 1:n
r = sqrt((1 - z * z))
@myociss
myociss / extract_interface.jl
Created June 5, 2025 20:39
Protein Docking: extract interface
# determine if each amino acid is part of the interface of the complex
interface_max_dist = 10.0
for res_key_l in keys(all_residues_dict["l_b"])
atom_l_coords = all_residues_dict["l_b"][res_key_l]["coords"]
for res_key_r in keys(all_residues_dict["r_b"])
atom_r_coords = all_residues_dict["r_b"][res_key_r]["coords"]
is_interface = any([norm(coord2 - coord1) <= interface_max_dist for coord2 in atom_r_coords for coord1 in atom_l_coords])
@myociss
myociss / load_protein_data.jl
Last active June 5, 2025 20:43
Protein Docking: load protein data
using BioStructures
proteins_dict = Dict()
protein_complex_pdb_id = "3WD5"
figures_path = mkpath(string(protein_complex_pdb_id, "_figures"))
for designation in ("l_u", "r_u", "l_b", "r_b")
protein = read(string("./protein_data/", protein_complex_pdb_id, '_', designation, ".pdb"), PDBFormat)
length(protein.models) == 1 || throw(DomainError(protein.models), "pdb files should only contain one model")
proteins_dict[designation] = protein[1]
@myociss
myociss / proteins.jl
Last active June 16, 2025 01:41
protein docking algorithm implementation in julia
using BioStructures
using LinearAlgebra
using PlotlyJS
using DataFrames
using StaticArrays
using Rotations
using ImageTransformations
using CoordinateTransformations
using Interpolations
using FFTW
@myociss
myociss / heat_method_voronoi.cpp
Last active May 6, 2019 01:59
utilize CGAL's heat method to assign Voronoi site id to each vertex on a triangle surface mesh
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Surface_mesh.h>
#include <CGAL/Heat_method_3/Surface_mesh_geodesic_distances_3.h>
#include <fstream>
#include <iostream>
#include <boost/foreach.hpp>
typedef CGAL::Simple_cartesian<double> Kernel;
typedef Kernel::Point_3 Point_3;