def getMthaologroupResult(slugfilename): # 芯片数据 sdata = snp.reader_dict_mtpos(slugfilename) # 存储运算结果 result = {"0": {'matchrsid': None, 'nomathrsid': None, 'weight': 0, 'name': None,'lain':0,'mandn':0}} # getMthaologroup(mttree, sdata, result) return result
def main_2m_n(filename): #更新位置信息 #update23andmeFilePos(filename) sdata = snp.reader_dict_mtpos(filename) #所有命中snp的权重和 weightTree = getTotalWeightTree(sdata, weightdict, mttree) if weightTree > 0: getMthaologroupPath(sdata, weightTree) else: print('请检查文件')
return retreepath def getFormatYhaologroupPath(treepath): re = [] for item in treepath: for k, v in item.items(): re.append(k) return re if __name__ == "__main__": filename = filename = '/Users/similarface/Documents/user2643_file1659_yearofbirth_unknown_sex_XY.23andme.txt' if len(sys.argv) != 1: print("param error!", "Use: python mthaplogroup andmefile") else: filename = filename = '/Users/similarface/Documents/user2643_file1659_yearofbirth_unknown_sex_XY.23andme.txt' #更新位置信息 #update23andmeFilePos(filename) loggername = os.path.basename( filename)[0:os.path.basename(filename).rindex('.')] logger = logging.getLogger(loggername) # 获取名为tst的logger logger.addHandler(handler) # 为logger添加handler logger.setLevel(logging.DEBUG) sdata = snp.reader_dict_mtpos(filename) #所有命中snp的权重和 weightTree = getTotalWeightTree(sdata, weightdict, mttree) if weightTree > 0: getMthaologroupPath(sdata, weightTree) else: print('请检查文件')
weightdict = getWeightDict() redirecttree = getDictFromFile() for k, v in redirecttree.items(): rsids = v['pos'] if len(rsids) != 0: for rsid in rsids: try: if rsid[-1] == sdata[rsid[1:-1]].genotype[0]: weightTree = weightTree + weightdict[rsid] except Exception, e: pass return weightTree weightTree = getTotalWeightTree( snp.reader_dict_mtpos('/Users/similarface/wocao.txt')) def getMthaologroup(mttree, sdata, result): ''' :param ytree: Y染色体的haplogroup树 :param ysnp: Y染色体突变字典 :param sdata: 芯片数据 :param result: 结果 :return: ''' id = mttree['id'] pid = mttree['pid'] name = mttree['name'] children = mttree['children']
#filename='/Users/similarface/Documents/reslut1/genome_wang_mian_Full_20151021231213.txt' filename = '/Users/similarface/wocao.txt' #filename='/Users/similarface/Documents/user10_file3_yearofbirth_1982_sex_XY.23andme.txt' #filename='/Users/similarface/Documents/user2099_file1272_yearofbirth_unknown_sex_unknown.23andme.txt' #filename=sys.argv[1] #sample 02 -->争议 #N 1785 H3 T2e1a1a #filename = '/Users/similarface/Documents/user1785_file1041_yearofbirth_unknown_sex_unknown.23andme.txt' #filename = '/Users/similarface/Downloads/11.23andme.176' #sample 03 --> #N 1875 HV9a T2e1a1a #filename = '/Users/similarface/Documents/user1875_file1113_yearofbirth_unknown_sex_unknown.23andme.txt' weightTree = getTotalWeightTree(snp.reader_dict_mtpos(filename)) print(weightTree) loggername = os.path.basename( filename)[0:os.path.basename(filename).rindex('.')] logger = logging.getLogger(loggername) # 获取名为tst的logger logger.addHandler(handler) # 为logger添加handler logger.setLevel(logging.DEBUG) # for file in ['/Users/similarface/Documents/reslut1/genome_wang_mian_Full_20151021231213.txt', # '/Users/similarface/Documents/reslut1/genome_wang_jun_chen_Full_20151021231123.txt', # '/Users/similarface/Downloads/I2b1.txt', # '/Users/similarface/Downloads/H6a1b2.txt', # '/Users/similarface/Downloads/1718.23andme.993', # '/Users/similarface/Downloads/1718.23andme.993', # '/Users/similarface/Downloads/4763.23andme.3353', # '/Users/similarface/Downloads/T',