parameters: (orig_smiles, decoded_smiles, output_file=None)
return_statement: return(res_df)
docstring: Compare decoded to original SMILES strings and output a table of Tanimoto distances, along with
      binary flags for whether the strings are the same and whether the decoded string is valid SMILES.
      orig_smiles and decoded_smiles are lists or arrays of strings.
      If an output file name is provided, the table will be written to it as a CSV file.
      Returns the table as a DataFrame.
docstring_summary: Compare decoded to original SMILES strings and output a table of Tanimoto distances, along with
      binary flags for whether the strings are the same and whether the decoded string is valid SMILES.
      orig_smiles and decoded_smiles are lists or arrays of strings.
      If an output file name is provided, the table will be written to it as a CSV file.
      Returns the table as a DataFrame.
docstring_tokens: Compare decoded to original SMILES strings and output a table of Tanimoto distances along with binary flags for whether the strings are the same and whether the decoded string is valid SMILES . orig_smiles and decoded_smiles are lists or arrays of strings . If an output file name is provided the table will be written to it as a CSV file . Returns the table as a DataFrame .
function: def compare_decoded_to_original_smiles(orig_smiles, decoded_smiles, output_file=None):
      """
      Compare decoded to original SMILES strings and output a table of Tanimoto distances, along with
      binary flags for whether the strings are the same and whether the decoded string is valid SMILES.
      orig_smiles and decoded_smiles are lists or arrays of strings.
      If an output file name is provided, the table will be written to it as a CSV file.
      Returns the table as a DataFrame.
  
      """
      res_df = pd.DataFrame(dict(original=orig_smiles, decoded=decoded_smiles))
      is_valid = []
      is_same = []
      tani_dist = []
      accuracy = []
      count = 0
      data_size = len(orig_smiles)
      for row in res_df.itertuples():
          count = count + 1
          #compute char by char accuracy
          hit = 0
          for x, y in zip(row.original, row.decoded):
              if x == y:
                  hit = hit+1
          accuracy.append((hit/len(row.original))*100)
  
          is_same.append(int(row.decoded == row.original))
          orig_mol = Chem.MolFromSmiles(row.original)
          if orig_mol is None:
            #Note, input may be invalid, if original SMILE string is truncated 
            is_valid.append('x')
            tani_dist.append(-1)
            continue
          dec_mol = Chem.MolFromSmiles(row.decoded)
          RDLogger.DisableLog('rdApp.*')
          if dec_mol is None:
              is_valid.append(0)
              tani_dist.append(1)
          else:
              is_valid.append(1)
              orig_fp = AllChem.GetMorganFingerprintAsBitVect(orig_mol, 2, 1024)
              dec_fp = AllChem.GetMorganFingerprintAsBitVect(dec_mol, 2, 1024)
              tani_sim = DataStructs.FingerprintSimilarity(orig_fp, dec_fp, metric=DataStructs.TanimotoSimilarity)
              tani_dist.append(1.0 - tani_sim)
      res_df['is_valid'] = is_valid
      res_df['is_same'] = is_same
      res_df['smile_accuracy'] = accuracy
      res_df['tanimoto_distance'] = tani_dist
      global_acc  = np.mean(np.array(accuracy))
      res_df['total_avg_accuracy'] = [global_acc]*len(accuracy)
      
      print("Mean global accuracy % ", global_acc)
      print("Validity % ", (is_valid.count(1)/data_size)*100)
      print("Same % ", (is_same.count(1)/data_size)*100)
      valid_tani_dist = [ t for t in tani_dist if t >= 0 ] 
      print("Average tanimoto ", np.mean(np.array(valid_tani_dist)))
      
  
      if output_file is not None:
          output_columns = ['original', 'decoded', 'is_valid', 'is_same', 'smile_accuracy','tanimoto_distance','total_avg_accuracy']
          res_df.to_csv(output_file, index=False, columns=output_columns)
      return(res_df)
function_tokens: def compare_decoded_to_original_smiles ( orig_smiles , decoded_smiles , output_file = None ) : res_df = pd . DataFrame ( dict ( original = orig_smiles , decoded = decoded_smiles ) ) is_valid = [ ] is_same = [ ] tani_dist = [ ] accuracy = [ ] count = 0 data_size = len ( orig_smiles ) for row in res_df . itertuples ( ) : count = count + 1 #compute char by char accuracy hit = 0 for x , y in zip ( row . original , row . decoded ) : if x == y : hit = hit + 1 accuracy . append ( ( hit / len ( row . original ) ) * 100 ) is_same . append ( int ( row . decoded == row . original ) ) orig_mol = Chem . MolFromSmiles ( row . original ) if orig_mol is None : #Note, input may be invalid, if original SMILE string is truncated  is_valid . append ( 'x' ) tani_dist . append ( - 1 ) continue dec_mol = Chem . MolFromSmiles ( row . decoded ) RDLogger . DisableLog ( 'rdApp.*' ) if dec_mol is None : is_valid . append ( 0 ) tani_dist . append ( 1 ) else : is_valid . append ( 1 ) orig_fp = AllChem . GetMorganFingerprintAsBitVect ( orig_mol , 2 , 1024 ) dec_fp = AllChem . GetMorganFingerprintAsBitVect ( dec_mol , 2 , 1024 ) tani_sim = DataStructs . FingerprintSimilarity ( orig_fp , dec_fp , metric = DataStructs . TanimotoSimilarity ) tani_dist . append ( 1.0 - tani_sim ) res_df [ 'is_valid' ] = is_valid res_df [ 'is_same' ] = is_same res_df [ 'smile_accuracy' ] = accuracy res_df [ 'tanimoto_distance' ] = tani_dist global_acc = np . mean ( np . array ( accuracy ) ) res_df [ 'total_avg_accuracy' ] = [ global_acc ] * len ( accuracy ) print ( "Mean global accuracy % " , global_acc ) print ( "Validity % " , ( is_valid . count ( 1 ) / data_size ) * 100 ) print ( "Same % " , ( is_same . count ( 1 ) / data_size ) * 100 ) valid_tani_dist = [ t for t in tani_dist if t >= 0 ] print ( "Average tanimoto " , np . mean ( np . array ( valid_tani_dist ) ) ) if output_file is not None : output_columns = [ 'original' , 'decoded' , 'is_valid' , 'is_same' , 'smile_accuracy' , 'tanimoto_distance' , 'total_avg_accuracy' ] res_df . to_csv ( output_file , index = False , columns = output_columns ) return ( res_df )