chem_nor 0.5.5 copy "chem_nor: ^0.5.5" to clipboard
chem_nor: ^0.5.5 copied to clipboard

Dart package that finds relevant chemical compounds using AI(Gemini) and PubChem. Use it to level up your chemistry knowledge and chat with your Ai chemist!

ChemNOR Version

ChemNOR #

Chemical Heuristic Evaluation of Molecules Networking for Optimized Reactivity #

A powerful Dart package that discovers relevant chemical compounds using Google Gemini AI and PubChem β€” your all-in-one chemistry toolkit.

pub.dev License SDK Issues


πŸ“– Overview #

ChemNOR combines the power of Google Gemini AI with the vast PubChem chemical database to give you:

  • πŸ”¬ AI-driven compound discovery via SMILES pattern generation
  • πŸ’¬ Conversational AI Chemist for chemistry Q&A
  • πŸ§ͺ Formula parsing, IUPAC naming, and molecular weight calculation
  • πŸ“Š NMR, IR, and Mass spectroscopy simulation
  • βš–οΈ Automatic chemical equation balancing
  • πŸ›‘οΈ GHS safety data retrieval
  • πŸ–ΌοΈ Molecular structure visualization

Note: A Google Cloud API Key is required for AI features.


πŸš€ Installation #

Add the following to your pubspec.yaml:

dependencies:
  chem_nor: ^0.5.5

Then run:

dart pub get

βš™οΈ Initialization #

Default Model (gemini-2.5-flash) #

import 'package:chem_nor/chem_nor.dart';

final chemNor = ChemNOR(genAiApiKey: 'your-api-key');

Specifying a Model #

final chemNor = ChemNOR(
  genAiApiKey: 'your-api-key',
  model: GeminiModel.gemini_2_5_pro.apiName,
);

note: use .apiName to get the api name of the model Available models:

Model Identifier
Gemini 2.5 Flash Lite GeminiModel.gemini_2_5_flash_lite.apiName
Gemini 2.5 Flash GeminiModel.gemini_2_5_flash.apiName
Gemini 2.5 Pro GeminiModel.gemini_2_5_pro.apiName
Gemini 3.0 Flash Preview GeminiModel.gemini_3_flash_preview.apiName
Gemini 3.0 Pro Preview GeminiModel.gemini_3_pro_preview.apiName
// Print all available models
print(ChemNOR.availableModels);

🧬 Core Features #

1. πŸ” Find Relevant Compounds #

Finds chemical compounds matching an application description using AI-generated SMILES patterns and PubChem lookups.

import 'package:chem_nor/chem_nor.dart';

void main() async {
  final chemNor = ChemNOR(genAiApiKey: 'your-api-key');
  final results = await chemNor.findListOfCompounds('carboxylic acid compounds');
  print(results);
}
πŸ“„ View Text Output
ChemNOR Compound Search Results
Generated at: 2025-02-06 13:55:01
Query SMILES patterns: C(=O)O, O=C(O)O, C(=O)C, C(=O)OC, C(=O)CC
====================================================
CID: 284
Name: formic acid
Molecular Formula: CH2O2
SMILES: C(=O)O
Hydrogen Bond Donor: 1
Hydrogen Bond Acceptor: 2
TPSA: 37.3
Complexity: 10.3
--------------------------------------------
CID: 767
Name: carbonic acid
Molecular Formula: CH2O3
SMILES: C(=O)(O)O
Hydrogen Bond Donor: 2
Hydrogen Bond Acceptor: 3
TPSA: 57.5
Complexity: 26.3
--------------------------------------------

For JSON output, use findListOfCompoundsJSN:

final results = await chemNor.findListOfCompoundsJSN('carboxylic acid compounds');
print(results);

Searches PubChem for compounds containing a given SMILES pattern and returns a list of matching compound IDs (CIDs).

final cids = await chemNor.getSubstructureCids('CC');
print(cids); // Output: [6324]

3. πŸ€– AI SMILES Generation #

Uses Gemini AI to suggest relevant SMILES patterns based on a chemical application description.

final smiles = await chemNor.getRelevantSmiles('carboxylic acid compounds');
print(smiles);
// Output: [C(=O)O, CC(=O)O, c1ccccc1C(=O)O, OC(=O)C(=O)O, ...]

4. πŸ“‹ Compound Properties #

Fetches detailed compound properties from PubChem using a CID.

final props = await chemNor.getCompoundProperties('248');
print(props);
// Output: {cid: 248, name: carboxymethyl(trimethyl)ammonium, formula: C5H12NO2+, weight: 118.15, ...}

5. πŸ’¬ AI Chemist #

Chat with an AI chemist specializing in chemistry topics. Uses Gemini AI with chemistry-focused context.

void main() async {
  final chemNor = ChemNOR(genAiApiKey: 'your-api-key');
  final response = await chemNor.Chemist(
    'Please educate me about carboxymethyl(trimethyl)ammonium'
  );
  print(response);
}

The Chemist method focuses on chemistry-related questions. Use the chat method for general-purpose conversation with optional chat history context.


🧰 Additional Modules #

πŸ“ Formula Parser #

Parses chemical formulas into element maps.

final elements = parseFormula('H2SO4');
print(elements); // Output: {H: 2, S: 1, O: 4}

🏷️ IUPAC Naming #

Generates IUPAC names from SMILES notation via PubChem.

final name = await generateIupacName('CCO');
print(name); // Output: ethanol

βš–οΈ Molecular Weight #

Calculates molecular weight from a chemical formula.

final weight = calculateMolecularWeight('H2O');
print('Water molecular weight: $weight g/mol');
// Output: Water molecular weight: 18.01528 g/mol

