forked from enviPath/enviPy
[Feature] Sync Features from Client Repo (#425)
- New PackageImporter - Fix persisting Molfile on Structure creation - Add NonPersistent Prediction - Pathway View Options - Edit Node Fix Co-authored-by: Tim Lorsbach <tim@lorsba.ch> Reviewed-on: enviPath/enviPy#425
This commit is contained in:
@ -1241,8 +1241,12 @@ class CompoundStructure(
|
||||
if description is not None:
|
||||
cs.description = nh3.clean(description, tags=s.ALLOWED_HTML_TAGS).strip()
|
||||
|
||||
cs.smiles = smiles
|
||||
cs.compound = compound
|
||||
cs.smiles = smiles
|
||||
|
||||
# Check if molfile is present and valid
|
||||
if molfile is not None and molfile.strip() != "":
|
||||
cs.molfile = molfile
|
||||
|
||||
if "normalized_structure" in kwargs:
|
||||
cs.normalized_structure = kwargs["normalized_structure"]
|
||||
@ -2023,6 +2027,7 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMix
|
||||
# add links start -> pseudo
|
||||
new_link = {
|
||||
"name": link["name"],
|
||||
"plain_name": link["plain_name"],
|
||||
"id": link["id"],
|
||||
"url": link["url"],
|
||||
"image": link["image"],
|
||||
@ -2032,6 +2037,7 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMix
|
||||
"source": node_url_to_idx[link["start_node_urls"][0]],
|
||||
"target": pseudo_idx,
|
||||
"app_domain": link.get("app_domain", None),
|
||||
"to_pseudo": True,
|
||||
}
|
||||
adjusted_links.append(new_link)
|
||||
|
||||
@ -2039,6 +2045,7 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMix
|
||||
for target in link["end_node_urls"]:
|
||||
new_link = {
|
||||
"name": link["name"],
|
||||
"plain_name": link["plain_name"],
|
||||
"id": link["id"],
|
||||
"url": link["url"],
|
||||
"image": link["image"],
|
||||
@ -2049,6 +2056,7 @@ class Pathway(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMix
|
||||
"target": node_url_to_idx[target],
|
||||
"app_domain": link.get("app_domain", None),
|
||||
"multi_step": link["multi_step"],
|
||||
"from_pseudo": True,
|
||||
}
|
||||
adjusted_links.append(new_link)
|
||||
|
||||
@ -2359,17 +2367,19 @@ class Node(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
|
||||
def _url(self):
|
||||
return "{}/node/{}".format(self.pathway.url, self.uuid)
|
||||
|
||||
def get_name(self):
|
||||
def get_name(self, include_suffix=True):
|
||||
non_generic_name = True
|
||||
|
||||
if self.name == "no name":
|
||||
if self.name is None or self.name == "no name":
|
||||
non_generic_name = False
|
||||
|
||||
return (
|
||||
self.name
|
||||
if non_generic_name
|
||||
else f"{self.default_node_label.name} (taken from underlying structure)"
|
||||
)
|
||||
if non_generic_name:
|
||||
return self.name
|
||||
else:
|
||||
if include_suffix:
|
||||
return f"{self.default_node_label.name} (taken from underlying structure)"
|
||||
else:
|
||||
return self.default_node_label.name
|
||||
|
||||
def d3_json(self):
|
||||
app_domain_data = self.get_app_domain_assessment_data()
|
||||
@ -2399,6 +2409,7 @@ class Node(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
|
||||
),
|
||||
"image_type": "svg",
|
||||
"name": self.get_name(),
|
||||
"plain_name": self.get_name(include_suffix=False),
|
||||
"smiles": self.default_node_label.smiles,
|
||||
"scenarios": [{"name": s.get_name(), "url": s.url} for s in self.scenarios.all()],
|
||||
"app_domain": {
|
||||
@ -2505,6 +2516,28 @@ class Node(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
|
||||
|
||||
return res
|
||||
|
||||
def is_proposed_intermediate(self):
|
||||
collected = defaultdict(dict)
|
||||
for ai in self.additional_information.filter(
|
||||
type__in=["ProposedIntermediate", "TransformationProductImportance", "Confidence"],
|
||||
scenario__isnull=False,
|
||||
):
|
||||
collected[str(ai.scenario.uuid)]["scenarioId"] = ai.scenario.url
|
||||
collected[str(ai.scenario.uuid)]["scenarioName"] = ai.scenario.name
|
||||
|
||||
if ai.type == "ProposedIntermediate":
|
||||
collected[str(ai.scenario.uuid)]["proposed"] = True
|
||||
|
||||
if ai.type == "Confidence":
|
||||
collected[str(ai.scenario.uuid)]["Confidence"] = ai.get().level
|
||||
|
||||
if ai.type == "TransformationProductImportance":
|
||||
collected[str(ai.scenario.uuid)]["Transformation product importance"] = (
|
||||
ai.get().importance.value
|
||||
)
|
||||
|
||||
return list(collected.values())
|
||||
|
||||
|
||||
class Edge(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin):
|
||||
pathway = models.ForeignKey(
|
||||
@ -2526,6 +2559,7 @@ class Edge(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
|
||||
def d3_json(self):
|
||||
edge_json = {
|
||||
"name": self.get_name(),
|
||||
"plain_name": self.get_name(include_suffix=False),
|
||||
"id": self.url,
|
||||
"url": self.url,
|
||||
"image": self.url + "?image=svg",
|
||||
@ -2640,17 +2674,19 @@ class Edge(EnviPathModel, AliasMixin, ScenarioMixin, AdditionalInformationMixin)
|
||||
|
||||
return res
|
||||
|
||||
def get_name(self):
|
||||
def get_name(self, include_suffix=True):
|
||||
non_generic_name = True
|
||||
|
||||
if self.name == "no name":
|
||||
non_generic_name = False
|
||||
|
||||
return (
|
||||
self.name
|
||||
if non_generic_name
|
||||
else f"{self.edge_label.name} (taken from underlying reaction)"
|
||||
)
|
||||
if non_generic_name:
|
||||
return self.name
|
||||
else:
|
||||
if include_suffix:
|
||||
return f"{self.edge_label.name} (taken from underlying reaction)"
|
||||
else:
|
||||
return self.edge_label.name
|
||||
|
||||
|
||||
class EPModel(PolymorphicModel, EnviPathModel, AdditionalInformationMixin):
|
||||
|
||||
Reference in New Issue
Block a user