SET extra_float_digits=0;
PREPARE dummy AS SELECT rdkit_version();
SET rdkit.ignore_reaction_agents=false;
SET rdkit.agent_FP_bit_ratio=0.2;
SET rdkit.difference_FP_weight_agents=1;
SET rdkit.difference_FP_weight_nonagents=10;
SET rdkit.move_unmmapped_reactants_to_agents=true;
SET rdkit.threshold_unmapped_reactant_atoms=0.2;
SET rdkit.init_reaction=true;
SELECT reaction_from_smiles('c1ccccc1>>c1cccnc1');
 reaction_from_smiles 
----------------------
 c1ccccc1>>c1ccncc1
(1 row)

SELECT reaction_from_smiles('c1ccccc1>CC(=O)O>c1cccnc1');
   reaction_from_smiles    
---------------------------
 c1ccccc1>CC(=O)O>c1ccncc1
(1 row)

SELECT reaction_from_smarts('[c1:1][c:2][c:3][c:4]c[c1:5]>CC(=O)O>[c1:1][c:2][c:3][c:4]n[c1:5]');
                       reaction_from_smarts                        
-------------------------------------------------------------------
 c([c:4][c:3][c:2][c:1])[c:5]>CC(O)=O>n([c:4][c:3][c:2][c:1])[c:5]
(1 row)

SELECT reaction_from_smarts('C(F)(F)F.[c1:1][c:2][c:3][c:4]c[c1:5]>CC(=O)O>[c1:1][c:2][c:3][c:4]n[c1:5]');
                           reaction_from_smarts                           
--------------------------------------------------------------------------
 c([c:4][c:3][c:2][c:1])[c:5]>CC(O)=O.FC(F)F>n([c:4][c:3][c:2][c:1])[c:5]
(1 row)

SELECT reaction_from_smarts('c1ccc[n,c]c1>>c1nccnc1');
 reaction_from_smarts 
----------------------
 *1ccccc1>>c1cnccn1
(1 row)

SELECT reaction_to_smiles(reaction_from_smiles('c1ccccc1>>c1cccnc1'));
 reaction_to_smiles 
--------------------
 c1ccccc1>>c1ccncc1
(1 row)

SELECT reaction_to_smiles(reaction_from_smarts('c1ccc[n,c]c1>>c1nccnc1'));
 reaction_to_smiles 
--------------------
 *1ccccc1>>c1cnccn1
(1 row)

SELECT reaction_to_smarts(reaction_from_smarts('c1ccc[n,c]c1>>c1nccnc1'));
   reaction_to_smarts   
------------------------
 c1ccc[n,c]c1>>c1nccnc1
(1 row)

SELECT reaction_to_smarts('c1cccnc1>>c1nccnc1'::reaction);
                         reaction_to_smarts                         
--------------------------------------------------------------------
 [#6]1:[#6]:[#6]:[#6]:[#7]:[#6]:1>>[#6]1:[#7]:[#6]:[#6]:[#7]:[#6]:1
(1 row)

SELECT reaction_to_ctab(reaction_from_smiles('c1ccccc1>>c1cccnc1'));
                           reaction_to_ctab                            
-----------------------------------------------------------------------
 $RXN                                                                 +
                                                                      +
       RDKit                                                          +
                                                                      +
   1  1                                                               +
 $MOL                                                                 +
                                                                      +
      RDKit          2D                                               +
                                                                      +
   6  6  0  0  0  0  0  0  0  0999 V2000                              +
     1.5000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
     0.7500   -1.2990    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
    -0.7500   -1.2990    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
    -1.5000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
    -0.7500    1.2990    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
     0.7500    1.2990    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
   1  2  4  0                                                         +
   2  3  4  0                                                         +
   3  4  4  0                                                         +
   4  5  4  0                                                         +
   5  6  4  0                                                         +
   6  1  4  0                                                         +
 M  END                                                               +
 $MOL                                                                 +
                                                                      +
      RDKit          2D                                               +
                                                                      +
   6  6  0  0  0  0  0  0  0  0999 V2000                              +
     1.5000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
     0.7500   -1.2990    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
    -0.7500   -1.2990    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
    -1.5000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
    -0.7500    1.2990    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0+
     0.7500    1.2990    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0+
   1  2  4  0                                                         +
   2  3  4  0                                                         +
   3  4  4  0                                                         +
   4  5  4  0                                                         +
   5  6  4  0                                                         +
   6  1  4  0                                                         +
 M  END                                                               +
 
(1 row)

SELECT reaction_numreactants(reaction_from_smiles('[Cl].c1ccccc1>>c1cccnc1.[OH2]'));
 reaction_numreactants 
-----------------------
                     2
(1 row)

SELECT reaction_numproducts(reaction_from_smiles('[Cl].c1ccccc1>>c1cccnc1.[OH2]'));
 reaction_numproducts 
----------------------
                    2
(1 row)

SELECT reaction_numagents(reaction_from_smiles('[Cl].c1ccccc1>CC(=O)O.[Na+]>c1cccnc1.[OH2]'));
 reaction_numagents 
--------------------
                  2
(1 row)

SELECT reaction_numagents(reaction_from_smarts('C(F)(F)F.[c1:1][c:2][c:3][c:4]c[c1:5]>CC(=O)O>[c1:1][c:2][c:3][c:4]n[c1:5]'));
 reaction_numagents 
--------------------
                  2
(1 row)

SET rdkit.move_unmmapped_reactants_to_agents=false;
SELECT reaction_numagents(reaction_from_smarts('C(F)(F)F.[c1:1][c:2][c:3][c:4]c[c1:5]>CC(=O)O>[c1:1][c:2][c:3][c:4]n[c1:5]'));
 reaction_numagents 
--------------------
                  1
(1 row)

SET rdkit.move_unmmapped_reactants_to_agents=true;
SET rdkit.threshold_unmapped_reactant_atoms=0.9;
SELECT reaction_numagents(reaction_from_smarts('C(F)(F)F.[c1:1][c:2][c:3][c:4]c[c1:5]>CC(=O)O>[c1:1][c:2][c:3][c:4]n[c1:5]'));
 reaction_numagents 
--------------------
                  3
(1 row)

SET rdkit.threshold_unmapped_reactant_atoms=0.2;
SELECT 'c1ccccc1>>c1cccnc1'::reaction @= 'c1ccccc1>>c1cccnc1'::reaction;
 ?column? 
----------
 t
(1 row)

SELECT 'c1ccccc1>>c1cccnc1'::reaction @= 'c1ccccc1>>c1cncnc1'::reaction;
 ?column? 
----------
 f
(1 row)

SELECT reaction_from_ctab('$RXN                                                                 
                                                                     
      RDKit                                                          
                                                                     
  1  1                                                               
$MOL                                                                 
                                                                     
     RDKit                                                           
                                                                     
  6  6  0  0  0  0  0  0  0  0999 V2000                              
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  4  0                                                         
  2  3  4  0                                                         
  3  4  4  0                                                         
  4  5  4  0                                                         
  5  6  4  0                                                         
  6  1  4  0                                                         
M  END                                                               
$MOL                                                                 
                                                                     
     RDKit                                                           
                                                                     
  6  6  0  0  0  0  0  0  0  0999 V2000                              
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 N   0  0  0  0  0  0  0  0  0  0  0  0
    0.0000    0.0000    0.0000 C   0  0  0  0  0  0  0  0  0  0  0  0
  1  2  4  0                                                         
  2  3  4  0                                                         
  3  4  4  0                                                         
  4  5  4  0                                                         
  5  6  4  0                                                         
  6  1  4  0                                                         
M  END');
       reaction_from_ctab       
--------------------------------
 C1:C:C:C:C:C:1>>C1:C:C:N:C:C:1
(1 row)

CREATE TABLE tmp (id integer, tmprxn text);
\copy tmp from 'data/reaction_test_data.out.rsmi';
select * into pgreactions from (select id,reaction_from_smiles(tmprxn::cstring) rxn from tmp) as r where r is not null;
SET rdkit.move_unmmapped_reactants_to_agents=false;
select * into pgreactions_unchanged from (select id,reaction_from_smiles(tmprxn::cstring) rxn from tmp) as r where r is not null;
DROP table tmp;
SET rdkit.move_unmmapped_reactants_to_agents=true;
SELECT count(*) FROM pgreactions;
 count 
-------
  1000
(1 row)

SELECT count(*) FROM pgreactions_unchanged;
 count 
-------
  1000
(1 row)

SELECT SUM(reaction_numreactants(rxn)) FROM pgreactions;
 sum  
------
 1898
(1 row)

SELECT SUM(reaction_numreactants(rxn)) FROM pgreactions_unchanged;
 sum  
------
 3517
(1 row)

SELECT SUM(reaction_numproducts(rxn)) FROM pgreactions;
 sum  
------
 1157
(1 row)

SELECT SUM(reaction_numproducts(rxn)) FROM pgreactions_unchanged;
 sum  
------
 1157
(1 row)

SELECT SUM(reaction_numagents(rxn)) FROM pgreactions;
 sum  
------
 2528
(1 row)

SELECT SUM(reaction_numagents(rxn)) FROM pgreactions_unchanged;
 sum 
-----
 909
(1 row)

CREATE INDEX rxnidx ON pgreactions USING gist(rxn);
SET enable_indexscan=off;
SET enable_bitmapscan=off;
SET enable_seqscan=on;
SELECT count(*) FROM pgreactions WHERE rxn@>'c1ccccc1>>c1ccncc1';
 count 
-------
    47
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn@>'c1cnccc1>>c1ccccc1';
 count 
-------
    50
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1ccccc1>>c1ccncc1'<@rxn;
 count 
-------
    47
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1cnccc1>>c1ccccc1'<@rxn;
 count 
-------
    50
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn@>'c1ccccc1>>';
 count 
-------
   667
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn@>'c1cnccc1>>';
 count 
-------
    83
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1ccccc1>>'<@rxn;
 count 
-------
   667
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1cnccc1>>'<@rxn;
 count 
-------
    83
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn@>'>>c1ccncc1';
 count 
-------
    79
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn@>'>>c1ccccc1';
 count 
-------
   650
(1 row)

SELECT count(*) FROM pgreactions WHERE '>>c1ccncc1'<@rxn;
 count 
-------
    79
(1 row)

SELECT count(*) FROM pgreactions WHERE '>>c1ccccc1'<@rxn;
 count 
-------
   650
(1 row)

SET enable_indexscan=on;
SET enable_bitmapscan=on;
SET enable_seqscan=off;
SELECT count(*) FROM pgreactions WHERE rxn@>'c1ccccc1>>c1ccncc1';
 count 
-------
    47
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn@>'c1cnccc1>>c1ccccc1';
 count 
-------
    50
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1ccccc1>>c1ccncc1'<@rxn;
 count 
-------
    47
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1cnccc1>>c1ccccc1'<@rxn;
 count 
-------
    50
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn@>'c1ccccc1>>';
 count 
-------
   667
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn@>'c1cnccc1>>';
 count 
-------
    83
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1ccccc1>>'<@rxn;
 count 
-------
   667
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1cnccc1>>'<@rxn;
 count 
-------
    83
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn@>'>>c1ccncc1';
 count 
-------
    79
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn@>'>>c1ccccc1';
 count 
-------
   650
(1 row)

SELECT count(*) FROM pgreactions WHERE '>>c1ccncc1'<@rxn;
 count 
-------
    79
(1 row)

SELECT count(*) FROM pgreactions WHERE '>>c1ccccc1'<@rxn;
 count 
-------
   650
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn?>'c1ccccc1>>c1ccncc1';
 count 
-------
    47
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn?>'c1cnccc1>>c1ccccc1';
 count 
-------
    50
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1ccccc1>>c1ccncc1'?<rxn;
 count 
-------
    47
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1cnccc1>>c1ccccc1'?<rxn;
 count 
-------
    50
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn?>'c1ccccc1>>';
 count 
-------
   667
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn?>'c1cnccc1>>';
 count 
-------
    83
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1ccccc1>>'?<rxn;
 count 
-------
   667
(1 row)

SELECT count(*) FROM pgreactions WHERE 'c1cnccc1>>'?<rxn;
 count 
-------
    83
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn?>'>>c1ccncc1';
 count 
-------
    79
(1 row)

SELECT count(*) FROM pgreactions WHERE rxn?>'>>c1ccccc1';
 count 
-------
   650
(1 row)

SELECT count(*) FROM pgreactions WHERE '>>c1ccncc1'?<rxn;
 count 
-------
    79
(1 row)

SELECT count(*) FROM pgreactions WHERE '>>c1ccccc1'?<rxn;
 count 
-------
   650
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',1), reaction_difference_fp('c1ccccc1>>c1ccncc1',1));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',1), reaction_difference_fp('c1ncccc1>>c1ncncc1',1));
   tanimoto_sml    
