MetaLig API

class DARTassembler.src.metalig.db.BaseDB(db)[source]

Bases: object

to_dict(desc='Convert DB to dict')[source]

Converts all molecules in the database to a dictionary format.

Parameters:

desc – str: Description for the progress bar.

Returns:

A dictionary where keys are molecule identifiers and values are dictionaries representing the molecules.

save_to_file(path, desc=None, json_lines=True)[source]

Saves the database to a .json or .jsonlines file.

Parameters:
  • path – Path to the output file where the database will be saved.

  • desc – Description for the progress bar. If None, no progress bar will be shown.

  • json_lines – If True, saves the database as jsonlines. If False, saves the database as a single json file.

Returns:

None

class DARTassembler.src.metalig.db.LigandDB(db)[source]

Bases: BaseDB

classmethod from_json(path='metalig', n_max=None, show_progress=True)[source]

Loads a ligand database from a .jsonlines file.

Parameters:
  • path – Path to the .jsonlines file of the ligand database. Alternatively, the string ‘metalig’ can be used to load the default ligand database.

  • n_max – Maximum number of ligands to load. If None, all ligands will be loaded.

  • show_progress – If True, a progress bar will be shown.

Returns:

A LigandDB object

get_df(max_entries=5)[source]

Returns a DataFrame with important ligand information for all ligands in the database, such as charge, stoichiometry, archetype, and more.

Parameters:

max_entries – Maximum number of entries for long lists in the DataFrame, such as the list of CSD codes in which this ligand is present.

Returns:

A DataFrame with ligand information, with the index being unique_name.

save_to_csv(outpath, max_entries=5)[source]

Saves a csv file with important ligand information for all ligands in the database, such as charge, stoichiometry, archetype, and more.

Parameters:
  • outpath – Path to the output csv file.

  • max_entries – Maximum number of entries for long lists in the DataFrame, such as the list of CSD codes in which this ligand is present.

Returns:

A DataFrame with ligand information.

save_to_concat_xyz(outpath, with_metal=True, comment=None)[source]

Save a concatenated xyz file with all ligands in the database.

Parameters:
  • outpath – Path to the output xyz file.

  • with_metal – If True, the output structure of each ligand will contain a metal center at the original position for better visualization. If False, only the ligand structure itself will be saved.

  • comment – A comment to be added to each xyz structure. If None, a default comment will be used.

Returns:

A concatenated xyz string with all ligands in the database.

get_concat_xyz_string(with_metal=True, comment=None)[source]

Get a concatenated xyz string with all ligands in the database.

Parameters:
  • with_metal – If True, the output structure of each ligand will contain a metal center at the original position for better visualization. If False, only the ligand structure itself will be saved.

  • comment – A comment to be added to each xyz structure. If None, a default comment will be used.

Returns:

A concatenated xyz string with all ligands in the database.

get_sub_db(ligand_names)[source]

Returns a sub-database containing only the ligands with the specified names.

Parameters:

ligand_names (list[str]) – List of ligand names to include in the sub-database.

Returns:

A LigandDB object containing only the specified ligands.

Return type:

LigandDB