Skip to content

Instantly share code, notes, and snippets.

@heliy
Created June 3, 2014 11:54
Show Gist options
  • Save heliy/b213758baf414bbd64d9 to your computer and use it in GitHub Desktop.
Save heliy/b213758baf414bbd64d9 to your computer and use it in GitHub Desktop.
ctypes的使用测试
"""
7万个SNP的hw平横检验MAF的过滤
纯 python ver:
pypy 约 20s
python 约 25s
用 ctypes 调用 c ver:
pypy 约 18s
python 约 12s <- 比pypy还要好
pypy ver : 2.0.2
python ver : 2.7
"""
from ctypes import *
dll_path = "./nande/hw.so"
hw = CDLL(dll_path)
hw.hw.restype = c_double
hw.hw.argtypes = [c_int] * 3
def __cal_hw(self):
"""
计算Hardy-Wenberg平衡p值
"""
[aa, ab, bb] = self.geno_count[:-1]
return hw.hw(aa, ab, bb)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment