NoahHenrikKleinschmidt/buildamol: BuildAMol v.1.2.11

Fuente: Zenodo
Saved in:
Bibliographic Details
Main Author: Noah Kleinschmidt
Format: Recurso digital
Published: Zenodo 2025
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866902137552764928
author Noah Kleinschmidt
author_facet Noah Kleinschmidt
contents <h2>New <code>Reaction</code> and <code>Reactivity</code> classes for enhanced chemistry support</h2> <p>The new <code>Reaction</code> serves as an automated <code>Linkage</code> generator, by accepting functions rather than <code>Atom</code> instances to search for suitable linker and deleter atoms when connecting <code>Molecules</code>. The class is complemented by the new <code>Reactivity</code> classes that succeed the old <code>FunctionalGroup</code> classes (the latter will remain part of the codebase). The <code>Reactivity</code> classes define atom getter functions to mimic the reaction patterns of functional groups in a more flexible way than the old functional groups could.</p> <blockquote> <h3>Be sure to check out the <a href="https://biobuild.readthedocs.io/en/latest/examples/reaction.html">Reaction tutorial</a> and <a href="https://biobuild.readthedocs.io/en/latest/examples/reactivity.html">Reactivity tutorial</a> to learn more about their usage.</h3> </blockquote> <h3>Quick look</h3> <p>To let two molecules "react" via their functional groups do the following:</p> <pre><code>import buildamol as bam from buildamol.structural.reactivity import Hydroxyl, Carboxyl alcohol = bam.molecule("cyclohexanol") acid = bam.molecule("acetic acid") reaction = bam.Reaction.from_reactivities( electrophile=Carboxyl(), nucleophile=Hydroxyl(), ) product = reaction(acid, alcohol) </code></pre> <p><img width="200" height="200" alt="image" src="https://github.com/user-attachments/assets/921059b2-93e5-4efa-a29e-db439a1fd798" /></p> <h2>Larger leaving groups with Linkages</h2> <p><code>Linkages</code> can now automatically delete <em>all</em> downstream atoms of the <em>defined</em> deleter atoms. This means that by defining a single deleter atom of a larger leaving group, <em>all</em> atoms of the group are removed. This behaviour is now default for <em>all</em> <code>Linkages</code> but can be disabled for individual linkages using <code>automatically_delete_downstream_atoms=False</code>.</p> <p>To exemplify this. Let's say we want to delete an entire phosphate group from a molecule when attaching another molecule. We can specify the linkage as follows:</p> <pre><code>mol = bam.read_smiles("NCC") mol = bam.phosphorylate(mol, "C2").squash() # in this case specifying the O2 as deleter atom # will automatically mark all other phosphate group atoms # downstream of the C2-O2 bond for deletion as well link = bam.linkage("C2", "N1", delete_in_target=["O2"]) out = mol % link + mol.copy() </code></pre> <p><img width="745" height="263" alt="image" src="https://github.com/user-attachments/assets/b44caee9-5871-4fa9-a58c-51fb37b42986" /></p> <h2>Atoms know their Neighbourhood</h2> <p>So far, connectivity was exclusively known to <code>Molecule</code> instances. Child objects such as individual <code>Atom</code> instances had no access to such information. The <code>base_classes</code> now have a <code>molecule</code> attribute that allows them to access their toplevel entity. By extension, <code>Atom</code> and <code>Residue</code> objects now also support methods such as <code>get_neighbors</code> or <code>get_bonds</code>.</p> <pre><code>mol.get_neighbors(some_atom) # previously the only way to get neighbors some_atom.get_neighbors() # ✅ since v.1.2.11 also supported </code></pre> <p>Methods of the <code>Atom</code> class thus newly supported are:</p> <ul> <li>get_neighbors (also supported by the <code>Residue</code> class)</li> <li>get_hydrogens</li> <li>get_equatorial_neighbor</li> <li>get_axial_neighbor</li> <li>get_equatorial_hydrogen</li> <li>get_axial_hydrogen</li> <li>get_left_hydrogen</li> <li>get_right_hydrogen</li> <li>get_bonds (also supported by the <code>Residue</code> class)</li> </ul> <h2>Improved Constraint Functions</h2> <p>The new <code>constraints_v2</code> class defines improved constraint functions for atom filtering with <code>get_atoms</code>. They work with a single <code>Atom</code> instance as the only argument and build on the above-mentioned new <code>get_neighbors</code> support of the <code>Atom</code> class. The <code>constraints_v2</code> are a separate entity from the existing <code>constraints</code>, which will remain an unchanged part of the codebase for now.</p> <p>For example constraints such as "a carbon with a double bond to an oxygen and single bond to a nitrogen" would be a description for the central C of an <code>R-C(=O)N-R</code> amide group. To search for carbons matching this description, we can use:</p> <pre><code>from buildamol.structural import constraints_v2 as constraints filters = constraints.and_( constraints.has_double_bond_with("O"), constraints.has_single_bond_with("N"), ) matching_carbons = mol.get_atoms("C", by="element", filter=filters) </code></pre> <h2>More powerful 2D visualizations</h2> <p>The <code>Chem2DViewer</code> received a few additional methods to <code>highlight_atoms</code>, <code>highlight_bonds</code>, <code>highlight_residues</code>, and <code>label_atoms</code> in more flexible ways. In addition to hard-coded values such as colour values, functions can now be used to set values for atom colors or labels dynamically.</p> <p>The <a href="https://biobuild.readthedocs.io/en/latest/examples/drawing.html#2D-drawing">visualization tutorial</a> was updated accordingly so be sure to check it out!</p> <h2>Other Changes</h2> <ul> <li>the <code>phosphorylate</code> function had a bug with the attachment atoms, which is fixed now</li> <li><code>Bond</code> instances can now get the "binding partner" based on one atom (i.e. if given atom1 they return atom2 and vice versa)</li> <li><code>Molecule</code> instances can now get atoms that are in a specific spatial region using <code>get_atoms_within</code> (based on some anchor coordinate)</li> <li>the documentation received a small makeover</li> <li>other small bug fixes</li> </ul>
format Recurso digital
id zenodo_https___doi_org_10_5281_zenodo_17201633
institution Zenodo
language
publishDate 2025
publisher Zenodo
record_format zenodo
spellingShingle NoahHenrikKleinschmidt/buildamol: BuildAMol v.1.2.11
Noah Kleinschmidt
<h2>New <code>Reaction</code> and <code>Reactivity</code> classes for enhanced chemistry support</h2> <p>The new <code>Reaction</code> serves as an automated <code>Linkage</code> generator, by accepting functions rather than <code>Atom</code> instances to search for suitable linker and deleter atoms when connecting <code>Molecules</code>. The class is complemented by the new <code>Reactivity</code> classes that succeed the old <code>FunctionalGroup</code> classes (the latter will remain part of the codebase). The <code>Reactivity</code> classes define atom getter functions to mimic the reaction patterns of functional groups in a more flexible way than the old functional groups could.</p> <blockquote> <h3>Be sure to check out the <a href="https://biobuild.readthedocs.io/en/latest/examples/reaction.html">Reaction tutorial</a> and <a href="https://biobuild.readthedocs.io/en/latest/examples/reactivity.html">Reactivity tutorial</a> to learn more about their usage.</h3> </blockquote> <h3>Quick look</h3> <p>To let two molecules "react" via their functional groups do the following:</p> <pre><code>import buildamol as bam from buildamol.structural.reactivity import Hydroxyl, Carboxyl alcohol = bam.molecule("cyclohexanol") acid = bam.molecule("acetic acid") reaction = bam.Reaction.from_reactivities( electrophile=Carboxyl(), nucleophile=Hydroxyl(), ) product = reaction(acid, alcohol) </code></pre> <p><img width="200" height="200" alt="image" src="https://github.com/user-attachments/assets/921059b2-93e5-4efa-a29e-db439a1fd798" /></p> <h2>Larger leaving groups with Linkages</h2> <p><code>Linkages</code> can now automatically delete <em>all</em> downstream atoms of the <em>defined</em> deleter atoms. This means that by defining a single deleter atom of a larger leaving group, <em>all</em> atoms of the group are removed. This behaviour is now default for <em>all</em> <code>Linkages</code> but can be disabled for individual linkages using <code>automatically_delete_downstream_atoms=False</code>.</p> <p>To exemplify this. Let's say we want to delete an entire phosphate group from a molecule when attaching another molecule. We can specify the linkage as follows:</p> <pre><code>mol = bam.read_smiles("NCC") mol = bam.phosphorylate(mol, "C2").squash() # in this case specifying the O2 as deleter atom # will automatically mark all other phosphate group atoms # downstream of the C2-O2 bond for deletion as well link = bam.linkage("C2", "N1", delete_in_target=["O2"]) out = mol % link + mol.copy() </code></pre> <p><img width="745" height="263" alt="image" src="https://github.com/user-attachments/assets/b44caee9-5871-4fa9-a58c-51fb37b42986" /></p> <h2>Atoms know their Neighbourhood</h2> <p>So far, connectivity was exclusively known to <code>Molecule</code> instances. Child objects such as individual <code>Atom</code> instances had no access to such information. The <code>base_classes</code> now have a <code>molecule</code> attribute that allows them to access their toplevel entity. By extension, <code>Atom</code> and <code>Residue</code> objects now also support methods such as <code>get_neighbors</code> or <code>get_bonds</code>.</p> <pre><code>mol.get_neighbors(some_atom) # previously the only way to get neighbors some_atom.get_neighbors() # ✅ since v.1.2.11 also supported </code></pre> <p>Methods of the <code>Atom</code> class thus newly supported are:</p> <ul> <li>get_neighbors (also supported by the <code>Residue</code> class)</li> <li>get_hydrogens</li> <li>get_equatorial_neighbor</li> <li>get_axial_neighbor</li> <li>get_equatorial_hydrogen</li> <li>get_axial_hydrogen</li> <li>get_left_hydrogen</li> <li>get_right_hydrogen</li> <li>get_bonds (also supported by the <code>Residue</code> class)</li> </ul> <h2>Improved Constraint Functions</h2> <p>The new <code>constraints_v2</code> class defines improved constraint functions for atom filtering with <code>get_atoms</code>. They work with a single <code>Atom</code> instance as the only argument and build on the above-mentioned new <code>get_neighbors</code> support of the <code>Atom</code> class. The <code>constraints_v2</code> are a separate entity from the existing <code>constraints</code>, which will remain an unchanged part of the codebase for now.</p> <p>For example constraints such as "a carbon with a double bond to an oxygen and single bond to a nitrogen" would be a description for the central C of an <code>R-C(=O)N-R</code> amide group. To search for carbons matching this description, we can use:</p> <pre><code>from buildamol.structural import constraints_v2 as constraints filters = constraints.and_( constraints.has_double_bond_with("O"), constraints.has_single_bond_with("N"), ) matching_carbons = mol.get_atoms("C", by="element", filter=filters) </code></pre> <h2>More powerful 2D visualizations</h2> <p>The <code>Chem2DViewer</code> received a few additional methods to <code>highlight_atoms</code>, <code>highlight_bonds</code>, <code>highlight_residues</code>, and <code>label_atoms</code> in more flexible ways. In addition to hard-coded values such as colour values, functions can now be used to set values for atom colors or labels dynamically.</p> <p>The <a href="https://biobuild.readthedocs.io/en/latest/examples/drawing.html#2D-drawing">visualization tutorial</a> was updated accordingly so be sure to check it out!</p> <h2>Other Changes</h2> <ul> <li>the <code>phosphorylate</code> function had a bug with the attachment atoms, which is fixed now</li> <li><code>Bond</code> instances can now get the "binding partner" based on one atom (i.e. if given atom1 they return atom2 and vice versa)</li> <li><code>Molecule</code> instances can now get atoms that are in a specific spatial region using <code>get_atoms_within</code> (based on some anchor coordinate)</li> <li>the documentation received a small makeover</li> <li>other small bug fixes</li> </ul>
title NoahHenrikKleinschmidt/buildamol: BuildAMol v.1.2.11
url https://doi.org/10.5281/zenodo.17201633