Models
BindingSite
dataclass
A specific binding site on a specific component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_id
|
ID
|
The ID of the component this site belongs to. |
required |
site_id
|
ID
|
The site identifier within the component. |
required |
Examples:
Creating a bond by passing binding sites explicitly:
>>> from nasap_net import Bond
>>> metal_bs = BindingSite('M0', 0) # site 0 on component M0
>>> ligand_bs = BindingSite('L0', 0) # site 0 on component L0
>>> Bond.from_sites(metal_bs, ligand_bs)
Source code in src/nasap_net/models/binding_site.py
AuxEdge
dataclass
An auxiliary edge between two binding sites on the same component.
Used to encode geometric constraints between sites, such as cis/trans relationships in octahedral metal complexes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
site_id1
|
ID
|
The first site ID. |
required |
site_id2
|
ID
|
The second site ID. Must be different from |
required |
kind
|
str | None
|
The kind of geometric relationship (e.g., |
None
|
Examples:
>>> from nasap_net import AuxEdge
>>> AuxEdge(0, 1) # geometric adjacency between sites 0 and 1
>>> AuxEdge(0, 1, kind='cis') # cis relationship between sites 0 and 1
Encoding square-planar geometry in a metal center (sites 0–3 form a ring):
>>> from nasap_net import Component
>>> M = Component(
... kind='M', sites=[0, 1, 2, 3],
... aux_edges=[AuxEdge(0, 1), AuxEdge(1, 2),
... AuxEdge(2, 3), AuxEdge(3, 0)],
... )
Source code in src/nasap_net/models/aux_edge.py
get_binding_sites(comp_id)
Return the binding sites of this auxiliary edge.
Source code in src/nasap_net/models/aux_edge.py
to_tuple()
Return a tuple representation of the auxiliary edge.
Source code in src/nasap_net/models/aux_edge.py
Component
dataclass
A component in a self-assembly system.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
The kind identifier for this component (e.g., |
required |
sites
|
Iterable[ID]
|
The site IDs available for bonding on this component. |
required |
aux_edges
|
Iterable[AuxEdge] | None
|
Auxiliary edges representing geometric constraints between sites (e.g., cis/trans relationships). Default is None. |
None
|
Examples:
>>> from nasap_net import Component
>>> M = Component(kind='M', sites=[0, 1]) # metal with 2 binding sites
>>> L = Component(kind='L', sites=[0, 1]) # bridging ligand with 2 binding sites
>>> X = Component(kind='X', sites=[0]) # monodentate leaving ligand
With auxiliary edges encoding geometric constraints:
>>> from nasap_net import AuxEdge
>>> M = Component(
... kind='M', sites=[0, 1, 2, 3],
... aux_edges=[AuxEdge(0, 1), AuxEdge(1, 2),
... AuxEdge(2, 3), AuxEdge(3, 0)],
... )
Source code in src/nasap_net/models/component.py
get_binding_sites(comp_id)
Return the binding sites of this component.
Bond
dataclass
A bond between two binding sites on two components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comp_id1
|
ID
|
The ID of the first component. |
required |
site1
|
ID
|
The site ID on the first component. |
required |
comp_id2
|
ID
|
The ID of the second component. |
required |
site2
|
ID
|
The site ID on the second component. |
required |
Examples:
Source code in src/nasap_net/models/bond.py
component_ids
property
Return the component IDs involved in the bond.
from_sites(site1, site2)
classmethod
Create a Bond from two BindingSite instances.
Source code in src/nasap_net/models/bond.py
to_tuple()
Return the bond as a tuple of component and site IDs.
Assembly
dataclass
An assembly of components connected by bonds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
Mapping[C, Component[S]]
|
A mapping from component IDs to their corresponding components. |
required |
bonds
|
Iterable[Bond[C, S]]
|
An iterable of bonds connecting the components. |
required |
Raises:
| Type | Description |
|---|---|
-InconsistentComponentError
|
If components with the same kind have different structures. |
-InvalidBondError
|
|
-ParallelBondError
|
If there are multiple bonds between the same pair of components. |
Warnings
- The assembly does not enforce connectivity; it is the user's responsibility to ensure that the assembly is connected as needed.
Notes
Currently, the assembly does not support parallel bonds (multiple bonds between the same pair of components), e.g., chelate complexes.
Examples:
A simple M2L2 ring:
>>> from nasap_net import Component, Assembly, Bond
>>> M = Component(kind='M', sites=[0, 1])
>>> L = Component(kind='L', sites=[0, 1])
>>> M2L2 = Assembly(
... components={'M0': M, 'M1': M, 'L0': L, 'L1': L},
... bonds=[
... Bond('M0', 1, 'L0', 0), Bond('L0', 1, 'M1', 0),
... Bond('M1', 1, 'L1', 0), Bond('L1', 1, 'M0', 0),
... ]
... )
A free ligand as a single-component assembly:
>>> X = Component(kind='X', sites=[0])
>>> free_X = Assembly(id_='free_X', components={'X0': X}, bonds=[])
Source code in src/nasap_net/models/assembly.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 | |
component_id_to_kind
cached
property
Return a mapping from component IDs to their kinds.
component_kind_counts
property
Return a mapping from component kinds to their counts.
components
property
Return the components in the assembly as an immutable mapping.
id_
property
Return the ID of the assembly.
id_or_none
property
Return the ID of the assembly, or None if not set.
add_bond(site1, site2)
Return a new assembly with an additional bond.
Source code in src/nasap_net/models/assembly.py
composition_formula(*, order=None, show_one=False)
Return the composition formula string for this assembly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
order
|
Sequence[str]
|
The order of component kinds to use in the formula. Kinds not listed here will appear at the end sorted alphabetically. |
None
|
show_one
|
bool
|
If True, always show the count even when it is 1 (e.g., |
False
|
Returns:
| Type | Description |
|---|---|
str
|
The composition formula string. |
Examples:
>>> M = Component(kind='M', sites=[0, 1])
>>> L = Component(kind='L', sites=[0, 1])
>>> M2L2 = Assembly(
... components={'M0': M, 'M1': M, 'L0': L, 'L1': L},
... bonds=[
... Bond('M0', 1, 'L0', 0), Bond('L0', 1, 'M1', 0),
... Bond('M1', 1, 'L1', 0), Bond('L1', 1, 'M0', 0),
... ]
... )
>>> M2L2.composition_formula()
'L2M2'
>>> M2L2.composition_formula(order=['M', 'L'])
'M2L2'
>>> M2L2.composition_formula(order=['M', 'L'], show_one=True)
'M2L2'
Source code in src/nasap_net/models/assembly.py
copy_with(*, components=MISSING, bonds=MISSING, id_=MISSING)
Return a copy of the assembly with optional modifications.
Fields not provided will default to the current values, except for the ID, which will be set to None if not provided.
If you want to copy the current ID, specify it explicitly,
e.g., copied = assembly.copy_with(id_=assembly.id_or_none).
Source code in src/nasap_net/models/assembly.py
find_sites(*, has_bond=None, component_kind=None)
Return binding sites based on their bond status.
Source code in src/nasap_net/models/assembly.py
get_bond_by_comp_ids(comp_id1, comp_id2)
Return the bond between two components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
comp_id1
|
ID
|
The ID of the first component. |
required |
comp_id2
|
ID
|
The ID of the second component. |
required |
Returns:
| Type | Description |
|---|---|
Bond
|
The bond between the two components. |
Raises:
| Type | Description |
|---|---|
BondNotFoundError
|
If there is no bond between the two components. |
Notes
This method assumes that there is no parallel bonds between the same pair of components.
Source code in src/nasap_net/models/assembly.py
get_component_kind_of_site(site)
has_bond(site)
has_bond_between_components(comp_id1, comp_id2)
Check if there is a bond between two components.
remove_bond(site1, site2)
Return a new assembly with a bond removed.
Source code in src/nasap_net/models/assembly.py
Reaction
dataclass
A single elementary reaction between assemblies.
Represents a metal–ligand exchange (MLE) in which a leaving ligand is
replaced by an entering ligand at a specific metal binding site.
Reaction objects are typically produced by :func:nasap_net.enumerate_reactions
rather than constructed directly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
init_assem
|
Assembly
|
The initial assembly that undergoes the reaction. |
required |
entering_assem
|
Assembly | None
|
The assembly supplying the entering ligand. None for intra-molecular reactions. |
required |
product_assem
|
Assembly
|
The product assembly after the reaction. |
required |
leaving_assem
|
Assembly | None
|
The assembly receiving the leaving ligand. None for intra-molecular reactions. |
required |
metal_bs
|
BindingSite
|
The binding site on the metal where the exchange occurs. |
required |
leaving_bs
|
BindingSite
|
The binding site of the leaving ligand. |
required |
entering_bs
|
BindingSite
|
The binding site of the entering ligand. |
required |
duplicate_count
|
int | None
|
The number of symmetry-equivalent ways this reaction can occur. Default is None. |
None
|
id_
|
ID | None
|
An optional identifier for this reaction. Default is None. |
None
|
Examples:
>>> from nasap_net import (
... Component, Assembly, Bond, BindingSite, Reaction
... )
>>> M = Component(kind='M', sites=[0, 1])
>>> L = Component(kind='L', sites=[0, 1])
>>> X = Component(kind='X', sites=[0])
>>> MX2 = Assembly(
... id_='MX2',
... components={'M0': M, 'X0': X, 'X1': X},
... bonds=[Bond('M0', 0, 'X0', 0), Bond('M0', 1, 'X1', 0)],
... )
>>> free_L = Assembly(id_='free_L', components={'L0': L}, bonds=[])
>>> MLX = Assembly(
... id_='MLX',
... components={'M0': M, 'X0': X, 'L0': L},
... bonds=[Bond('M0', 0, 'X0', 0), Bond('M0', 1, 'L0', 0)],
... )
>>> free_X = Assembly(id_='free_X', components={'X0': X}, bonds=[])
>>> reaction = Reaction(
... init_assem=MX2,
... entering_assem=free_L,
... product_assem=MLX,
... leaving_assem=free_X,
... metal_bs=BindingSite('M0', 1), # M0's site 1 (the active site)
... leaving_bs=BindingSite('X1', 0), # X1's site 0
... entering_bs=BindingSite('L0', 0), # L0's site 0
... duplicate_count=2,
... )
>>> reaction.equation_str
'MX2 + free_L -> MLX + free_X'
Source code in src/nasap_net/models/reaction.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 | |
duplicate_count
property
Return the duplicate count of the reaction.
duplicate_count_or_none
property
Return the duplicate count of the reaction, or None if not set.
entering_assem_id
property
Return the ID of the entering assembly, or None if there is none.
Errors if the ID is not set.
entering_assem_strict
property
Return the entering assembly.
Errors if there is no entering assembly.
equation_str
property
Return a string representation of the reaction equation.
If an assembly ID is not set, '??' is used in its place.
id_
property
Return the ID of the reaction.
id_or_none
property
Return the ID of the reaction, or None if not set.
init_assem_id
property
Return the ID of the initial assembly.
Errors if the ID is not set.
leaving_assem_id
property
Return the ID of the leaving assembly, or None if there is none.
Errors if the ID is not set.
leaving_assem_strict
property
Return the leaving assembly.
Errors if there is no leaving assembly.
metal_kind
property
Return the kind of the metal binding site.
mle
property
Return the MLE (metal, leaving, entering binding sites) of the reaction.
product_assem_id
property
Return the ID of the product assembly.
Errors if the ID is not set.
as_reaction_to_classify()
Return a ReactionToClassify version of this reaction.
copy_with(*, init_assem=MISSING, entering_assem=MISSING, product_assem=MISSING, leaving_assem=MISSING, metal_bs=MISSING, leaving_bs=MISSING, entering_bs=MISSING, duplicate_count=MISSING, id_=MISSING)
Return a copy of the reaction with optional modifications.
- Fields not provided will default to the current values, except for the ID, which will be set to None if not provided.
- Fields explicitly set to None will overwrite with None. (only applies to fields that can be None)
If you want to copy the current ID, specify it explicitly,
e.g., copied = reaction.copy_with(id_=reaction.id_or_none).
Source code in src/nasap_net/models/reaction.py
is_inter()
MLEKind
dataclass
Specifies the kind of metal–ligand exchange (MLE) reaction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metal
|
str
|
The kind of the metal component. |
required |
leaving
|
str
|
The kind of the leaving ligand component. |
required |
entering
|
str
|
The kind of the entering ligand component. |
required |
Examples:
>>> from nasap_net import MLEKind
>>> MLEKind(metal='M', leaving='X', entering='L') # X-to-L
>>> MLEKind(metal='M', leaving='L', entering='X') # L-to-X