cgexplore.scram.TopologyIterator

class cgexplore.scram.TopologyIterator(building_block_counts, graph_type=None, graph_set='rxx', allowed_num_components=1, max_samples=None, graph_directory=None, verbose=True)[source]

Bases: object

Iterate over topology graphs.

This is the latest version, but without good symmetry and graph checks, this can over produce structures.

This class now contains agx.TopologyIterator.

Important

Warning: Currently, the order of building_block_counts has to have the building block with the most FGs first! This ordering is defined by the order used when defining the graphs. If you are defining your own graph library (i.e., setting graph_directory or using a new graph_type), then the order is defined by the order in building_block_counts when generating the json.

Important

To reproduce the no_doubles dataset, you must filter the topology codes after generation using the cgexplore.scram.TopologyCode methods (this is now the recommended approach).

Parameters:
  • building_block_counts (dict[BuildingBlock, int]) – Dictionary of stk.BuildingBlock and their count in the proposed structures. Always put the building blocks with more functional groups first (this is a current bug). Additionally, only mixtures of three distinct building block functional group counts is implemented, and in the case of three components, all building blocks bind to the building block with the most functional groups.

  • graph_type (str | None) – Name of the graph. Current name convention is long, but complete, capturing the count of each building block with certain functional group count included. Following this name convention will allow you to use saved graphs, if not, you can make your own. Although it can be time consuming.

  • graph_set (str) – Set of graphs to use based on different algorithms or papers. Can be custom, as above. Note that the code to generation nx graphs is no longer present in cgexplore because the networkx algorithms were slow.

  • scale_multiplier – Scale multiplier to use in construction.

  • allowed_num_components (int) – Allowed number of disconnected graph components. Usually 1 to generate complete graphs only.

  • max_samples (int | None) – When constructing graphs, there is some randomness in their order, although that order should be consistent, and only up-to max_samples are sampled. For very large numbers of building blocks there is not guarantee all possible graphs will be explored.

  • graph_directory (Path | None) – Directory to check for and save graph jsons.

  • verbose (bool) – Whether to log outcomes.

Methods

count_graphs

Count completely connected graphs in iteration.

get_configurations

Get potential node configurations.

get_edges_from_topology_code

Get stk Edges from topology code.

get_num_building_blocks

Get number of building blocks.

get_vertex_prototypes

Get vertex prototypes.

graph_exists

Checks if the graphs have been defined.

is_type_possible

Return True if the graph is chemically possible.

yield_configured_codes

Get potential node configurations.

yield_graphs

Get constructed molecules from iteration.

Attributes

count_graphs()[source]

Count completely connected graphs in iteration.

Return type:

int

get_configurations()[source]

Get potential node configurations.

Return type:

Sequence[Configuration]

get_edges_from_topology_code(topology_code, unaligning=False)[source]

Get stk Edges from topology code.

Parameters:
Return type:

list[Edge]

get_num_building_blocks()[source]

Get number of building blocks.

Return type:

int

get_vertex_prototypes(unaligning)[source]

Get vertex prototypes.

Parameters:

unaligning (bool)

Return type:

Sequence[Vertex]

graph_exists()[source]

Checks if the graphs have been defined.

Return type:

bool

is_type_possible()[source]

Return True if the graph is chemically possible.

Return type:

bool

yield_configured_codes()[source]

Get potential node configurations.

Return type:

Iterator[ConfiguredCode]

yield_graphs()[source]

Get constructed molecules from iteration.

Yields only graphs with the allowed number of components.

Return type:

Generator[TopologyCode]

allowed_num_components: int = 1
building_block_counts: dict[BuildingBlock, int]
building_blocks: dict[BuildingBlock, Sequence[int]]
graph_directory: Path | None = None
graph_set: str = 'rxx'
graph_type: str | None = None
iterator: TopologyIterator
max_samples: int | None = None
node_counts: dict[NodeType, int]
node_to_bb_map: dict[NodeType, BuildingBlock]
scale_multiplier = 5
unaligned_vertex_prototypes: list[Vertex]
verbose: bool = True
vertex_prototypes: list[Vertex]
vertex_types_by_fg: dict[int, Sequence[int]]