Skip to content

Commit

Permalink
Added models for iupac_name and alternate names
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavin2897 committed Oct 23, 2024
1 parent 4738e5d commit 967d11a
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 147 deletions.
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 50 additions & 16 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions ckanext/rdkit_visuals/blueprint.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# encoding: utf-8

from flask import Blueprint, redirect, url_for

from ckan.plugins.toolkit import c, render, request
import ckan.lib.helpers as h
from ckanext.sparql_interface.utils import sparql_query_SPARQLWrapper as utils_sparqlQuery
from flask import Response


rdkit_visuals_blueprint = Blueprint(u'rdkit_visuals',__name__)

@rdkit_visuals_blueprint.add_url_rule(u'/localhost:5000/dataset/<package_name>')
def display_image(package_name):
return render('')

1 change: 0 additions & 1 deletion ckanext/rdkit_visuals/controllers/display_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from ckanext.related_resources.models.related_resources import RelatedResources as related_resources
from ckanext.rdkit_visuals.models.molecule_rel import MolecularRelationData as molecule_rel


class RdkitVisualsController():

def display_image(package_name):
Expand Down
7 changes: 5 additions & 2 deletions ckanext/rdkit_visuals/models/molecule_rel.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,12 @@ def get_molecule_data_by_package_id(cls, package_id):
cls.molecules_id
).filter(cls.package_id == package_id).subquery()

molecule_data = Session.query(Molecules.inchi).filter(Molecules.id.in_(molecules_sub_query)).all()
inchi = Session.query(Molecules.inchi).filter(Molecules.id.in_(molecules_sub_query)).all()
iupac_name = Session.query(Molecules.iupac_name).filter(Molecules.id.in_(molecules_sub_query)).all()

return inchi,iupac_name


return molecule_data


# relationship to build between molecules and packages
Expand Down
11 changes: 7 additions & 4 deletions ckanext/rdkit_visuals/models/molecule_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,18 @@ class Molecules(Base):
inchi = Column(_types.String)
smiles = Column(_types.String)
inchi_key = Column(_types.String)

exact_mass = Column(Float)
mol_formula = Column(_types.String)
iupac_name = Column(_types.String)
alternate_names = Column(_types.String)

# Relationship with the Package model
# package = relationship('Package')

# Additional methods can be added here as needed

@classmethod
def create(cls, inchi, smiles, inchi_key, exact_mass, mol_formula):
def create(cls, inchi, smiles, inchi_key, exact_mass, mol_formula,iupac_name, alternate_names):
"""
Create a new Molecule entry and store it in the database.
Expand All @@ -48,11 +49,13 @@ def create(cls, inchi, smiles, inchi_key, exact_mass, mol_formula):
:return: The created Molecule instance
"""
new_molecule = cls(
inchi=inchi,
inchi=inchi.strip(),
smiles=smiles,
inchi_key=inchi_key,
exact_mass=exact_mass,
mol_formula=mol_formula
mol_formula=mol_formula,
iupac_name = iupac_name,
alternate_names = alternate_names
)
Session.add(new_molecule)
Session.commit()
Expand Down
7 changes: 5 additions & 2 deletions ckanext/rdkit_visuals/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def update_config(self, config):
toolkit.add_resource('public/statics', 'ckanext-rdkit-visuals')


# IBlueprint
def get_blueprint(self):

blueprint = Blueprint(self.name, self.__module__)
Expand All @@ -33,9 +34,11 @@ def get_blueprint(self):
)
return blueprint


# ITemplate Helpers
def get_helpers(self):

return {'rdkit_visuals': RdkitVisualsController.display_image,
'molecule_data':RdkitVisualsController.molecule_data,
'alternate_names': RdkitVisualsController.alternames,
'related_values': RdkitVisualsController.related_resources,}
'alternate_names': RdkitVisualsController.alternames,
'related_values': RdkitVisualsController.related_resources,}
Loading

0 comments on commit 967d11a

Please sign in to comment.