Skip to content

Instantly share code, notes, and snippets.

View hainm's full-sized avatar

Hai Nguyen hainm

View GitHub Profile
@hainm
hainm / rmsd_two_parms.py
Last active August 29, 2015 14:15
pytraj: rmsd_two_parms.py
"""calculate RMSD for two proteins with different topologies"""
from pytraj import io as mdio
# create trajectory objects (having frames)
traj_0 = mdio.load("../tests/data/Tc5b.crd", "../tests/data/Tc5b.top")
traj_1 = mdio.load("../tests/data/ala3.dcd", "../tests/data/ala3.psf")
# get new traj objects with given mask
traj_0_new = traj_0[":8-10@CA :frame"]
@hainm
hainm / test.pyx
Last active March 27, 2017 08:35
test.pyx
# distutils: language = c++
cdef cppclass A:
void c_test():
print ("hello from A")
cdef cppclass B(A):
void SetObject(A* ptr):
print ("dummy method, hello from B")
cdef class pyA:
@hainm
hainm / test_cython_setter.pyx
Created April 8, 2015 22:26
cython settter
cdef class MyTest (object):
cdef public object _x
def __cinit__(self):
self._x = 0
@property
def x(self):
return self._x
@x.setter
@hainm
hainm / test_rmsd.py
Last active August 29, 2015 14:20
check_rmsd_from_dataset
# test get reference Frame from DataSetList
traj = mdio.load("./data/md1_prod.Tc5b.x", "./data/Tc5b.top")
dslist = DataSetList()
dslist.add_set("ref_frame", "myname")
dslist[0].top = traj.top.copy()
# use last Frame for reference
dslist[0].append(traj[-1])
# dslist.get_reference_frame("myname")
@hainm
hainm / gist:3dc21e9585a8c1103650
Created June 9, 2015 19:43
cython + python2 error
Traceback (most recent call last):
File "/home/hainm/anaconda3/envs/python2/bin/cython", line 9, in <module>
load_entry_point('Cython==0.23.dev0', 'console_scripts', 'cython')()
File "/home/hainm/anaconda3/envs/python2/lib/python2.7/site-packages/Cython-0.23.dev0-py2.7-linux-x86_64.egg/Cython/Compiler/Main.py", line 676, in setuptools_main
return main(command_line = 1)
File "/home/hainm/anaconda3/envs/python2/lib/python2.7/site-packages/Cython-0.23.dev0-py2.7-linux-x86_64.egg/Cython/Compiler/Main.py", line 693, in main
result = compile(sources, options)
File "/home/hainm/anaconda3/envs/python2/lib/python2.7/site-packages/Cython-0.23.dev0-py2.7-linux-x86_64.egg/Cython/Compiler/Main.py", line 668, in compile
return compile_multiple(source, options)
File "/home/hainm/anaconda3/envs/python2/lib/python2.7/site-packages/Cython-0.23.dev0-py2.7-linux-x86_64.egg/Cython/Compiler/Main.py", line 646, in compile_multiple
@hainm
hainm / most-active-users-on-github-2015.md
Last active August 29, 2015 14:26 — forked from eddiejaoude/most-active-users-on-github-2015.md
Most active users on GitHub 2015

This is the top 1000 users on GitHub

Where are you on here?

For the first 6 months of 2015 (Jan - June).

Query used on Google's BigQuery with GitHubArchive Data

SELECT actor.login as user, COUNT(*) as total FROM (
CPPTRAJ: Trajectory Analysis. V16.00b
___ ___ ___ ___
| \/ | \/ | \/ |
_|_/\_|_/\_|_/\_|_
| Date/time: 08/05/15 16:30:04
| Available memory: 132.562 MB
INPUT: Reading Input from file dih.in
[parm G5.pdb]
$ pip install https://github.com/ParmEd/ParmEd/archive/2.0.5.tar.gz
Collecting https://github.com/ParmEd/ParmEd/archive/2.0.5.tar.gz
Downloading https://github.com/ParmEd/ParmEd/archive/2.0.5.tar.gz
| 32.0MB 12.1MB/s
Installing collected packages: ParmEd
Found existing installation: ParmEd 2.3.2
Uninstalling ParmEd-2.3.2:
Successfully uninstalled ParmEd-2.3.2
Running setup.py install for ParmEd ... done
Successfully installed ParmEd-2.3.2
import pytraj as pt
import numpy as np
traj = pt.iterload('tz2.nc', 'tz2.parm7')
# note: use pt.load method if your trajectory is fit well to memory
c0 = pt.center_of_mass(traj, ':1-3')
c1 = pt.center_of_mass(traj, ':4-7')
c2 = pt.center_of_mass(traj, ':8-10')
c3 = pt.center_of_mass(traj, ':11-13')
# Q: [AMBER] Working with pytraj
# use all atoms in residue 1
c_o_G = pt.center_of_geometry(traj, mask=':1')
# or
# use given atoms in residue 1
c_o_G = pt.center_of_geometry(traj, mask=':1@C1,N6,C2,C4,N7')
pt.vector.corrplane(traj, mask=':1@C1,N6,C2,C4,N7')