ekraka / SSnet

MIT License
19 stars 9 forks source link

Something confusing about find_pairs in make_target.py #5

Open ZillaRU opened 1 year ago

ZillaRU commented 1 year ago

https://github.com/ekraka/SSnet/blob/6a28140b2e54e5415553609a612fcae92f9103f0/SSnet_in_Action/make_target.py#L44-L79 I tried to process 2ONL.pdb with your code. 2ONL is a protein with 4 chains (containing 338, 339, 317, and 313 alpha carbons, respectively). But the function gave the curvature/torsion data of size 339 (=338+1), 340 (=339+1), 317, and 313, respectively. It seems weird. Diving into your implementation, I find the code handles the last alpha carbon of each chain as a special case. When running out the items in A but the last item in a has no curvature/torsion data, take the curvature/torsion data of the last one in A as the curvature/torsion for the last item in a.

FYI, I write a new version of this function.

def find_pairs(a, A):
    pointer = 0
    max_p = len(A[0])
    res_idx = []  # result index

    # 给每个真实点找最靠近它的插值点 用其曲率挠率作为真实点的曲率挠率
    for i in range(len(a[0])):
        print(i)
        min_dis = 999.0
        a1 = np.array([a[0][i], a[1][i], a[2][i]])  # x y z
        while pointer < max_p:
            A1 = np.array([A[0][pointer], A[1][pointer], A[2][pointer]])
            dis = LA.norm(a1 - A1)
            if dis <= min_dis:
                min_dis = dis
                pointer = pointer + 1
            else:
                res_idx.append(pointer - 1)
                break
    # 如果还没为最后一个真实点找插值点,用最后一个插值点的曲率挠率作为最后一个真实点的曲率挠率
    if pointer >= max_p and len(res_idx) < len(a[0]):
        res_idx.append(max_p - 1)
    assert len(res_idx) == len(a[0])
    return res_idx
yliuhz commented 1 year ago

ORZ