Created
June 3, 2014 11:54
-
-
Save heliy/b213758baf414bbd64d9 to your computer and use it in GitHub Desktop.
ctypes的使用测试
This file contains hidden or 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
""" | |
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