diff --git a/.idea/misc.xml b/.idea/misc.xml index e729098..0239966 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,5 +1,8 @@ + + - diff --git a/ckanext/rdkit_visuals/blueprint.py b/ckanext/rdkit_visuals/blueprint.py new file mode 100644 index 0000000..296d998 --- /dev/null +++ b/ckanext/rdkit_visuals/blueprint.py @@ -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/') +def display_image(package_name): + return render('') + diff --git a/ckanext/rdkit_visuals/controllers/display_image.py b/ckanext/rdkit_visuals/controllers/display_image.py index f72604a..db05758 100644 --- a/ckanext/rdkit_visuals/controllers/display_image.py +++ b/ckanext/rdkit_visuals/controllers/display_image.py @@ -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): diff --git a/ckanext/rdkit_visuals/models/molecule_rel.py b/ckanext/rdkit_visuals/models/molecule_rel.py index 50c86fb..d1d55ed 100644 --- a/ckanext/rdkit_visuals/models/molecule_rel.py +++ b/ckanext/rdkit_visuals/models/molecule_rel.py @@ -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 diff --git a/ckanext/rdkit_visuals/models/molecule_tab.py b/ckanext/rdkit_visuals/models/molecule_tab.py index 2a04e94..cd1e201 100644 --- a/ckanext/rdkit_visuals/models/molecule_tab.py +++ b/ckanext/rdkit_visuals/models/molecule_tab.py @@ -24,9 +24,10 @@ 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') @@ -34,7 +35,7 @@ class Molecules(Base): # 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. @@ -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() diff --git a/ckanext/rdkit_visuals/plugin.py b/ckanext/rdkit_visuals/plugin.py index 137f8da..fe736e1 100644 --- a/ckanext/rdkit_visuals/plugin.py +++ b/ckanext/rdkit_visuals/plugin.py @@ -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__) @@ -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,} diff --git a/ckanext/rdkit_visuals/public/BEFTXRINHQTSSE-UHFFFAOYSA-N.svg b/ckanext/rdkit_visuals/public/BEFTXRINHQTSSE-UHFFFAOYSA-N.svg deleted file mode 100644 index bc6b047..0000000 --- a/ckanext/rdkit_visuals/public/BEFTXRINHQTSSE-UHFFFAOYSA-N.svg +++ /dev/null @@ -1,121 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/ckanext/rdkit_visuals/public/static/rdkit_visuals_details.js b/ckanext/rdkit_visuals/public/static/rdkit_visuals_details.js deleted file mode 100644 index e69de29..0000000 diff --git a/ckanext/rdkit_visuals/templates/snippets/ckanext_rdkit_visuals_data_page_visuals.html b/ckanext/rdkit_visuals/templates/snippets/ckanext_rdkit_visuals_data_page_visuals.html index 4e9c05f..b6d6fab 100644 --- a/ckanext/rdkit_visuals/templates/snippets/ckanext_rdkit_visuals_data_page_visuals.html +++ b/ckanext/rdkit_visuals/templates/snippets/ckanext_rdkit_visuals_data_page_visuals.html @@ -2,7 +2,7 @@ {% set dest_url = h.url_for('rdkit_visuals.display_image', package_name = pkg.get('id'), _external=True) %} {% set molecule_formula = h.molecule_data(package_name = pkg.get('id')) %} -{% set alter_names = h.alternate_names(package_name = pkg.get('id')) %} +{% set alter_names = h.alternate_names(package_name = pkg.get('id')) %}} @@ -32,6 +32,7 @@
+

{{ _('Chemical Info') }}

molecular Image
diff --git a/ckanext/rdkit_visuals/templates/snippets/ckanext_rdkit_visuals_rdkit_visuals.html b/ckanext/rdkit_visuals/templates/snippets/ckanext_rdkit_visuals_rdkit_visuals.html index 6757aea..e76fa8a 100644 --- a/ckanext/rdkit_visuals/templates/snippets/ckanext_rdkit_visuals_rdkit_visuals.html +++ b/ckanext/rdkit_visuals/templates/snippets/ckanext_rdkit_visuals_rdkit_visuals.html @@ -33,6 +33,7 @@
+

{{ _('Chemical Info') }}

molecular Image