Skip to content

Instantly share code, notes, and snippets.

@JoaoRodrigues
JoaoRodrigues / diffseq.py
Created October 25, 2016 01:46
PyMOL script to highlight mutated residues between two proteins
"""
(c) 2016 Joao Rodrigues
"""
from __future__ import print_function
from pymol import cmd
# Autocomplete
def _autocomplete():
@JoaoRodrigues
JoaoRodrigues / pw_dist_numba.py
Created February 8, 2017 10:14
Pairwise Distance Calculation on Nx3 (xyz) Matrix
@jit()
def pw_dist(xyz_array):
"""Iteration-based pairwise distance calculator"""
A = xyz_array
M, N = A.shape
max_d = 0.0
for i in xrange(M):
print(i)
_t = []
@JoaoRodrigues
JoaoRodrigues / pwdistance.pyx
Last active February 8, 2017 10:29
Cythonized Pairwise Distance Calculation
"""
Cython optimized pairwise distance function on numpy matrix (3xN).
"""
from __future__ import print_function
import numpy as np
cimport numpy as np
# data type of our arrays
DTYPE = np.float
@JoaoRodrigues
JoaoRodrigues / bio_dssp.py
Created April 24, 2017 22:35
Relative Solvent Accessibilities using Biopython and DSSP
#!/usr/bin/env python
"""
Demonstration of calling DSSP and accessing accessibilities using Biopython
"""
from Bio.PDB import PDBParser, DSSP
# Make sure you downloaded 1ctf in PDB format first..
pdb_filepath = '1ctf.pdb'
@JoaoRodrigues
JoaoRodrigues / hydrophobic_moment.md
Last active July 13, 2022 20:40
Peptide/Protein Hydrophobic Moment Calculator
@JoaoRodrigues
JoaoRodrigues / draw_ss.py
Last active February 19, 2024 20:47
Protein Secondary Structure Diagram/Plot using Matplotlib
#!/usr/bin/env python
"""
Draws a SS plot, representing strands as arrows and helices as waves from
a SS-containing file (H/E/etc). Turns are drawn as single arcs.
Example Input:
1 C
2 H
3 H
ATOM 1 CAY MET A 1 -56.399 2.562 22.154 0.00 0.00
ATOM 2 HY1 MET A 1 -56.751 3.253 21.523 0.00 0.00
ATOM 3 HY2 MET A 1 -55.521 2.858 22.528 0.00 0.00
ATOM 4 HY3 MET A 1 -57.053 2.413 22.896 0.00 0.00
ATOM 5 CY MET A 1 -56.269 1.704 21.658 0.00 0.00
ATOM 6 OY MET A 1 -55.917 1.013 22.289 0.00 0.00
ATOM 7 N MET A 1 -56.536 1.836 20.703 1.00 0.00 N
ATOM 8 HN MET A 1 -56.888 2.527 20.072 0.00 0.00
ATOM 9 CA MET A 1 -56.346 0.586 19.980 1.00 0.00 C
ATOM 10 HA MET A 1 -56.929 -0.175 20.484 0.00 0.00
PSF CMAP
7 !NTITLE
REMARKS original generated structure x-plor psf file
REMARKS 2 patches were applied to the molecule.
REMARKS topology C:/Users/joaor/Downloads/toppar/top_all36_prot.rtf
REMARKS topology C:/Users/joaor/Downloads/toppar/top_all22_prot.rtf
REMARKS segment A { first ACE; last CT3; auto angles dihedrals }
REMARKS patch CT3 A:27
REMARKS patch ACE A:1
REMARK 200 Generated with PyMOL and psico
ATOM 1 CY MET A 1 -57.588 1.993 21.439 1.00 0.00 C
ATOM 2 OY MET A 1 -58.412 1.073 21.529 1.00 0.00 O
ATOM 3 CAY MET A 1 -57.792 3.297 22.180 1.00 0.00 C
ATOM 4 N MET A 1 -56.540 1.838 20.704 1.00 0.00 N
ATOM 5 CA MET A 1 -56.332 0.585 19.985 1.00 0.00 C
ATOM 6 C MET A 1 -54.885 0.158 20.046 1.00 0.00 C
ATOM 7 O MET A 1 -54.053 0.864 20.614 1.00 0.00 O
ATOM 8 CB MET A 1 -56.802 0.738 18.512 1.00 0.00 C
ATOM 9 CG MET A 1 -58.316 0.961 18.308 1.00 0.00 C
@JoaoRodrigues
JoaoRodrigues / fetch_sequences.py
Created June 5, 2019 19:43
Using Biopython (Bio.Entrez) to fetch sequences from NCBI
from Bio import Entrez
Entrez.email = None # change this!
assert Entrez.email is not None
# Read ids from file to a list
id_list = [ ... ]
results = {}
handle = Entrez.efetch(db="protein", id=id_list, retmode="xml")