wengong-jin / hgraph2graph

Hierarchical Generation of Molecular Graphs using Structural Motifs
MIT License
378 stars 109 forks source link

AssertionError #43

Open orubaba opened 2 years ago

orubaba commented 2 years ago

Hi gurus, pls, I need your help. I am trying to run the get-vocab.py on my small dataset around 100. but keep getting this error as shown below: Is there a way to go around this. the reference for the error is to the mol_graph.py line82: "assert n - m <= 1 #must be connected" image

max-unfried commented 2 years ago

I'm having the exact same issue - any idea why this is?

NiharikaVadlamudi commented 2 years ago

@wengong-jin Can you please suggest a solution for this ? Thanks

max-unfried commented 2 years ago

Anything that you could suggest - still hung up on it?

AdamIzdebski commented 2 years ago

+1

marshallcase commented 2 years ago

Can you post a picture of your molecule / encoded graph? In my experience you get n-m > 1 when there's atoms that aren't connected to the rest of the molecule. This could be because the cluster generation process in find_clusters() wasn't built for a particular combination of rings / bonds

JonathanBroadbent commented 1 year ago

Hi, reopening this as I am currently experiencing the same problem. It says the issue occurs in tree_decomp line 82

Has anybody found a fix yet?

orubaba commented 1 year ago

Hi,

check out this code and correct your get_vocal.py. let's see if it works. this is what i adjusted.

[image: image.png]

On Wed, Sep 27, 2023 at 9:32 PM JonathanBroadbent @.***> wrote:

Hi, reopening this as I am currently experiencing the same problem. It says the issue occurs in tree_decomp line 82

— Reply to this email directly, view it on GitHub https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1737964626, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVBVXE34PIUE4MT7NVBFVRLX4R5OTANCNFSM53ZE4TNQ . You are receiving this because you authored the thread.Message ID: @.***>

-- Regards, Adeshina

JonathanBroadbent commented 1 year ago

HI Adeshina,

Thanks for the response, the image you attached only shows alt text. Can you resend it to me?

Jonathan

