计算DNA中两个碱基的中点

import math
#up_sticky_end is the up strand where the sequence is split
#bottom_sticky_end is the bottom strand where the sequence is split
def Calculate_distance(file_pdb,up_strand_list,bottom_strand_list,up_sticky_end,bottom_sticky_end):
    file_pdb_data=open(file_pdb,'r')
    lines_data=file_pdb_data.readlines()
    file_pdb_data.close()
    up_point_list=[]
    bottom_point_list=[]
    for i in range(0,len(up_strand_list)):
        for line_data in lines_data:
            line_data_list=line_data.split()
            if up_strand_list[i]!=up_sticky_end:
                if up_strand_list[i] in line_data_list[4:] and "P" in line_data_list[2:]:
                    up_point_list.append(line_data_list[-5:-2])
                    break
            elif up_strand_list[i]==up_sticky_end:
                if up_strand_list[i] in line_data_list[4:] and "O5'" in line_data_list[2:]:
                    up_point_list.append(line_data_list[-5:-2])
                    break
    for j in range(0,len(bottom_strand_list)):
        for line_data in lines_data:
            line_data_list=line_data.split()
            if bottom_strand_list[j]!=bottom_sticky_end:
                if bottom_strand_list[j] in line_data_list[4:] and "P" in line_data_list[2:]:    
                    bottom_point_list.append(line_data_list[-5:-2])
                    break
            elif bottom_strand_list[j]==bottom_sticky_end:
                if bottom_strand_list[j] in line_data_list[4:] and "O5'" in line_data_list[2:]:    
                    bottom_point_list.append(line_data_list[-5:-2])
                    break
    print up_point_list[1:],bottom_point_list[:-1]    
    return up_point_list[1:],bottom_point_list[:-1]
def distance(list1,list2,i):
    x_avg=(float(list1[i][0])+float(list2[i][0]))/2
    y_avg=(float(list1[i][1])+float(list2[i][1]))/2
    z_avg=(float(list1[i][2])+float(list2[i][2]))/2
    return x_avg,y_avg,z_avg                            
def extract_resdue_list(file):
    resdue_file=open(file,"r")
    all_resdue_list=[]
    for line in resdue_file.readlines():
        line_list=line.split()[1:]
        all_resdue_list.append(line_list)
    resdue_file.close()
    return all_resdue_list
if __name__=="__main__":
    #resdue_lists=extract_resdue_list("sequence.txt")

    #The following is the test data

    L1=["756","757","530"]

    L2=["52","12","11"]
    list_one,list_two=Calculate_distance("0.pdb",L1,L2,"93","-1")
    distance(list_one,list_two)
           

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值