-------------------
 0.636363636363636
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1), reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1), reaction_difference_fp('c1ncccc1>[Na+]>c1ncncc1',1));
   tanimoto_sml    
-------------------
 0.603448275862069
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',2), reaction_difference_fp('c1ccccc1>>c1ccncc1',2));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',2), reaction_difference_fp('c1ncccc1>>c1ncncc1',2));
 tanimoto_sml 
--------------
          0.2
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2), reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2), reaction_difference_fp('c1ncccc1>[Na+]>c1ncncc1',2));
 tanimoto_sml 
--------------
          0.2
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',3), reaction_difference_fp('c1ccccc1>>c1ccncc1',3));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',3), reaction_difference_fp('c1ncccc1>>c1ncncc1',3));
   tanimoto_sml    
-------------------
 0.454545454545455
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3), reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3), reaction_difference_fp('c1ncccc1>[Na+]>c1ncncc1',3));
   tanimoto_sml    
-------------------
 0.444933920704846
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',1), reaction_structural_bfp('c1ccccc1>>c1ccncc1',1));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',1), reaction_structural_bfp('c1ncccc1>>c1ncncc1',1));
   tanimoto_sml    
-------------------
 0.620689655172414
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',1));
   tanimoto_sml    
-------------------
 0.514285714285714
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',2), reaction_structural_bfp('c1ccccc1>>c1ccncc1',2));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',2), reaction_structural_bfp('c1ncccc1>>c1ncncc1',2));
 tanimoto_sml 
