seoklab / nurikit

*The* fundamental software platform for chem- and bio-informatics
https://nurikit.readthedocs.io
Apache License 2.0
5 stars 0 forks source link

TypeError: to_mol2(): incompatible function arguments. #353

Closed hakjean-kim closed 2 hours ago

hakjean-kim commented 2 hours ago
import nuri
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("-p", "--path", type=str, required=True, help="file path")
args = parser.parse_args()

with open(args.path, 'r') as g:
    for line in g:
        mol = nuri.readstring("smi",line,False)
        print(str(mol))
        print(type(mol))
        a = nuri.to_smiles(mol)
        print(a)

It returns error messages:

<nuri.fmt.MoleculeReader object at 0x14b6a72ab870>
<class 'nuri.fmt.MoleculeReader'>
Traceback (most recent call last):
  File "smitomol2_nuri.py", line 13, in <module>
    a = nuri.to_mol2(mol)
TypeError: to_mol2(): incompatible function arguments. The following argument types are supported:
    1. (mol: nuri.core._core.Molecule, conf: Optional[int] = None) -> str

Invoked with: <nuri.fmt.MoleculeReader object at 0x14b6a72ab870>

and it returns error at to_smiles also.

<nuri.fmt.MoleculeReader object at 0x149d48969770>
<class 'nuri.fmt.MoleculeReader'>
Traceback (most recent call last):
  File "smitomol2_nuri.py", line 13, in <module>
    a = nuri.to_smiles(mol)
TypeError: to_smiles(): incompatible function arguments. The following argument types are supported:
    1. (mol: nuri.core._core.Molecule) -> str

Invoked with: <nuri.fmt.MoleculeReader object at 0x149d48969770>

It happens at nurikit version 0.1.0a5.

Platform information:

jnooree commented 2 hours ago

readers return an iterable of molecules, not a molecule object.

 import nuri
 import argparse

 parser = argparse.ArgumentParser()
 parser.add_argument("-p", "--path", type=str, required=True, help="file path")
 args = parser.parse_args()

 with open(args.path, 'r') as g:
     for line in g:
-        mol = nuri.readstring("smi",line,False)
+        mol = next(nuri.readstring("smi",line,False))
         print(str(mol))
         print(type(mol))
         a = nuri.to_smiles(mol)
         print(a)