Property & Coordinate Macros
These macros add molecular properties, generate coordinates, and modify molecular metadata.
Add Properties
OpenBabel.@add_properties — Macro@add_properties(expr, props)Add calculated molecular properties to the output.
Arguments
expr: Previous command in the chainprops: Vector of property names (e.g., ["MW", "logP", "TPSA"])
Example
@chain begin
@read_file("molecules.smi", "smi")
@add_properties(["MW", "logP", "HBD", "HBA"])
@output_as("molecules_with_props.sdf", "sdf")
@execute
endUsage Examples
Calculate common molecular descriptors:
@chain begin
@read_file("molecules.smi", "smi")
@add_properties(["MW", "logP", "TPSA", "HBD", "HBA"])
@output_as("molecules_with_props.sdf", "sdf")
@execute
endAvailable properties include:
MW- Molecular weightlogP- Partition coefficientTPSA- Topological polar surface areaHBD- Hydrogen bond donorsHBA- Hydrogen bond acceptorsrotors- Number of rotatable bondsatoms- Number of atomsbonds- Number of bonds
Available Descriptors
The get_available_descriptors() function returns a list of all molecular descriptors that can be calculated:
descriptors = get_available_descriptors()
println(descriptors)Generate 3D Coordinates
OpenBabel.@gen_3D_coords — Macro@gen_3D_coords(expr, speed)Generate 3D coordinates for molecules.
Arguments
expr: Previous command in the chainspeed: Generation speed ("fast", "med", "slow")
Example
@chain begin
@read_file("input.smi", "smi")
@gen_3D_coords("fast")
@output_as("output_3d.mol", "mol")
@execute
endUsage Examples
# Fast generation (good for large datasets)
@chain begin
@read_file("input.smi", "smi")
@gen_3D_coords("fast")
@output_as("output_3d.mol", "mol")
@execute
end
# Higher quality (slower)
@chain begin
@read_file("input.smi", "smi")
@gen_3D_coords("slow")
@output_as("high_quality_3d.mol", "mol")
@execute
endGenerate 2D Coordinates
OpenBabel.@gen_2D_coords — Macro@gen_2D_coords(expr)Generate 2D coordinates for molecules.
Example
@chain begin
@read_file("input.smi", "smi")
@gen_2D_coords()
@output_as("output_2d.mol", "mol")
@execute
endUsage Examples
Generate 2D coordinates for visualization:
@chain begin
@read_file("molecules.smi", "smi")
@gen_2D_coords()
@output_as("molecules_2d.sdf", "sdf")
@execute
endCenter Coordinates at Zero
OpenBabel.@center_coords_at_zero — Macro@center_coords_at_zero(expr)Center the molecular coordinates at the origin (0,0,0).
Arguments
expr: Previous command in the chain
Example
@chain begin
@read_file("molecules.mol", "mol")
@center_coords_at_zero()
@output_as("centered_molecules.mol", "mol")
@execute
endUsage Examples
Center molecular coordinates at the origin:
@chain begin
@read_file("input.smi", "smi")
@gen_3D_coords("slow")
@center_coords_at_zero()
@output_as("centered_3d.mol", "mol")
@execute
endAdd Filename
OpenBabel.@add_filename — Macro@add_filename(expr)Add the original filename as a property to each molecule in the output.
Arguments
expr: Previous command in the chain
Example
@chain begin
@read_file("molecules.smi", "smi")
@add_filename()
@output_as("output_with_filenames.sdf", "sdf")
@execute
endUsage Examples
Add the source filename as metadata:
@chain begin
@read_file("database.sdf", "sdf")
@add_filename()
@output_as("molecules_with_filename.sdf", "sdf")
@execute
endAdd Index
OpenBabel.@add_index — Macro@add_index(expr)Add a sequential index number to each molecule in the output.
Arguments
expr: Previous command in the chain
Example
@chain begin
@read_file("database.sdf", "sdf")
@add_index()
@output_as("indexed_molecules.sdf", "sdf")
@execute
endUsage Examples
Add molecule indices for tracking:
@chain begin
@read_file("molecules.sdf", "sdf")
@add_index()
@output_as("indexed_molecules.sdf", "sdf")
@execute
endAdd Title
OpenBabel.@add_title — Macro@add_title(expr, title)Add a custom title to each molecule in the output.
Arguments
expr: Previous command in the chaintitle: Title string to add to molecules
Example
@chain begin
@read_file("compounds.smi", "smi")
@add_title("Processed Compounds")
@output_as("titled_compounds.sdf", "sdf")
@execute
endUsage Examples
@chain begin
@read_file("molecules.sdf", "sdf")
@add_title("Processed Database")
@output_as("titled_molecules.sdf", "sdf")
@execute
endComplete Workflows
Property Calculation Pipeline
@chain begin
@read_file("molecules.smi", "smi")
@gen_3D_coords("med")
@add_properties(["MW", "logP", "TPSA", "HBD", "HBA"])
@add_index()
@add_filename()
@output_as("full_analysis.sdf", "sdf")
@execute
endCoordinate Generation with Metadata
@chain begin
@read_file("database.sdf", "sdf")
@gen_3D_coords("slow")
@center_coords_at_zero()
@add_index()
@add_filename()
@add_title("High Quality 3D Structures")
@output_as("processed_3d.sdf", "sdf")
@execute
end