🌑️ Periodic Table #

Access detailed information about any element.

final oxygen = PeriodicTable.getBySymbol('O');
print('Oxygen: atomic number ${oxygen?.atomicNumber}, mass ${oxygen?.atomicMass}');
// Output: Oxygen: atomic number 8, mass 15.999

final metals = PeriodicTable.getByCategory('transition metal');
print('Number of transition metals: ${metals.length}');
// Output: Number of transition metals: 38

βš—οΈ Reaction Balancer #

Automatically balances chemical equations.

final balanced = ReactionBalancer.balance('H2 + O2 = H2O');
print(balanced); // Output: 2H2 + O2 = 2H2O

πŸ›‘οΈ Safety Data (GHS) #

Retrieves GHS chemical safety classifications and hazard codes.

final safetyInfo = await getSafetyData('acetone');
print('Signal word: ${safetyInfo['signal_word']}');
print('Hazard statements: ${safetyInfo['hazard_statements']}');
// Output:
// Signal word: Danger
// Hazard statements: {H225, H319, H336}

πŸ”— SMILES Parser #

Analyzes SMILES notation to extract structural information.

final structure = parseSmiles('CCO');
print(structure);
// Output: {atomCounts: {C: 2, O: 1}, bondCounts: {single: 2, ...}, rings: 0, ...}

final isValid = isSmilesValid('C1=CC=CC=C1');
print('Is benzene SMILES valid? $isValid'); // Output: true

πŸ“‘ Spectroscopy Simulation #

Simulates NMR, IR, and Mass Spectrometry data from molecular structures.

// Proton NMR
final nmrData = await simulateProtonNmr('CCO');
print(nmrData['summary']);
// Output:
// ΒΉH NMR prediction for ethanol:
// Ξ΄ 0.9 ppm (triplet, 3H) - Methyl group (-CH₃)
// Ξ΄ 3.5 ppm (singlet (broad), 1H) - Hydroxyl group (-OH)
// Ξ΄ 3.6 ppm (quartet, 2H) - CHβ‚‚ adjacent to oxygen

// IR Spectrum
final irData = await simulateIrSpectrum('CCO');
print('IR bands: ${irData['bands'].length}'); // Output: IR bands: 4

πŸ–ΌοΈ Molecular Visualization #

Generates a PubChem URL to visualize a compound from SMILES.

final url = drawMolecule('CCO');
print(url);
// Output: https://pubchem.ncbi.nlm.nih.gov/rest/pug/compound/smiles/CCO/PNG

πŸ”¬ Complete Example #

Combine all modules for a comprehensive chemical analysis pipeline:

import 'package:chem_nor/chem_nor.dart';

void main() async {
  final chemNor = ChemNOR(genAiApiKey: 'your-api-key');

  // 1. Find compounds related to a query
  final compounds = await chemNor.findListOfCompounds('analgesic compounds');

  if (compounds.isNotEmpty) {
    final smiles = 'CC(=O)OC1=CC=CC=C1C(=O)O'; // Aspirin SMILES

    // 2. Get IUPAC name
    final name = await generateIupacName(smiles);

    // 3. Calculate molecular weight
    final formula = 'C9H8O4';
    final weight = calculateMolecularWeight(formula);

    // 4. Get GHS safety information
    final safety = await getSafetyData('aspirin');

    // 5. Simulate NMR spectrum
    final nmrData = await simulateProtonNmr(smiles);

    // 6. Generate visualization
    final visUrl = drawMolecule(smiles);

    // 7. Print comprehensive report
    print('Compound:          $name');
    print('Formula:           $formula');
    print('Molecular Weight:  $weight g/mol');
    print('Safety Signal:     ${safety['signal_word']}');
    print('NMR Summary:       ${nmrData['summary']}');
    print('Visualization:     $visUrl');
  }
}

πŸ“¦ Module Summary #

Module Function Description
πŸ”¬ ChemNOR Core findListOfCompounds AI + PubChem compound search
πŸ”¬ ChemNOR Core findListOfCompoundsJSN JSON-formatted compound search
πŸ”¬ ChemNOR Core getSubstructureCids PubChem substructure search
πŸ”¬ ChemNOR Core getRelevantSmiles AI-generated SMILES suggestions
πŸ”¬ ChemNOR Core getCompoundProperties PubChem compound property lookup
πŸ’¬ Chemist Chemist / chat AI chemistry chatbot
πŸ“ Formula Parser parseFormula Element map from formula
🏷️ IUPAC Naming generateIupacName SMILES β†’ IUPAC name
βš–οΈ Molecular Weight calculateMolecularWeight Formula β†’ molecular weight
🌑️ Periodic Table PeriodicTable.getBySymbol Element data lookup
βš—οΈ Reaction Balancer ReactionBalancer.balance Equation balancing
πŸ›‘οΈ Safety Data getSafetyData GHS hazard information
πŸ”— SMILES Parser parseSmiles / isSmilesValid SMILES structure analysis
πŸ“‘ Spectroscopy simulateProtonNmr / simulateIrSpectrum Spectrum simulation
πŸ–ΌοΈ Visualization drawMolecule PubChem structure image URL

πŸ“„ License #

This project is licensed under the MIT License β€” see the LICENSE file for details.


Made with ❀️ for the chemistry and Dart community.

GitHub

2
likes
160
points
221
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Dart package that finds relevant chemical compounds using AI(Gemini) and PubChem. Use it to level up your chemistry knowledge and chat with your Ai chemist!

Repository (GitHub)
View/report issues

License

BSD-3-Clause (license)

Dependencies

http, intl

More

Packages that depend on chem_nor