From: Adeshina John Orubuloye @.> Date: Wednesday, September 27, 2023 at 9:56 PM To: wengong-jin/hgraph2graph @.> Cc: Broadbent, Jonathan /CA @.>, Comment @.> Subject: Re: [wengong-jin/hgraph2graph] AssertionError (Issue #43) Hi,

check out this code and correct your get_vocal.py. let's see if it works. this is what i adjusted.

[image: image.png]

On Wed, Sep 27, 2023 at 9:32 PM JonathanBroadbent @.***> wrote:

Hi, reopening this as I am currently experiencing the same problem. It says the issue occurs in tree_decomp line 82

— Reply to this email directly, view it on GitHub https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1737964626<https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1737964626>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVBVXE34PIUE4MT7NVBFVRLX4R5OTANCNFSM53ZE4TNQ<https://github.com/notifications/unsubscribe-auth/AVBVXE34PIUE4MT7NVBFVRLX4R5OTANCNFSM53ZE4TNQ> . You are receiving this because you authored the thread.Message ID: @.***>

-- Regards, Adeshina

— Reply to this email directly, view it on GitHubhttps://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1738330411, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BAGO4OZUGGJCB4MEE3VS6N3X4TKMXANCNFSM53ZE4TNQ. You are receiving this because you commented.Message ID: @.***>

orubaba commented 1 year ago

Hi,

sorry for that. hope this works this time.

On Thu, Sep 28, 2023 at 7:12 PM JonathanBroadbent @.***> wrote:

HI Adeshina,

Thanks for the response, the image you attached only shows alt text. Can you resend it to me?

Jonathan

From: Adeshina John Orubuloye @.> Date: Wednesday, September 27, 2023 at 9:56 PM To: wengong-jin/hgraph2graph @.> Cc: Broadbent, Jonathan /CA @.>, Comment @.> Subject: Re: [wengong-jin/hgraph2graph] AssertionError (Issue #43) Hi,

check out this code and correct your get_vocal.py. let's see if it works. this is what i adjusted.

[image: image.png]

On Wed, Sep 27, 2023 at 9:32 PM JonathanBroadbent @.***> wrote:

Hi, reopening this as I am currently experiencing the same problem. It says the issue occurs in tree_decomp line 82

— Reply to this email directly, view it on GitHub < https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1737964626 < https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1737964626>>,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AVBVXE34PIUE4MT7NVBFVRLX4R5OTANCNFSM53ZE4TNQ < https://github.com/notifications/unsubscribe-auth/AVBVXE34PIUE4MT7NVBFVRLX4R5OTANCNFSM53ZE4TNQ>>

. You are receiving this because you authored the thread.Message ID: @.***>

-- Regards, Adeshina

— Reply to this email directly, view it on GitHub< https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1738330411>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/BAGO4OZUGGJCB4MEE3VS6N3X4TKMXANCNFSM53ZE4TNQ>.

You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1739718579, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVBVXE7VJCH4TH4QNAHXB6DX4WVZXANCNFSM53ZE4TNQ . You are receiving this because you authored the thread.Message ID: @.***>

-- Regards, Adeshina

JonathanBroadbent commented 1 year ago

Hi Adeshina,

Sorry, I still do not see any image. Perhaps you could upload it by replying directly on github? Or email me directly? @.***)

Jonathan

From: Adeshina John Orubuloye @.> Date: Friday, September 29, 2023 at 12:37 AM To: wengong-jin/hgraph2graph @.> Cc: Broadbent, Jonathan /CA @.>, Comment @.> Subject: Re: [wengong-jin/hgraph2graph] AssertionError (Issue #43) Hi,

sorry for that. hope this works this time.

On Thu, Sep 28, 2023 at 7:12 PM JonathanBroadbent @.***> wrote:

HI Adeshina,

Thanks for the response, the image you attached only shows alt text. Can you resend it to me?

Jonathan

From: Adeshina John Orubuloye @.> Date: Wednesday, September 27, 2023 at 9:56 PM To: wengong-jin/hgraph2graph @.> Cc: Broadbent, Jonathan /CA @.>, Comment @.> Subject: Re: [wengong-jin/hgraph2graph] AssertionError (Issue #43) Hi,

check out this code and correct your get_vocal.py. let's see if it works. this is what i adjusted.

[image: image.png]

On Wed, Sep 27, 2023 at 9:32 PM JonathanBroadbent @.***> wrote:

Hi, reopening this as I am currently experiencing the same problem. It says the issue occurs in tree_decomp line 82

— Reply to this email directly, view it on GitHub < https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1737964626https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1737964626 < https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1737964626https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1737964626>>,

or unsubscribe < https://github.com/notifications/unsubscribe-auth/AVBVXE34PIUE4MT7NVBFVRLX4R5OTANCNFSM53ZE4TNQhttps://github.com/notifications/unsubscribe-auth/AVBVXE34PIUE4MT7NVBFVRLX4R5OTANCNFSM53ZE4TNQ < https://github.com/notifications/unsubscribe-auth/AVBVXE34PIUE4MT7NVBFVRLX4R5OTANCNFSM53ZE4TNQhttps://github.com/notifications/unsubscribe-auth/AVBVXE34PIUE4MT7NVBFVRLX4R5OTANCNFSM53ZE4TNQ>>

. You are receiving this because you authored the thread.Message ID: @.***>

-- Regards, Adeshina

— Reply to this email directly, view it on GitHub< https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1738330411https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1738330411>, or unsubscribe< https://github.com/notifications/unsubscribe-auth/BAGO4OZUGGJCB4MEE3VS6N3X4TKMXANCNFSM53ZE4TNQhttps://github.com/notifications/unsubscribe-auth/BAGO4OZUGGJCB4MEE3VS6N3X4TKMXANCNFSM53ZE4TNQ>.

You are receiving this because you commented.Message ID: @.***>

— Reply to this email directly, view it on GitHub https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1739718579<https://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1739718579>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AVBVXE7VJCH4TH4QNAHXB6DX4WVZXANCNFSM53ZE4TNQ<https://github.com/notifications/unsubscribe-auth/AVBVXE7VJCH4TH4QNAHXB6DX4WVZXANCNFSM53ZE4TNQ> . You are receiving this because you authored the thread.Message ID: @.***>

-- Regards, Adeshina

— Reply to this email directly, view it on GitHubhttps://github.com/wengong-jin/hgraph2graph/issues/43#issuecomment-1740305221, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BAGO4O462PX5P5JZVCVEDATX4ZGBTANCNFSM53ZE4TNQ. You are receiving this because you commented.Message ID: @.***>

orubaba commented 1 year ago

import sys import argparse from hgraph import * from rdkit import Chem from multiprocessing.dummy import Pool

def process(data): vocab = set() for line in data: s = line.strip("\r\n ") hmol = MolGraph(s) for node,attr in hmol.mol_tree.nodes(data=True): smiles = attr['smiles'] vocab.add( attr['label'] ) for i,s in attr['inter_label']: vocab.add( (smiles, s) ) return vocab

if name == "main":

parser = argparse.ArgumentParser()
parser.add_argument('--ncpu', type=int, default=1)
args = parser.parse_args()

data = [mol for line in sys.stdin for mol in line.split()[:2]]
data = list(set(data))

batch_size = len(data) // args.ncpu + 1
batches = [data[i : i + batch_size] for i in range(0, len(data), batch_size)]

with Pool(args.ncpu) as pool:
    vocab_list = pool.map(process, batches, chunksize=1)
    vocab = [(x,y) for vocab in vocab_list for x,y in vocab]
orubaba commented 1 year ago

Interestingly, I removed all contents from line 34 downwards (I don't know why that should solve the problem for me) and it ran well. sorry you couldn't get the img. I was responding within my mail. let's see if it works. btw, chatgpt was really helpful with the error clearings.