/********************************************************************** * This source code is public domain, and may be freely distributed, * * modified, and used for any purpose. IT COMES WITH ABSOLUTELY NO * * WARRANTY OF ANY KIND. * **********************************************************************/ #include #include #include #include "dt_smiles.h" #include "dt_finger.h" #define TRUE 1 #define FALSE 0 /*************************************************************************** * FUNCTION: du_name2fp * * DESCRIPTION: * Fingerprinting ASCII text. * Function which takes a string of characters and builds a molecule * object. Generates that molecules fingerprint and returns it. * Returns NULL_OB if it cannot create a fingerprint. * * RETURNS: (dt_Handle) a fingerprint object. ***************************************************************************/ dt_Handle du_name2fp(dt_Integer namelen, dt_String namestr, dt_Boolean dofold) { dt_Integer char_count, current_char; dt_Handle mol, atom, fp; dt_Handle last_atom = NULL_OB; /**** Make a new, empty molecule object ****/ if (NULL_OB == (mol = dt_alloc_mol())) return(NULL_OB); dt_mod_on(mol); /**** Loop through each character and add an atom. ****/ for (char_count = 0; char_count < namelen; char_count++) { current_char = (dt_Integer)*(namestr + char_count); /**** If one of the printable characters, add an atom for it ****/ if ((current_char > 47) && (current_char < 123)) { atom = dt_addatom(mol, current_char - 46, 1); dt_setaromatic(atom, FALSE); dt_addbond(last_atom, atom, DX_BTY_SINGLE); last_atom = atom; } /**** If space, don't connect the words ****/ if (current_char == 32) last_atom = NULL_OB; } /**** Make a fingerprint object ****/ fp = dt_fp_fingerprint(mol, dofold); dt_dealloc(mol); return (fp); }