Skip to content

Commit

Permalink
add reaction element count
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoruiDong committed Oct 20, 2023
1 parent 35f5e4b commit cc64388
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions rdmc/reaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,20 @@ def is_num_atoms_balanced(self) -> bool:
"""
return self.reactant_complex.GetNumAtoms() == self.product_complex.GetNumAtoms()

@property
def reactant_element_count(self) -> dict:
"""
The element count in the reactant(s) and product(s).
"""
return dict(Counter(self.reactant_complex.GetElementSymbols()))

Check warning on line 147 in rdmc/reaction.py

View check run for this annotation

Codecov / codecov/patch

rdmc/reaction.py#L147

Added line #L147 was not covered by tests

@property
def product_element_count(self) -> dict:
"""
The element count in the reactant(s) and product(s).
"""
return dict(Counter(self.product_complex.GetElementSymbols()))

Check warning on line 154 in rdmc/reaction.py

View check run for this annotation

Codecov / codecov/patch

rdmc/reaction.py#L154

Added line #L154 was not covered by tests

@property
def is_element_balanced(self) -> bool:
"""
Expand Down Expand Up @@ -477,8 +491,7 @@ def has_same_reactants(
Returns:
bool: Whether the reaction has the same reactants as the other reaction.
"""
return self.is_same_reactants(other.reactant_complex,
resonance=resonance)
return self.is_same_reactants(other.reactant_complex, resonance=resonance)

Check warning on line 494 in rdmc/reaction.py

View check run for this annotation

Codecov / codecov/patch

rdmc/reaction.py#L494

Added line #L494 was not covered by tests

def is_same_reactants(
self,
Expand All @@ -495,9 +508,7 @@ def is_same_reactants(
Returns:
bool: Whether the reaction has the same reactants as the given reactants or reactant complex.
"""
return is_same_complex(self.reactant_complex,
reactants,
resonance=resonance)
return is_same_complex(self.reactant_complex, reactants, resonance=resonance)

Check warning on line 511 in rdmc/reaction.py

View check run for this annotation

Codecov / codecov/patch

rdmc/reaction.py#L511

Added line #L511 was not covered by tests

def has_same_products(
self,
Expand All @@ -513,8 +524,7 @@ def has_same_products(
Returns:
bool: Whether the reaction has the same products as the other reaction.
"""
return self.is_same_products(other.product_complex,
resonance=resonance)
return self.is_same_products(other.product_complex, resonance=resonance)

Check warning on line 527 in rdmc/reaction.py

View check run for this annotation

Codecov / codecov/patch

rdmc/reaction.py#L527

Added line #L527 was not covered by tests

def is_same_products(
self,
Expand All @@ -531,6 +541,4 @@ def is_same_products(
Returns:
bool: Whether the reaction has the same products as the given products or product complex.
"""
return is_same_complex(self.product_complex,
products,
resonance=resonance)
return is_same_complex(self.product_complex, products, resonance=resonance)

Check warning on line 544 in rdmc/reaction.py

View check run for this annotation

Codecov / codecov/patch

rdmc/reaction.py#L544

Added line #L544 was not covered by tests

0 comments on commit cc64388

Please sign in to comment.