ci-lab-cz / pharmd

MD pharmacophores and virtual screening
BSD 3-Clause "New" or "Revised" License
31 stars 17 forks source link

TypeError: _get_features_atom_ids() missing 1 required positional argument: 'smarts_features' #7

Open sherifelsabbagh opened 10 months ago

sherifelsabbagh commented 10 months ago

Hi,

I managed to install the package, but when i run md2pharm using the command

md2pharm -i md_center.xtc -t pharmd.pdb -s 10 -g LIG -o pharmaco/frames.pdb

i got the message:

File "/home/tu/tu_tu/tu_zxolr16/.conda/envs/pharmd/bin/md2pharm", line 8, in sys.exit(entry_point()) File "/home/tu/tu_tu/tu_zxolr16/.conda/envs/pharmd/lib/python3.9/site-packages/pharmd/md2pharm.py", line 220, in entry_point for i, p in enumerate(get_pharmacophores(pdb_input, args.lig_id)): File "/home/tu/tu_tu/tu_zxolr16/.conda/envs/pharmd/lib/python3.9/site-packages/pharmd/md2pharm.py", line 113, in get_pharmacophores features = Pharmacophore._get_features_atom_ids(rdkit_lig, smarts) TypeError: _get_features_atom_ids() missing 1 required positional argument: 'smarts_features'

sherifelsabbagh commented 10 months ago

I can see the frames.pdb file but the models are not there

DrrDom commented 10 months ago

Did you install pharmd from the branch cgr from github? Which version of pmapper did you install?

sherifelsabbagh commented 10 months ago

hi

i follow the following instructions:

pip install git+https://github.com/meddwl/pharmd.git@cgr pip install git+https://github.com/meddwl/psearch.git@gen_pharms (The pmapper package will be installed automatically) pip install CGRtools pip install git+https://github.com/stsouko/PharmaContacts.git

sherifelsabbagh commented 10 months ago

what can I do ?

sherifelsabbagh commented 9 months ago

can i get help ?

DrrDom commented 9 months ago

You should not manually install psearch. During pharmdinstallation it will install required packages of proper versions. This will be enough:

pip install CGRtools
pip install git+https://github.com/stsouko/PharmaContacts.git
pip install git+https://github.com/meddwl/pharmd.git@cgr

I attached an environment file in which the program works - pharmd.yml.txt.

However, during tests I found an issue with parsing PDB structures using CGRtools. It does not properly recognize charges on some atoms and stops on this. Maybe in your case you will not meet such an issue. Unfortunately this is a third-party package and I know a little about it. It may happen that something was changed in recent versions. If I'll find a solution I'll let you know,

sherifelsabbagh commented 9 months ago

i tried the solution but there is also error with charges

Exception: invalid charges found on atom: 1617 [[H]C([H])([H])[S+]C([H])([H])C([H])([H])C([H])(N([H])C)C(N)=O]

sherifelsabbagh commented 9 months ago

one another thing, i tried installing the dependancies using the follwiung command

conda env create --name pharmd --file pharmd.yml

but i got the following error

sherifelsabbagh commented 9 months ago

is there any solution ?

DrrDom commented 9 months ago

I updated the repository to bring the actual version to the master branch. The issue still persists. I asked a colleague for a help. If not, you may debug the error by yourself. I suspect that the issue is in CGRtools and how PDB files are parsed and charges are assigned. The error occurs not always, some complexes are processed without errors as expected.

DrrDom commented 9 months ago

