#!/usr/local/bin/perl # # get_smiles # # Gets the smiles string of the specified compound from one of the specified files # # Arguments: # $name The name of the compound to find the smiles for # *smiles_files The array of smiles files indexed by prefix # *file_prefixes The array of prefixes within the files indexed by the prefix of # the compound name (compound name prefix and the prefix of the # compound name in the file are not necessarily the same). # # Return Values: # The smiles string on success, "?" string on failure # # Modification History: # 08/8/96 - mjc - Original Code # # 09/4/96 - tnd - doesn't get cmpds like "E-", "X-" from SC file # fixed this problem # # 10/6/96 - tjo - use gdbm to directly look up smiles from name. # 1/7/97 - tjo - special case for MFCD (ACD) compound names # use GDBM_File; #@AnyDBM_File::ISA = qw(DB_File GDBM_File NDBM_File); @AnyDBM_File::ISA = qw(GDBM_File); sub get_smiles { local( $name, *smiles_files, *file_prefixes ) = @_; local( $finished, $smi, $cmpd ) = ( 0, "", "" ); # Go through the file specified for the given prefix ($prefix,$id) = split( /-/, $name ); # tjo special case for MFCD (ACD) compound names ($prefix,$id) = ($1,$2) if $name =~ /^(MFCD)(\d*)$/ ; # tnd $filename = $smiles_files{$prefix}; $file_prefix = $file_prefixes{$prefix}; # tnd add the following $filename = $smiles_files{$file_prefix}; if ($filename) { $opensmi = dbmopen(SMILES, $filename, undef); if ($opensmi) { # Find the compound name $smi = $SMILES{$name}; dbmclose(SMILES); if ($smi) { $smi; } else { '?'; } } else { &errorexit( "