--------------
          0.4
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',2));
 tanimoto_sml 
--------------
          0.4
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',3), reaction_structural_bfp('c1ccccc1>>c1ccncc1',3));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',3), reaction_structural_bfp('c1ncccc1>>c1ncncc1',3));
   tanimoto_sml    
-------------------
 0.409090909090909
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',3));
   tanimoto_sml   
------------------
 0.32258064516129
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',4), reaction_structural_bfp('c1ccccc1>>c1ccncc1',4));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',4), reaction_structural_bfp('c1ncccc1>>c1ncncc1',4));
   tanimoto_sml   
------------------
 0.27710843373494
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',4), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',4));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',4), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',4));
   tanimoto_sml    
-------------------
 0.237113402061856
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',5), reaction_structural_bfp('c1ccccc1>>c1ccncc1',5));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',5), reaction_structural_bfp('c1ncccc1>>c1ncncc1',5));
   tanimoto_sml    
-------------------
 0.793388429752066
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',5), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',5));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',5), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',5));
   tanimoto_sml    
-------------------
 0.604938271604938
(1 row)

SET rdkit.agent_FP_bit_ratio=0.5;
SET rdkit.difference_FP_weight_agents=-3;
SET rdkit.difference_FP_weight_nonagents=7;
SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',1), reaction_difference_fp('c1ccccc1>>c1ccncc1',1));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',1), reaction_difference_fp('c1ncccc1>>c1ncncc1',1));
   tanimoto_sml    
-------------------
 0.636363636363636
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1), reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1), reaction_difference_fp('c1ncccc1>[Na+]>c1ncncc1',1));
   tanimoto_sml    
-------------------
 0.515789473684211
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',2), reaction_difference_fp('c1ccccc1>>c1ccncc1',2));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',2), reaction_difference_fp('c1ncccc1>>c1ncncc1',2));
 tanimoto_sml 
--------------
          0.2
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2), reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2), reaction_difference_fp('c1ncccc1>[Na+]>c1ncncc1',2));
 tanimoto_sml 
