Skip to content

Releases: sinagilassi/PyMolinfo

Create Molecule

02 Mar 03:13
Compare
Choose a tag to compare

New Features

  • Molecule Source with Different Chains: You can now define a molecule source with multiple chains, enabling the creation of complex molecular structures.
  • Loop Chain Capability: A new feature allows you to define a loop chain, such as the benzene molecule, by adding asterisks (*) at the beginning and end of the bond sequence.

Chain Types

  1. Branch: Chain1: ["*-C1", "C1=C2", "C2-C3", "C3=C4"]
  2. Loop: Chain1: ["*-C1", "C1=C2", "C2-C3", "C3=*"]
  3. Bridge: Chain1: ["*-C1", "C1=C2", "C2-C3", "C3=**"]

Molecule Source Definition Rules

  • * represents a connection point.
  • {} is used to reference another chain.
  • Bond index starts from 1 in all chains.
  • Supported bond types: single bond (-), double bond (=), and triple bond (#).

Example Usage

molecule_src = {
    'MainChain': ["C1-C2", "C2-C3", "C3*{Chain1}", "C3-C4", "C4*{Chain2}", "C4-C5", "C5-C6"],
    'Chain1': ["C1=C2", "C2-C3", "C3=*"],
    'Chain2': ["*-C1", "C1=C2", "C2-XX3"]
}

mol_= mi.generate_molecule(molecule_src, molecule_name='my_molecule')
# molecule info
molecule = mol_.molecule
print(molecule)

# NOTE: create a molecule graph (nx.Graph)
graph = mol_.to_graph()
print(graph)

# NOTE: create a molgraph (MolGraph)
mol_graph = mol_.to_molgraph()
# display molecule graph
mol_graph.d()

pymolinfo-1 8 0

molecule_src = {
    'MainChain': ["C1-C2", "C2=C3", "C3-C4", "C3*{Chain1}", "C4=C5", "C5*{Chain1}", "C5-C6", "C6=C1", "C6*{Chain2}"],
    'Chain1': ["C1=C2", "C2-C3", "C3=*"],
    'Chain2': ["*-C1", "C1=C2", "C2-XX3"]
}

pymolinfo-img2-1 8 0

molecule_src = {
    'MainChain': ["C1*{Chain1}", "C1-C2", "C2*{Chain2}"],
    'Chain1': ["*-C1", "C1=C2", "C2-C3", "C3=*"],
    'Chain2': ["*-C1", "C1=C2", "C2-C3", "C3=*"],
}

pymolinfo-img3-1 8 0

molecule_src = {
    'MainChain': ["C1*{Chain1}", "C1-C2", "C2*{Chain2}", "C2-C3", "C3*{Chain3}"],
    'Chain1': ["*-C1", "C1=C2", "C2-C3", "C3=*"],
    'Chain2': ["*-C1", "C1=C2", "C2-C3", "C3=*"],
    'Chain3': ["*-C1", "C1=C2", "C2-C3"],
}

pymolinfo-img4-1 8 0

# naphthalene
molecule_src = {
    'MainChain': ["C1-C2", "C2=C3", "C3-C4", "C4=C5", "C5-C6", "C6=C1", "C1*{Chain1}", "C6*{Chain1}"],
    'Chain1': ["*-C1", "C1=C2", "C2-C3", "C3=C4", "C4-**"],
}

pymolinfo-img5-1 8 0

Create Molecule Graph with Loop Chains

26 Feb 19:56
Compare
Choose a tag to compare

New Features

  • Molecule Source with Different Chains: You can now define a molecule source with multiple chains, enabling the creation of complex molecular structures.
  • Loop Chain Capability: A new feature allows you to define a loop chain, such as the benzene molecule, by adding asterisks (*) at the beginning and end of the bond sequence.

Chain Types

  1. Branch: Chain1: ["*-C1", "C1=C2", "C2-C3", "C3=C4"]
  2. Loop: Chain1: ["*-C1", "C1=C2", "C2-C3", "C3=*"]
  3. Bridge: Chain1: ["*-C1", "C1=C2", "C2-C3", "C3=**"]

Example Usage

The following example demonstrates how to define a molecule source with multiple chains, including a loop chain:

molecule_src = {
    'MainChain': ["C1*{Chain1}", "C1-C2", "C2*{Chain2}"],
    'Chain1': ["*-C1", "C1=C2", "C2-C3", "C3=*"],
    'Chain2': ["*-C1", "C1=C2", "C2-C3", "C3=*"],
}

# Create molecule graph
mol_graph = mi.create_molecule_graph(
    molecule_src, molecule_name='my_molecule')
print(mol_graph)

# Display molecule graph
mol_graph.d("my_molecule")

pymolinfo-img3-1 8 0

molecule_src = {
    'MainChain': ["C1*{Chain1}", "C1-C2", "C2*{Chain2}", "C2-C3", "C3*{Chain3}"],
    'Chain1': ["*-C1", "C1=C2", "C2-C3", "C3=*"],
    'Chain2': ["*-C1", "C1=C2", "C2-C3", "C3=*"],
    'Chain3': ["*-C1", "C1=C2", "C2-C3"],
}

pymolinfo-img4-1 8 0

# naphthalene
molecule_src = {
    'MainChain': ["C1-C2", "C2=C3", "C3-C4", "C4=C5", "C5-C6", "C6=C1", "C1*{Chain1}", "C6*{Chain1}"],
    'Chain1': ["*-C1", "C1=C2", "C2-C3", "C3=C4", "C4-**"],
}

pymolinfo-img5-1 8 0

Create Molecule Graph

24 Feb 18:59
Compare
Choose a tag to compare

New Features

  • Create Molecule Graph: A new method create_molecule_graph has been added to create a molecule graph from a given molecule source.
  • Molecule Source Definition: A new set of rules has been introduced to define the molecule source, including connection points (*), chain references ({}), and bond types.

Molecule Source Definition Rules

  • * represents a connection point.
  • {} is used to reference another chain.
  • Bond index starts from 1 in all chains.
  • Supported bond types: single bond (-), double bond (=), and triple bond (#).

Example Usage

molecule_src = {
    'MainChain': ["C1-C2", "C2-C3", "C3*{Chain1}", "C3-C4", "C4*{Chain2}", "C4-C5", "C5-C6"],
    'Chain1': ["C1=C2", "C2-C3", "C3=*"],
    'Chain2': ["*-C1", "C1=C2", "C2-XX3"]
}

mol_graph = mi.create_molecule_graph(molecule_src, molecule_name='my_molecule')
print(mol_graph)
mol_graph.d("my_molecule")

pymolinfo-1 8 0

molecule_src = {
    'MainChain': ["C1-C2", "C2=C3", "C3-C4", "C3*{Chain1}", "C4=C5", "C5*{Chain1}", "C5-C6", "C6=C1", "C6*{Chain2}"],
    'Chain1': ["C1=C2", "C2-C3", "C3=*"],
    'Chain2': ["*-C1", "C1=C2", "C2-XX3"]
}

# * create molecule graph
mol_graph = mi.create_molecule_graph(molecule_src, molecule_name='my_molecule')
print(mol_graph)
# display molecule graph
mol_graph.d("my_molecule")

pymolinfo-img2-1 8 0