Skip to content

Instantly share code, notes, and snippets.

View matteoferla's full-sized avatar

Matteo Ferla matteoferla

View GitHub Profile
@matteoferla
matteoferla / chem_isomorphisms.py
Created May 23, 2024 13:54
chemical isomorphism
"""
Chemical isomorphism refers to the phenomenon where elements of similar electron density,
such as carbon (C), nitrogen (N), and oxygen (O), cannot be easily distinguished in the electron density map.
This is because these atoms scatter X-rays similarly, resulting in overlapping or indistinguishable electron density.
This isomorphism is also called `crystallographic ambiguity`.
.. code-block:: python
isomorphics: List[Chem.Mol] = get_chemical_isomorphisms(hit)
@matteoferla
matteoferla / rototranslate.py
Created May 9, 2024 16:36
RDKit fix reference frame of molecule
# I am sure I have pasted this snippet somewhere, but I always forget where —so may be a duplicate.
wrong_ref: Chem.Mol = ... # the reference mol in former frame/location/crystal
right_ref: Chem.Mol = ... # the reference mol in desired frame
wrong: Chem.Mol = ... # the target
affine_matrix = AllChem.GetAlignmentTransform(wrong_ref, right_ref)[1]
AllChem.TransformConformer(wrong.GetConformer(), affine_matrix) # this is in place
@matteoferla
matteoferla / slimmer
Created March 6, 2024 17:38
Slim down PSE file with superposed chains in multiple objects
import numpy as np
import pymol2
token_resi = 25 # this present in all chains
filename = '👾👾👾.pse'
coords = {}
with pymol2.PyMOL() as pymol:
pymol.cmd.load('crysalin_lattice.pse')
for name in pymol.cmd.get_object_list():
for chain in pymol.cmd.get_chains(name):
@matteoferla
matteoferla / cuda11.8.md
Last active January 26, 2024 17:01
Singularity and CUDA

I want Pytorch, Jax and Tensorflow.

Check: nvidia-smi still gives 'NVIDIA-SMI 510.85.02 Driver Version: 510.85.02 CUDA Version: 11.6 '

conda activate base
unset LD_LIBRARY_PATH
unset CUDA_HOME
export NEW_ENV='cuda118redux'
export CONDA_ALWAYS_YES=yes
@matteoferla
matteoferla / best_template.ipynb
Last active December 12, 2023 09:54
Find the best Fragalysis template retrospectively. Namely, a compound was positioned against a template under an induced fit assumption, whereas for visualisation lock and key is needed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matteoferla
matteoferla / adding_xyz_in_NGL.js
Created December 12, 2023 06:16
Add xyz to origin in NGL.js
// In NGL it may be handy to show an XYZ system axes / caltrop / cube edge
// the following is called via `addAxis(stage)`
const addAxis = (stage) => {
let shape = new NGL.Shape("shape", { dashedCylinder: true })
shape.addArrow([ 0, 0, 0 ], [ 10, 0, 0 ], [ 1, 0, 0 ], 1.0);
shape.addText([ 12, 0, 0 ], [ 1, 0, 0 ], 2.5, "x");
shape.addArrow([ 0, 0, 0 ], [ 0, 10, 0 ], [ 0, 1, 0 ], 1.0);
shape.addText([ 0, 12, 0 ], [ 0, 1, 0 ], 2.5, "y");
shape.addArrow([ 0, 0, 0 ], [ 0, 0, 10 ], [ 0, 0, 1 ], 1.0);
@matteoferla
matteoferla / notes_on_OESpicoli_tests.md
Last active December 4, 2023 16:30
Get void with OpenEye Spicoli

I wanted to get the void volume with OpenEye Spicoli for use in OERocs.

But it did not create a usable surface.

This here is for my reference as I am missing something.

Standard reading:

# -----------------------------------
@matteoferla
matteoferla / test-cset.ipynb
Created November 13, 2023 13:38
Testing cset-uload
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@matteoferla
matteoferla / job.sh
Last active October 12, 2023 13:02
Example of how I run a Fragmenstein analysis in Diamond
#! bin/bash
# For scripts required see: https://gist.github.com/matteoferla/e0496d5766c12a0ae1738b943b41a536
# A few things don't work in CentOS 7 due to GNU lib C (glibc) 2.17, so it has to be run in a Singularity container
: << USAGE
export JOB_SCRIPT=/data/xchem-fragalysis/shared/singularity.sh;
export APPTAINER_CONTAINER=/data/xchem-fragalysis/shared/singularity/rockyplus.sif;
export JOB_INNER_SCRIPT=/data/xchem-fragalysis/mferla/Zika/job.sh;
condor_submit /data/xchem-fragalysis/shared/target_script.condor
@matteoferla
matteoferla / bashrc.sh
Last active December 21, 2023 10:08
A bunch of scripts used on the HTCondor cluster
# ========================
# Sets presents...
# tries to source $HOME/.bashrc
# or $HOME2/.bashrc;
# or a fallback
# ========================
# source /data/xchem-fragalysis/shared/bashrc.sh
# universal fixes