Use this file to discover all available pages before exploring further.
ChemAgent provides powerful molecule-to-text and text-to-molecule capabilities, enabling you to describe molecular structures or generate novel compounds from natural language descriptions.
from LLM4Chem.generation import LlaSMolGenerationgenerator = LlaSMolGeneration('osunlp/LlaSMol-Mistral-7B')query = "Describe this molecule: <SMILES> CCOC(=O)C1=CN=CN1[C@H](C)C1=CC=CC=C1 </SMILES>"result = generator.generate(query)print(result[0]['output'][0])
Output:
The molecule is an imidazole derivative with short-acting sedative, hypnotic, and general anesthetic properties. Etomidate appears to have gamma-aminobutyric acid (GABA) like effects, mediated through GABA-A receptor. The action enhances the inhibitory effect of GABA on the central nervous system by causing chloride channel opening events which leads to membrane hyperpolarization.
query = """Give me a molecule that satisfies the conditions outlined in the description: The molecule is a member of the class of tripyrroles that is a red-coloured pigment with antibiotic properties produced by Serratia marcescens. It has a role as an antimicrobial agent, a biological pigment, a bacterial metabolite, an apoptosis inducer and an antineoplastic agent. It is a tripyrrole, an aromatic ether and a ring assembly."""result = generator.generate(query)print(result[0]['output'][0])# Output: Here is a potential molecule: <SMILES> CCCCCC1=C(C)NC(/C=C2\N=C(C3=CC=CN3)C=C2OC)=C1 </SMILES>
Unlike other tasks, molecule generation does not require tags around the input description. Simply provide the natural language description directly.
query = """Generate a molecule with the following properties:- Antimicrobial activity- Ability to cross blood-brain barrier- Low toxicity- Water soluble"""result = generator.generate(query)
query = """Create a molecule that:- Contains a benzene ring- Has at least one hydroxyl group- Includes a carboxylic acid functional group"""result = generator.generate(query)
query = "Generate a molecule that is a beta-lactam antibiotic"result = generator.generate(query)
query = """Design a molecule that can act as:- HIV protease inhibitor- With good oral bioavailability"""result = generator.generate(query)
import asynciofrom plan_execute_agent.rdkit_agent import process_inputquery = "Generate a molecule that is an NMDA receptor antagonist"result, completed, attempts, llasmol_response, errors, formatted_input = \ asyncio.run(process_input(query))if completed and not errors: print(f"Generated and validated: {result}")else: print(f"Generation issues: {errors}")
base_description = "A molecule that inhibits HIV replication"variants = [ f"{base_description} with high water solubility", f"{base_description} with improved lipophilicity", f"{base_description} with reduced toxicity"]for i, variant in enumerate(variants, 1): result = generator.generate(f"Generate a molecule: {variant}") print(f"\nVariant {i}:") print(result[0]['output'][0])
Generate molecules with similar properties but different cores:
# Get description of original moleculeoriginal = "C1=CC=C(C=C1)O" # Phenolcaption = generator.generate(f"Describe: <SMILES> {original} </SMILES>")# Generate alternative scaffoldsquery = f"{caption[0]['output'][0]}. Generate a molecule with different core structure but similar properties."result = generator.generate(query)