This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fix_topology(topology): | |
new_top = topology.copy() | |
residues = {} | |
for chain in new_top.chains: | |
#print chain | |
for residue in chain.residues: | |
resname = str(residue) | |
if resname in list(residues.keys()): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor | |
import numpy as np | |
def compute_random_forests(features, projected_tica_coords, rf_dir, n_trees=500, | |
n_tica_components=25, start_tIC=0): | |
features = np.concatenate(features) | |
tics = np.concatenate(projected_tica_coords) | |
for j in range(start_tIC, np.shape(tics)[1]): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
The :mod:`sklearn.kernel_approximation` module implements several | |
approximate kernel feature maps base on Fourier transforms. | |
""" | |
# Author: Andreas Mueller <amueller@ais.uni-bonn.de> | |
# | |
# License: BSD 3 clause | |
import warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fix_topology(topology): | |
new_top = topology.copy() | |
residues = {} | |
for chain in new_top.chains: | |
#print chain | |
for residue in chain.residues: | |
resname = str(residue) | |
if resname in residues.keys(): | |
residues[resname].append(residue) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mdtraj as md | |
import os | |
import h5py | |
import multiprocessing as mp | |
from functools import partial | |
import pytraj.io as mdio | |
def get_trajectory_files(traj_dir, ext = ".h5"): | |
traj_files = [] | |
for traj in os.listdir(traj_dir): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fix_topology(topology): | |
new_top = topology.copy() | |
residues = {} | |
for chain in new_top.chains: | |
#print chain | |
for residue in chain.residues: | |
resname = str(residue) | |
if resname in residues.keys(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Many PDB Files have an issue where a single chemical residue (e.g., a single histidine) will have each of its atoms, while | |
chemically bonded, spread out across the PDB file. This confuses many PDB readers, as it will assume each non-contiguous | |
line for that residue corresponds to separate residues. This class has a function that takes as inputs the name of the original | |
pdb file and the name of a new file to which the user would like to write. It then finds all residues corresponding to proteins, | |
and stores them in a dict, with keys as a tuple of (residue_name, residue_chain, and residue_number) and with values as a | |
list of physical lines in the PDB file that correspond to that unique residue identifier. The function then prints the initial header, | |
prints the exact same PDB file lines just in a different order that maintains contiguousness within each residue, and then prints | |
all membrane, solvent, and other lines. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'''I should formalize this with a class, etc., but here's how one can use this: | |
with a file corresponding to a trajectory you want to featurize, call: | |
featurize_custom(traj_file) | |
''' | |
def fix_topology(topology): |