lixiaolong80的个人博客分享 http://blog.sciencenet.cn/u/lixiaolong80

博文

计算重组率

已有 6972 次阅读 2015-1-16 11:23 |个人分类:科研笔记|系统分类:科研笔记

##file为bed文件:chr,start,end    file1为10条染色体的cM数据:position,cM

import os,sys

import bisect

for file in os.listdir("/share/xulab_10t/lxl/IBD_20141224_recobination"):

   if file.endswith("_trop_trop.bed"):

       file1=file.replace("_trop_trop.bed",".raw.sort")

       file2=file.replace("bed","cM")

       inf1=open(file,"r")

       inf2=open(file1,"r")

       ouf=open(file2,"w")

       d={}

       for line in inf2:

           L=line.strip().split()

           d[int(float(L[1]))]=float(L[0])

       sd=[(k,d[k]) for k in sorted(d.keys())]

       #print sd[0:20]

       sd_key=map(lambda x:x[0],sd)

       print sd[0:20],sd_key[0:20]

       for line in inf1:

           b=line.strip().split()

           start=int(b[1])

           end=int(b[2])

           start_key= min(sd_key, key=lambda x:abs(x-start))

           end_key=min(sd_key, key=lambda x:abs(x-end))

           #print start_key,end_key

           ouf.write("%st%st%st%st%sn" % (b[0],b[1],b[2], d[start_key] ,d[end_key]))





https://blog.sciencenet.cn/blog-2360083-859934.html

上一篇:一个对fasta文件进行操作的python code
下一篇:时间太瘦,指缝太宽
收藏 IP: 111.203.22.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-5-19 15:36

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部