A comprehensive cheminformatics library for processing SMILES notations, analyzing molecular structures, calculating chemical properties, and comparing molecular similarity.
test {
// Validate SMILES string
let is_valid = validate_smiles("C=C(C)O") // true
assert_eq(is_valid, true)
}test {
// Normalization
let normalized_result = normalize_smiles("C = C ( C ) O") // returns Result[String, String]
let normalized = normalized_result.unwrap() // or use match if .unwrap() is not available
assert_eq(normalized, "C=C(C)O")
}test {
// Parse into molecular structure
let molecule = parse_smiles("CCO") // ethanol
assert_eq(molecule.atoms.length(), 3)
}test {
// Generate canonical SMILES
let molecule = parse_smiles("CCO")
let canonical = generate_canonical_smiles(molecule)
assert_eq(canonical, "CCO")
}test {
// Calculate molecular weight
let molecule = parse_smiles("CCO")
let mol_weight = calculate_molecular_weight(molecule) // ~46.07 g/mol
assert_eq(mol_weight > 46.0 && mol_weight < 46.1, true)
}test {
// Calculate LogP value (partition coefficient)
let molecule = parse_smiles("CCO")
let logp = calculate_logp(molecule) // negative value indicates hydrophilicity
assert_eq(logp < 0.0, true)
}test {
// Check drug-likeness
let molecule = parse_smiles("CCO")
let (passes_lipinski, _) = check_lipinski_rule_of_five(molecule)
assert_eq(passes_lipinski, true)
}test {
// Count rotatable bonds
let molecule = parse_smiles("CCO")
let rotatable_bonds = count_rotatable_bonds(molecule)
assert_eq(rotatable_bonds, 1)
}test {
// Find all rings
let molecule = parse_smiles("c1ccccc1") // benzene
let rings = find_all_rings(molecule)
assert_eq(rings.length(), 1)
}test {
// Identify aromatic rings
let molecule = parse_smiles("c1ccccc1") // benzene
let aromatic_rings = identify_aromatic_rings(molecule)
assert_eq(aromatic_rings.length(), 1)
}test {
// Check for specific substructures
let molecule = parse_smiles("CCO")
let has_hydroxyl = contains_substructure(molecule, "O") // check for hydroxyl group
assert_eq(has_hydroxyl, true)
}test {
// Calculate similarity between two molecules
let mol1 = parse_smiles("CCO")
let mol2 = parse_smiles("CCC")
let similarity = calculate_similarity(mol1, mol2)
assert_eq(similarity > 0.4, true)
}test {
// Calculate similarity directly from SMILES
let smiles_similarity = calculate_smiles_similarity("CCO", "CCC")
assert_eq(smiles_similarity > 0.4, true)
}pub(all) struct Bond {
atom1 : Int
atom2 : Int
bond_type : String
}fn count_atoms(smiles : String) -> Intfn get_normal_valence(symbol : String) -> Intfn has_balanced_parentheses(smiles : String) -> Boolfn normalize_smiles(smiles : String) -> Result[String, String]fn remove_whitespace(smiles : String) -> Stringfn validate_smiles(smiles : String) -> BoolInstall
Download zipA comprehensive cheminformatics library for processing SMILES notations, analyzing molecular structures, calculating chemical properties, and comparing molecular similarity.