FreyrS / dMaSIF

Other
191 stars 44 forks source link

why the interface is computed like this ? #42

Closed camel2000 closed 10 months ago

camel2000 commented 1 year ago

this function in data_iteration.py as below,

def generate_matchinglabels(args, P1, P2):
    if args.random_rotation:
        P1["xyz"] = torch.matmul(P1["rand_rot"].T, P1["xyz"].T).T + P1["atom_center"]
        P2["xyz"] = torch.matmul(P2["rand_rot"].T, P2["xyz"].T).T + P2["atom_center"]
    xyz1_i = LazyTensor(P1["xyz"][:, None, :].contiguous())
    xyz2_j = LazyTensor(P2["xyz"][None, :, :].contiguous())

    xyz_dists = ((xyz1_i - xyz2_j) ** 2).sum(-1).sqrt()
    xyz_dists = (1.0 - xyz_dists).step()

    p1_iface_labels = (xyz_dists.sum(1) > 1.0).float().view(-1)
    p2_iface_labels = (xyz_dists.sum(0) > 1.0).float().view(-1)

    P1["labels"] = p1_iface_labels
    P2["labels"] = p2_iface_labels

my question is: what is the meaning of xyz_dists.sum(1) > 1.0 and I think the value in the array of xyz_dists.sum(1) is less than 1.0 , and maybe in most case the value should be negative, so the p1_iface_labels may have no non-zero value. which means there is no interface.

YAndrewL commented 10 months ago

Same question, did you solve this?

jeanfeydy commented 10 months ago

Hi @camel2000, @YAndrewL ,

Apologies for the long delay. To answer briefly: please note that the .step() function is "old" KeOps syntax that means "> 0". As a consequence, writing:

xyz_dists = ((xyz1_i - xyz2_j) ** 2).sum(-1).sqrt()
xyz_dists = (1.0 - xyz_dists).step()

creates a (N_1, N_2) LazyTensor of "booleans" whose value xyz_dists[i, j] indicates if point i from protein 1 and point j from protein 2 are at distance < 1 Angstrom from each other. Then, computing:

p1_iface_labels = (xyz_dists.sum(1) > 1.0).float().view(-1)

is just a way of looking for points i in protein 1 with at least two such neighbours in protein 2. All in all, this code "flags" points on the surface of protein 1 that are close to the interface of protein 2, and vice versa.

I hope that this answers your question, please feel free to re-open the issue if needed :-) Best regards, Jean

YAndrewL commented 10 months ago

Hi @jeanfeydy, thank you very much for the reply. Is it fine to use the latest version of keops and pytorch geometrics?

camel2000 commented 10 months ago

thanks very much, this problem bave been solved , Not long ago, I also checked the official website of kops, the api ".step()" is really confusing, but now it is clear 

@.***

 

------------------ 原始邮件 ------------------ 发件人: "Jean @.>; 发送时间: 2023年11月9日(星期四) 下午5:05 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [FreyrS/dMaSIF] why the interface is computed like this ? (Issue #42)

Hi @camel2000, @YAndrewL ,

Apologies for the long delay. To answer briefly: please note that the .step() function is "old" KeOps syntax that means "> 0". As a consequence, writing: xyz_dists = ((xyz1_i - xyz2_j) ** 2).sum(-1).sqrt() xyz_dists = (1.0 - xyz_dists).step()

creates a (N_1, N_2) LazyTensor of "booleans" whose value xyz_dists[i, j] indicates if point i from protein 1 and point j from protein 2 are at distance < 1 Angstrom from each other. Then, computing: p1_iface_labels = (xyz_dists.sum(1) > 1.0).float().view(-1)

is just a way of looking for points i in protein 1 with at least two such neighbours in protein 2. All in all, this code "flags" points on the surface of protein 1 that are close to the interface of protein 2, and vice versa.

I hope that this answers your question, please feel free to re-open the issue if needed :-) Best regards, Jean

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>