Global-Chem / global-chem

A Knowledge Graph of Common Chemical Names to their Molecular Definition
https://globalchemistry.org/
Mozilla Public License 2.0
153 stars 20 forks source link

Google Colab Demo not working, missing `global_chem.food.fruits.mango.mango_phytocompounds` #292

Closed JacksonBurns closed 4 months ago

JacksonBurns commented 9 months ago

The google colab demo linked in the README does not run, with the first cell raising this error:

Collecting global-chem
  Downloading global_chem-1.8.5.tar.gz (134 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 134.5/134.5 kB 2.9 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: global-chem
  Building wheel for global-chem (setup.py) ... done
  Created wheel for global-chem: filename=global_chem-1.8.5-py3-none-any.whl size=177335 sha256=061202ae1080d25fbfa447d0b8379a009ddb9049725043ccbe7ba268e185ef57
  Stored in directory: /root/.cache/pip/wheels/79/e3/d0/f32b3c2462c08afb73387b76f8b082bfddfb5c64c4d9550ff1
Successfully built global-chem
Installing collected packages: global-chem
Successfully installed global-chem-1.8.5

---------------------------------------------------------------------------

ModuleNotFoundError                       Traceback (most recent call last)

[<ipython-input-1-44f29562853a>](https://localhost:8080/#) in <cell line: 7>()
      5 # Imports
      6 
----> 7 from global_chem import GlobalChem
      8 gc = GlobalChem()

[/usr/local/lib/python3.10/dist-packages/global_chem/__init__.py](https://localhost:8080/#) in <module>
    106 # Mango
    107 
--> 108 from global_chem.food.fruits.mango.mango_phytocompounds import MangoPhytoCompounds
    109 from global_chem.food.fruits.mango.mango_fatty_acids import MangoFattyAcids
    110 from global_chem.food.fruits.mango.mango_flavonoids import MangoFlavonoids

ModuleNotFoundError: No module named 'global_chem.food.fruits.mango.mango_phytocompounds'

---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.

To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
Sulstice commented 9 months ago

Hi @JacksonBurns, thanks for bringing this to my attention. It looks like either the node name or the node path is incorrect:

from global_chem.food.fruits.mango.mango_phytocompounds import MangoPhytoCompounds

@Nickspizza001 This is the mango node and we need to keep testing that. I think I know what the error is.

Nickspizza001 commented 9 months ago

Hi @JacksonBurns, Thank you for this. The init function is missing in the constituents_of_mango.py file. Also, a similar error will be noticed when you try to import the mango_amino_acids. def __init__(self): self.name = 'mango_fatty_acids'

This is currently being fixed.

Sulstice commented 9 months ago

@Nickspizza001 and @JacksonBurns I hot fixed it and now updated in version 1.8.5.1. Please reinstall.

The issue was the file path node wasn't set correctly or the file was missing:

class MangoPhytocompounds(object):

  def __init__(self):

    self.name = 'mango_phytocompounds'

As well as the node name for amino acids was off:


class MangoAminoAcids(object):

    def __init__(self):

        self.name = 'mango_amino_acids'

@Nickspizza001 I seem to be missing some phytocompounds:


          'alpha phellandrene': '',
          'alpha humulene': '',
          'gamma terpinene': '',
          'alpha pinene': '',
          'trans caryophyllene': '',
          'sabinene': '',
          'carene': '',
          'cis-caryophyllene': '',
          'αlpha humulene': '',
          'germacrene d': '',
          'aromadendrene': '',
          'beta ubebene': '',
          'alpha cubebene': '',
          'alpha bourbonene': '',
          'beta elemene': '',

@thedevp and @ANUGAMAGE can you help him get the SMILES using STOUT?

JacksonBurns commented 9 months ago

@Sulstice thanks for the quick response! The original problem is resolved, but now this happens in cell 7:

# Fetch All the Data

gc = GlobalChem()
print(len(gc.get_all_smiles()))
---------------------------------------------------------------------------

AttributeError                            Traceback (most recent call last)

[<ipython-input-7-be708f3a449d>](https://localhost:8080/#) in <cell line: 4>()
      2 
      3 gc = GlobalChem()
----> 4 print(len(gc.get_all_smiles()))
      5 print(len(gc.get_all_smarts()))
      6 print(len(gc.get_all_names()))

[/usr/local/lib/python3.10/dist-packages/global_chem/global_chem.py](https://localhost:8080/#) in get_all_smiles(self)
   1075             if node_key != 'global_chem' and node_key != 'common_regex_patterns':
   1076 
-> 1077                 smiles.append(list(node_value.get_smiles().values()))
   1078 
   1079         smiles = sum(smiles, [])

AttributeError: type object 'MangoPhytocompounds' has no attribute 'get_smiles'
Sulstice commented 5 months ago

@JacksonBurns I had to restore a previous version. I'm getting this back up and running.

westrangeloops commented 4 months ago

Hi! I got the same error, thakns for any help:

smiles_list = list(gc.get_node_smiles('emerging_perfluoroalkyls').values())
sunburster = cheminformatics.sunburst_chemical_list(
    smiles_list
)

sunburster.sunburst()

The error code:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[23], line 7
      4 # smiles_list = pd.read_csv('Tables/Perov_table_raw.csv')['Spacer_smiles'].to_list()
      6 smiles_list = list(gc.get_node_smiles('emerging_perfluoroalkyls').values())
----> 7 sunburster = cheminformatics.sunburst_chemical_list(
      8     smiles_list
      9 )
     10 sunburster.sunburst()

File ~/.local/lib/python3.8/site-packages/global_chem_extensions/cheminformatics/cheminformatics.py:46, in ChemInformatics.sunburst_chemical_list(smiles_list, save_file)
     30 '''
     31 
     32 
   (...)
     41 
     42 '''
     44 from global_chem_extensions.cheminformatics.applications.sunburster import Sunburster
---> 46 sunburster_object = Sunburster(smiles_list, save_file)
     48 return sunburster_object

File ~/.local/lib/python3.8/site-packages/global_chem_extensions/cheminformatics/applications/sunburster.py:63, in Sunburster.__init__(self, smiles_list, save_file, verbose)
     59 self.second_values = []
     61 # Controller
---> 63 self._mine_global_chem()
     64 self._prepare_object()
     65 self.determine_first_layer()

File ~/.local/lib/python3.8/site-packages/global_chem_extensions/cheminformatics/applications/sunburster.py:87, in Sunburster._mine_global_chem(self)
     84 if node_name == 'common_regex_patterns': # Skip this
     85     continue
---> 87 node_smarts = node.get_smarts()
     89 self.patterns.append(node_smarts)

AttributeError: 'MangoPhytocompounds' object has no attribute 'get_smarts'
Sulstice commented 4 months ago

Hi it should be fixed now! In version 1.9.4