The current state is that there is an issues in parsing of protein structures in cgrtoolsmodule. Since this module is not actively maintained, there are several ways what to do next:

  1. Fix the issue in cgrtools in your own.
  2. Implement another approach to extract pharmacophores from MD trajectories. I would suggest to look at ProLIF (https://github.com/chemosim-lab/ProLIF). This module should be able to do that and it is actively developed and maintained. If you will do that, please make pull request.
  3. You may use the current version of pharmd in those cases which do not cause errors. I had issues in only half of my test cases. So, it may be still useful.

I would prefer to implement ProLIF as a backbone of pharmd, but I do not have resources to do that quickly. So, any help will be appreciated.

sherifelsabbagh commented 8 months ago

I don't have experience in handling such errors and I have no idea how to extract features from MD using ProliF. I think I will wait till there is a solution

ricardojdgferreira commented 2 months ago

There is a way to override the erros with charges, you can comment these lines inside md2pharm.py:

    #for n, c in cmol._charges.items():
        #if n in sprt and c and n not in valid:
            #valid.update([n])
            #raise Exception(f'invalid charges found on atom: {n} [{cmol.augmented_substructure([n], deep=5)}]')

Of course, this should be used at your own risk as some pharmacophoric points may be wrongly assigned (or should not be present at all). However, while testing I found out that 98% of the extracted pharmacophores are still correct. Therefore I kept the original version (works flawlessly with most of the systems) but when I encounter such errors (not well equilibrated systems, membrane proteins, modified forcefields, etc) I use the modified one and curate the pharmacophores by hand.

Hope it helps!

sherifelsabbagh commented 2 months ago

There is a way to override the erros with charges, you can comment these lines inside md2pharm.py:

    #for n, c in cmol._charges.items():
        #if n in sprt and c and n not in valid:
            #valid.update([n])
            #raise Exception(f'invalid charges found on atom: {n} [{cmol.augmented_substructure([n], deep=5)}]')

Of course, this should be used at your own risk as some pharmacophoric points may be wrongly assigned (or should not be present at all). However, while testing I found out that 98% of the extracted pharmacophores are still correct. Therefore I kept the original version (works flawlessly with most of the systems) but when I encounter such errors (not well equilibrated systems, membrane proteins, modified forcefields, etc) I use the modified one and curate the pharmacophores by hand.

Hope it helps!

I tried the solution but I found a new error

TypeError: __PharmacophoreLoadedMol._get_features_atom_ids() missing 1 required positional argument: 'smarts_features'

since you used it successfully, can you provide me with the yml file you used for creating the environment or tell me how you installed it.. because this message appears if there is sth wrong with the pmapper tool

dr-aspirinas commented 2 months ago

@sherifelsabbagh probably you also do not have the "smarts_features.txt" inside the installation directory of pharmd. Please check it.

sherifelsabbagh commented 2 months ago

Untitled 2

sherifelsabbagh commented 2 months ago

I think there is sth wrong with pmapper tool because when I try generate pharmacophore from an example molecule

I found this message "__PharmacophoreLoadedMol._get_features_atom_ids() missing 1 required positional argument: 'self'"

DrrDom commented 2 months ago

There was no issue with pmapper itself - https://github.com/DrrDom/pmapper/issues/10.

If this error occurs in the modified code, you may fix it and submit a pull request and I would be glad to review and accept it. I would ask just that these changes should be consistent and do not break something else. So, some testing would be also appreciated.

I see that the project attracts some attention, however, we cannot continue its support by ourselves. If someone will be ready to contribute, I'll be glad to help with that.

sherifelsabbagh commented 2 months ago

if you check the md2pharm.py file .. you will find that the code is as follows

    cmol.thiele()  # aromatize
    cgr_lig = cmol.substructure(lig)
    cgr_prt = cmol.substructure(prt)
    rdkit_lig = to_rdkit_molecule(cgr_lig)
    features = Pharmacophore._get_features_atom_ids(rdkit_lig, smarts)

it didn't work..

when I modified the code like this

    cmol.thiele()  # aromatize
    cgr_lig = cmol.substructure(lig)
    cgr_prt = cmol.substructure(prt)
    rdkit_lig = to_rdkit_molecule(cgr_lig)
    p = Pharmacophore()
    features = p._get_features_atom_ids(rdkit_lig, smarts)

it finally works

sherifelsabbagh commented 2 months ago

I am not a developer but I was hoping that you can continue to develop it..it is intersting