Property & Coordinate Macros

These macros add molecular properties, generate coordinates, and modify molecular metadata.

Add Properties

OpenBabel.@add_propertiesMacro
@add_properties(expr, props)

Add calculated molecular properties to the output.

Arguments

  • expr: Previous command in the chain
  • props: 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
end
source

Usage 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
end

Available properties include:

  • MW - Molecular weight
  • logP - Partition coefficient
  • TPSA - Topological polar surface area
  • HBD - Hydrogen bond donors
  • HBA - Hydrogen bond acceptors
  • rotors - Number of rotatable bonds
  • atoms - Number of atoms
  • bonds - 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_coordsMacro
@gen_3D_coords(expr, speed)

Generate 3D coordinates for molecules.

Arguments

  • expr: Previous command in the chain
  • speed: Generation speed ("fast", "med", "slow")

Example

@chain begin
    @read_file("input.smi", "smi")
    @gen_3D_coords("fast")
    @output_as("output_3d.mol", "mol")
    @execute
end
source

Usage 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
end

Generate 2D Coordinates

OpenBabel.@gen_2D_coordsMacro
@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
end
source

Usage Examples

Generate 2D coordinates for visualization:

@chain begin
    @read_file("molecules.smi", "smi")
    @gen_2D_coords()
    @output_as("molecules_2d.sdf", "sdf")
    @execute
end

Center Coordinates at Zero

OpenBabel.@center_coords_at_zeroMacro
@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
end
source

Usage 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
end

Add Filename

OpenBabel.@add_filenameMacro
@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
end
source

Usage Examples

Add the source filename as metadata:

@chain begin
    @read_file("database.sdf", "sdf")
    @add_filename()
    @output_as("molecules_with_filename.sdf", "sdf")
    @execute
end

Add Index

OpenBabel.@add_indexMacro
@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
end
source

Usage Examples

Add molecule indices for tracking:

@chain begin
    @read_file("molecules.sdf", "sdf")
    @add_index()
    @output_as("indexed_molecules.sdf", "sdf")
    @execute
end

Add Title

OpenBabel.@add_titleMacro
@add_title(expr, title)

Add a custom title to each molecule in the output.

Arguments

  • expr: Previous command in the chain
  • title: 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
end
source

Usage Examples

@chain begin
    @read_file("molecules.sdf", "sdf")
    @add_title("Processed Database")
    @output_as("titled_molecules.sdf", "sdf")
    @execute
end

Complete 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
end

Coordinate 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