--------------
          0.2
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',3), reaction_difference_fp('c1ccccc1>>c1ccncc1',3));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',3), reaction_difference_fp('c1ncccc1>>c1ncncc1',3));
   tanimoto_sml    
-------------------
 0.454545454545455
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3), reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3), reaction_difference_fp('c1ncccc1>[Na+]>c1ncncc1',3));
   tanimoto_sml    
-------------------
 0.403314917127072
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',1), reaction_structural_bfp('c1ccccc1>>c1ccncc1',1));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',1), reaction_structural_bfp('c1ncccc1>>c1ncncc1',1));
   tanimoto_sml    
-------------------
 0.620689655172414
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',1));
   tanimoto_sml    
-------------------
 0.514285714285714
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',2), reaction_structural_bfp('c1ccccc1>>c1ccncc1',2));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',2), reaction_structural_bfp('c1ncccc1>>c1ncncc1',2));
 tanimoto_sml 
--------------
          0.4
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',2), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',2));
 tanimoto_sml 
--------------
          0.4
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',3), reaction_structural_bfp('c1ccccc1>>c1ccncc1',3));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',3), reaction_structural_bfp('c1ncccc1>>c1ncncc1',3));
   tanimoto_sml    
-------------------
 0.428571428571429
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',3), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',3));
   tanimoto_sml    
-------------------
 0.344827586206897
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',4), reaction_structural_bfp('c1ccccc1>>c1ccncc1',4));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',4), reaction_structural_bfp('c1ncccc1>>c1ncncc1',4));
   tanimoto_sml    
-------------------
 0.285714285714286
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',4), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',4));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',4), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',4));
   tanimoto_sml    
-------------------
 0.244897959183673
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',5), reaction_structural_bfp('c1ccccc1>>c1ccncc1',5));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',5), reaction_structural_bfp('c1ncccc1>>c1ncncc1',5));
 tanimoto_sml 
--------------
          0.8
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',5), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',5));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',5), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',5));
   tanimoto_sml    
-------------------
 0.608695652173913
(1 row)

SET rdkit.ignore_reaction_agents=true;
SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',1), reaction_difference_fp('c1ccccc1>>c1ccncc1',1));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>>c1ccncc1',1), reaction_difference_fp('c1ncccc1>>c1ncncc1',1));
   tanimoto_sml    
-------------------
 0.636363636363636
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1), reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_difference_fp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',1), reaction_difference_fp('c1ncccc1>[Na+]>c1ncncc1',1));
   tanimoto_sml    
-------------------
 0.636363636363636
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',5), reaction_structural_bfp('c1ccccc1>>c1ccncc1',5));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>>c1ccncc1',5), reaction_structural_bfp('c1ncccc1>>c1ncncc1',5));
 tanimoto_sml 
--------------
          0.8
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',5), reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',5));
 tanimoto_sml 
--------------
            1
(1 row)

SELECT tanimoto_sml(reaction_structural_bfp('c1ccccc1>CC(=O)O.[Na+]>c1ccncc1',5), reaction_structural_bfp('c1ncccc1>[Na+]>c1ncncc1',5));
 tanimoto_sml 
--------------
          0.8
(1 row)

SELECT substring(reaction_to_svg('[C:1][O:2].[C:3][C:4]>>[C:1][O:2][C:3][C:4]'::reaction)::text,1,120) svg;
                     svg                     
---------------------------------------------
 <?xml version='1.0' encoding='iso-8859-1'?>+
 <svg version='1.1' baseProfile='full'      +
               xmlns='http://www.w3.org
(1 row)

SELECT substring(reaction_to_svg('[C:1][O:2].[C:3][C:4]>>[C:1][O:2][C:3][C:4]'::reaction, true)::text,1,120) svg;
                     svg                     
---------------------------------------------
 <?xml version='1.0' encoding='iso-8859-1'?>+
 <svg version='1.1' baseProfile='full'      +
               xmlns='http://www.w3.org
(1 row)

SET enable_indexscan=on;
SET enable_bitmapscan=on;
SET enable_seqscan=on;
DROP INDEX rxnidx;
