Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report (raise warning or error for) lone hydrogens from bad input PDB #231

Open
rwxayheee opened this issue Nov 11, 2024 · 1 comment · May be fixed by #277
Open

Report (raise warning or error for) lone hydrogens from bad input PDB #231

rwxayheee opened this issue Nov 11, 2024 · 1 comment · May be fixed by #277
Assignees

Comments

@rwxayheee
Copy link
Contributor

When input PDB has lone hydrogens (from a strained structure), atom.GetNeighbors() becomes an empty tuple and an error will occur from here:

Meeko/meeko/polymer.py

Lines 2519 to 2524 in c938ebd

if element == "H":
nei_idx = atom.GetNeighbors()[0].GetIdx()
if nei_idx in mapping_inv:
result[element]["excess"].append(mapping_inv[nei_idx])
else:
result[element]["excess"].append(-1)

To raise an error:

                if element == "H": 
                    if atom.GetNeighbors(): 
                        nei_idx = atom.GetNeighbors()[0].GetIdx()
                        if nei_idx in mapping_inv: 
                            result[element]["excess"].append(mapping_inv[nei_idx])
                        else:
                            result[element]["excess"].append(-1)
                    else: # lone hydrogen
                        raise ValueError(f"Lone hydrogen {atom.GetMonomerInfo().GetName()} found from input structure")

If we allow the lone hydrogens to pass, the bad residue with lone hydrogens will be deleted silently (no template match results printed) from the result structure.

But alternatively, lone hydrogens can be detected at an earlier point than template matching.

@rwxayheee rwxayheee self-assigned this Nov 11, 2024
@rwxayheee rwxayheee changed the title Report (raise warning or error) lone hydrogens from bad input PDB Report (raise warning or error for) lone hydrogens from bad input PDB Nov 11, 2024
@diogomart
Copy link
Contributor

Wow, this was a sneaky one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants