Skip to content

Commit

Permalink
Add molecule_name in tabe
Browse files Browse the repository at this point in the history
  • Loading branch information
bhavin2897 committed Oct 25, 2024
1 parent 4ca51a8 commit c32e8cd
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
17 changes: 13 additions & 4 deletions .idea/workspace.xml

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

3 changes: 2 additions & 1 deletion ckanext/rdkit_visuals/models/molecule_rel.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ def get_molecule_data_by_package_id(cls, package_id):

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()
molecule_name = Session.query(Molecules.molecule_name).filter(Molecules.id.in_(molecules_sub_query)).all()

return inchi,iupac_name
return inchi,iupac_name, molecule_name



Expand Down
6 changes: 4 additions & 2 deletions ckanext/rdkit_visuals/models/molecule_tab.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ class Molecules(Base):
mol_formula = Column(_types.String)
iupac_name = Column(_types.String)
alternate_names = Column(_types.String)
molecule_name = 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,iupac_name, alternate_names):
def create(cls, inchi, smiles, inchi_key, exact_mass, mol_formula,iupac_name, alternate_names, molecule_name):
"""
Create a new Molecule entry and store it in the database.
Expand All @@ -55,7 +56,8 @@ def create(cls, inchi, smiles, inchi_key, exact_mass, mol_formula,iupac_name, al
exact_mass=exact_mass,
mol_formula=mol_formula,
iupac_name = iupac_name,
alternate_names = alternate_names
alternate_names = alternate_names,
molecule_name = molecule_name
)
Session.add(new_molecule)
Session.commit()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

{% set data_dict = { 'inchi': pkg.get('inchi'), 'smiles': pkg.get('smiles'), 'inchi_key': pkg.get('inchi_key'), 'exact_mass' : pkg.get('exactmass'),'molecular_formula': pkg.get('mol_formula') } %}
{% set mol_formula,exact_mass,inchi,iupac_name = h.get_molecule_data(package_id = pkg.get('id')) %}
{% set mol_formula,exact_mass,inchi,iupac_name,molecule_name = h.get_molecule_data(package_id = pkg.get('id')) %}
{% 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')) %}
Expand Down Expand Up @@ -71,6 +71,13 @@ <h3>{{ _('Chemical Info') }}</h3>
</tr>
{% endif %}

{% if molecule_name %}
<tr>
<th width="25%" scope="row" class="dataset-label">{{ _("Molecule Name") }}</th>
<td width="50%" class="dataset-details">{{ molecule_name }}</td>
</tr>
{% endif %}

{% if data_dict.smiles %}
<tr>
<th scope="row" class="dataset-label">{{ _("SMILES") }}</th>
Expand Down

0 comments on commit c32e8cd

Please sign in to comment.