Open JonStargaryen opened 1 year ago
Brainstrorming:
from view_builder import nodes as ns
builder = Root()
structure = builder.download(url=f"https://www.ebi.ac.uk/pdbe/entry-files/download/{id.lower()}_updated.cif")\
.parse(format="mmcif")\
.structure()
def download(url: str, is_binary: bool = False, children: list[ParseNode | ...]):
return DownloadNode(url=url, is_binary=is_binary, children=children)
def parse(format: Literal["mmcif"], *children: Any):
return DownloadNode(url=url, is_binary=is_binary, children=children)
tree = download(
url="test",
children=[parse(
format="mmcif",
children=[structure(
kind="assembly",
)]
)]
)
(structure
.component(selector="protein")
.representation(type="cartoon", color="white"))
(structure
.component(selector="ligand")
.representation(type="ball-and-stick"))
# .children(lambda n: [
# n.component(selector="protein").representation(type="cartoon", color="white"),
# n.component(selector="ligand").representation(type="cartoon", color="white"),
# ])
# .children(
# ns.component(selector="protein").representation(type="cartoon", color="white"),
# ns.component(selector="ligand").representation(type="cartoon", color="white"),
# )
class None:
allowed_children_kinds = ["download", "..."]
def _validate_child(self, child: BuilderBase):
if child.kind not in self.allowed_children_kinds:
raise ValueError(...)
def many(cb: Callable[[T], list[Builder]]) -> Root:
pass
def many(*children: list[Builder]) -> Root:
pass
structure.component(selector="protein")\
.representation(type="cartoon", color="white")
structure.component(selector="ligand")\
.representation(type="ball-and-stick")
The outcome of the discussion was: No immediate changes, but revisit in the future, right?
Yes
Let's say you want to create multiple representations from a structure:
How would this be done without holding
structure
in a variable? Are we fine with this? Shouldcomponent()
becomponents()
and take all requested components are argument? Generics +parent()
/leave()
/exit()
method?