forked from enviPath/enviPy
[Fix] Catch Exception for Adding Structures / Show PubChem Substances (#168)
Fixes #163 Fixes #165 Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#168
This commit is contained in:
@ -310,7 +310,7 @@ class ExternalDatabase(TimeStampedModel):
|
||||
},
|
||||
{
|
||||
"database": ExternalDatabase.objects.get(name="ChEBI"),
|
||||
"placeholder": "ChEBI ID without prefix e.g. 12345",
|
||||
"placeholder": "ChEBI ID without prefix e.g. 10576",
|
||||
},
|
||||
],
|
||||
"structure": [
|
||||
@ -328,7 +328,7 @@ class ExternalDatabase(TimeStampedModel):
|
||||
},
|
||||
{
|
||||
"database": ExternalDatabase.objects.get(name="ChEBI"),
|
||||
"placeholder": "ChEBI ID without prefix e.g. 12345",
|
||||
"placeholder": "ChEBI ID without prefix e.g. 10576",
|
||||
},
|
||||
],
|
||||
"reaction": [
|
||||
@ -342,7 +342,7 @@ class ExternalDatabase(TimeStampedModel):
|
||||
},
|
||||
{
|
||||
"database": ExternalDatabase.objects.get(name="UniProt"),
|
||||
"placeholder": "Query ID for UniPro e.g. rhea:12345",
|
||||
"placeholder": "Query ID for UniProt e.g. rhea:12345",
|
||||
},
|
||||
],
|
||||
}
|
||||
@ -477,7 +477,7 @@ class ChemicalIdentifierMixin(ExternalIdentifierMixin):
|
||||
return self.add_external_identifier("CAS", cas_number)
|
||||
|
||||
def get_pubchem_identifiers(self):
|
||||
return self.get_external_identifier("PubChem Compound") or self.get_external_identifier(
|
||||
return self.get_external_identifier("PubChem Compound") | self.get_external_identifier(
|
||||
"PubChem Substance"
|
||||
)
|
||||
|
||||
@ -3043,6 +3043,7 @@ class EnviFormer(PackageBasedModel):
|
||||
@cached_property
|
||||
def model(self):
|
||||
from enviformer import load
|
||||
|
||||
ckpt = os.path.join(s.MODEL_DIR, "enviformer", str(self.uuid), f"{self.uuid}.ckpt")
|
||||
mod = load(device=s.ENVIFORMER_DEVICE, ckpt_path=ckpt)
|
||||
return mod
|
||||
@ -3062,7 +3063,9 @@ class EnviFormer(PackageBasedModel):
|
||||
start = datetime.now()
|
||||
products_list = self.model.predict_batch(canon_smiles)
|
||||
end = datetime.now()
|
||||
logger.info(f"Prediction took {(end - start).total_seconds():.2f} seconds. Got results {products_list}")
|
||||
logger.info(
|
||||
f"Prediction took {(end - start).total_seconds():.2f} seconds. Got results {products_list}"
|
||||
)
|
||||
|
||||
results = []
|
||||
for products in products_list:
|
||||
|
||||
@ -1251,7 +1251,16 @@ def package_compound_structures(request, package_uuid, compound_uuid):
|
||||
structure_smiles = request.POST.get("structure-smiles")
|
||||
structure_description = request.POST.get("structure-description")
|
||||
|
||||
cs = current_compound.add_structure(structure_smiles, structure_name, structure_description)
|
||||
try:
|
||||
cs = current_compound.add_structure(
|
||||
structure_smiles, structure_name, structure_description
|
||||
)
|
||||
except ValueError:
|
||||
return error(
|
||||
request,
|
||||
"Adding structure failed!",
|
||||
"The structure could not be added as normalized structures don't match!",
|
||||
)
|
||||
|
||||
return redirect(cs.url)
|
||||
|
||||
|
||||
@ -183,7 +183,7 @@
|
||||
</div>
|
||||
<div id="compound-external-identifier" class="panel-collapse collapse in">
|
||||
<div class="panel-body list-group-item">
|
||||
{% if compound.get_pubchem_identifiers %}
|
||||
{% if compound.get_pubchem_compound_identifiers %}
|
||||
<div class="panel panel-default panel-heading list-group-item"
|
||||
style="background-color:silver">
|
||||
<h4 class="panel-title">
|
||||
@ -193,12 +193,28 @@
|
||||
</h4>
|
||||
</div>
|
||||
<div id="compound-pubchem-identifier" class="panel-collapse collapse in">
|
||||
{% for eid in compound.get_pubchem_identifiers %}
|
||||
{% for eid in compound.get_pubchem_compound_identifiers %}
|
||||
<a class="list-group-item"
|
||||
href="{{ eid.external_url }}">CID{{ eid.identifier_value }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if compound.get_pubchem_substance_identifiers %}
|
||||
<div class="panel panel-default panel-heading list-group-item"
|
||||
style="background-color:silver">
|
||||
<h4 class="panel-title">
|
||||
<a id="compound-pubchem-identifier-link" data-toggle="collapse"
|
||||
data-parent="#compound-external-identifier"
|
||||
href="#compound-pubchem-identifier">PubChem Substance Identifier</a>
|
||||
</h4>
|
||||
</div>
|
||||
<div id="compound-pubchem-identifier" class="panel-collapse collapse in">
|
||||
{% for eid in compound.get_pubchem_substance_identifiers %}
|
||||
<a class="list-group-item"
|
||||
href="{{ eid.external_url }}">SID{{ eid.identifier_value }}</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if compound.get_chebi_identifiers %}
|
||||
<div class="panel panel-default panel-heading list-group-item"
|
||||
style="background-color:silver">
|
||||
|
||||
Reference in New Issue
Block a user