SET extra_float_digits=0;
SELECT mol_amw('c1ccccc1'::mol) mol_amw;
 mol_amw 
---------
  78.114
(1 row)

SELECT mol_exactmw('c1ccccc1'::mol) mol_exactmw;
 mol_exactmw 
-------------
      78.047
(1 row)

SELECT mol_logp('c1ccccc1'::mol) mol_logp;
 mol_logp 
----------
   1.6866
(1 row)

SELECT mol_hba('c1ccccc1'::mol) mol_hba;
 mol_hba 
---------
       0
(1 row)

SELECT mol_hbd('c1ccccc1'::mol) mol_hbd;
 mol_hbd 
---------
       0
(1 row)

SELECT mol_hba('c1ccncc1'::mol) mol_hba;
 mol_hba 
---------
       1
(1 row)

SELECT mol_hbd('c1ccncc1'::mol) mol_hbd;
 mol_hbd 
---------
       0
(1 row)

SELECT mol_hbd('c1ccncc1O'::mol) mol_hbd;
 mol_hbd 
---------
       1
(1 row)

SELECT mol_hba('c1ccncc1O'::mol) mol_hba;
 mol_hba 
---------
       2
(1 row)

SELECT mol_logp('c1ccncc1O'::mol) mol_logp;
 mol_logp 
----------
   0.7872
(1 row)

SELECT mol_chi0n('c1ccccc1O'::mol) v;
    v    
---------
 3.83396
(1 row)

SELECT mol_chi1n('c1ccccc1O'::mol) v;
    v    
---------
 2.13429
(1 row)

SELECT mol_chi2n('c1ccccc1O'::mol) v;
    v    
---------
 1.33555
(1 row)

SELECT mol_chi3n('c1ccccc1O'::mol) v;
    v     
----------
 0.756194
(1 row)

SELECT mol_chi4n('c1ccccc1O'::mol) v;
    v     
----------
 0.427994
(1 row)

SELECT mol_chi0v('c1ccccc1O'::mol) v;
    v    
---------
 3.83396
(1 row)

SELECT mol_chi1v('c1ccccc1O'::mol) v;
    v    
---------
 2.13429
(1 row)

SELECT mol_chi2v('c1ccccc1O'::mol) v;
    v    
---------
 1.33555
(1 row)

SELECT mol_chi3v('c1ccccc1O'::mol) v;
    v     
----------
 0.756194
(1 row)

SELECT mol_chi4v('c1ccccc1O'::mol) v;
    v     
----------
 0.427994
(1 row)

SELECT mol_kappa1('C12CC2C3CC13'::mol) v;
    v    
---------
 2.34375
(1 row)

SELECT mol_kappa2('CC(C)C1CCC(C)CCC1'::mol) v;
    v    
---------
 4.13265
(1 row)

SELECT mol_kappa3('CC(C)C1CCC(C)CCC1'::mol) v;
    v    
---------
 2.84444
(1 row)

SELECT mol_numspiroatoms('C1CCC2(C1)CC1CCC2CC1'::mol) v;
 v 
---
 1
(1 row)

SELECT mol_numbridgeheadatoms('C1CCC2(C1)CC1CCC2CC1'::mol) v;
 v 
---
 2
(1 row)

SELECT mol_numspiroatoms('CC1(C)CC2(C)CCC1(C)CC2'::mol) v;
 v 
---
 0
(1 row)

SELECT mol_numbridgeheadatoms('CC1(C)CC2(C)CCC1(C)CC2'::mol) v;
 v 
---
 2
(1 row)

SELECT mol_phi('CC(C)(C)C(C)C'::mol) v;
    v    
---------
 1.85185
(1 row)

SELECT mol_hallkieralpha('CC(O)(C)C(C)C'::mol) v;
   v   
-------
 -0.04
(1 row)

SELECT mol_numamidebonds('O=C(C)NC'::mol) v;
 v 
---
 1
(1 row)

-- Mol formula tests - SQL equivalents of tests in testMolDescriptors.py.
select mol_formula('[2H]C([3H])O'::mol);
 mol_formula 
-------------
 CH4O
(1 row)

                                     -- separateIsotopes = true
select mol_formula('[2H]C([3H])O'::mol, true);
 mol_formula 
-------------
 CH2DTO
(1 row)

                                           -- abbreviateHIsotopes = false
select mol_formula('[2H]C([3H])O'::mol, true, false);
 mol_formula  
--------------
 CH2[2H][3H]O
(1 row)

       --
select mol_formula('[2H][13CH2]CO'::mol);
 mol_formula 
-------------
 C2H6O
(1 row)

select mol_formula('[2H][13CH2]CO'::mol, true);
 mol_formula 
-------------
 C[13C]H5DO
(1 row)

select mol_formula('[2H][13CH2]CO'::mol, true, false);
  mol_formula  
---------------
 C[13C]H5[2H]O
(1 row)

--
SELECT mol_numrotatablebonds('CCC'::mol) mol_numrotatablebonds;
 mol_numrotatablebonds 
-----------------------
                     0
(1 row)

SELECT mol_numrotatablebonds('CCCC'::mol) mol_numrotatablebonds;
 mol_numrotatablebonds 
-----------------------
                     1
(1 row)

-- mol_from_smiles() shouldn't be necessary, but there's an RDKit bug (#5104)
SELECT mol_numrotatablebonds(mol_from_smiles('c1ccccc1c1ccc(CCC)cc1')) mol_numrotatablebonds;
 mol_numrotatablebonds 
-----------------------
                     3
(1 row)

SELECT mol_numheavyatoms('CCC'::mol) val;
 val 
-----
   3
(1 row)

SELECT mol_numatoms('CCC'::mol) val;
 val 
-----
  11
(1 row)

SELECT mol_numheteroatoms('CCC'::mol) val;
 val 
-----
   0
(1 row)

SELECT mol_numheteroatoms('CCO'::mol) val;
 val 
-----
   1
(1 row)

SELECT mol_tpsa('CCC'::mol) val;
 val 
-----
   0
(1 row)

SELECT mol_tpsa('CCO'::mol) val;
  val  
-------
 20.23
(1 row)

SELECT mol_labuteasa('CCC'::mol) val;
   val   
---------
 21.4691
(1 row)

SELECT mol_numrings('CCC'::mol) val;
 val 
-----
   0
(1 row)

SELECT mol_numrings('C1CC1'::mol) val;
 val 
-----
   1
(1 row)

SELECT mol_murckoscaffold('c1ccccc1CCC'::mol) val;
   val    
----------
 c1ccccc1
(1 row)

SELECT mol_murckoscaffold('CSC(C)=O'::mol) is NULL;
 ?column? 
----------
 t
(1 row)

SELECT substring(mol_to_svg('CCO'::mol)::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(mol_to_svg('CCO'::mol,'legend')::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 mol_to_svg('CCO'::mol,'legend',250,200,
  '{"atomLabels":{"1":"foo"},"legendColour":[0.5,0.5,0.5]}')::text like '%fill=''#7F7F7F''%' svg;
 svg 
-----
 t
(1 row)

SELECT substring(mol_to_svg('CCO'::qmol)::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)

-- GitHub Issue 2174 - mol_to_svg() should not change input mol.
/**
  Check that mol_to_svg() does not change the_mol.
  In previous versions, the atom+bond count would
  change from '10 11' in "before_mol" to '11 12'
  in "after_mol", due to mol_to_svg()'s call to
  MolDraw2DUtils::prepareMolForDrawing().
**/
with t as (
  select 'C[C@H]1CC[C@H]2CCCCC12'::mol as the_mol
)
select
    substring(mol_to_ctab(the_mol)::text, 1, 65) as before_mol
  , substring(mol_to_svg(the_mol)::text, 1, 20) as the_svg
  , substring(mol_to_ctab(the_mol)::text, 1, 65) as after_mol
  from t;
               before_mol                |       the_svg        |                after_mol                
-----------------------------------------+----------------------+-----------------------------------------
                                        +| <?xml version='1.0'  |                                        +
      RDKit          2D                 +|                      |      RDKit          2D                 +
                                        +|                      |                                        +
  10 11  0  0  0  0  0  0  0  0999 V2000+|                      |  10 11  0  0  0  0  0  0  0  0999 V2000+
                                         |                      | 
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol);
 mol_nm_hash 
-------------
 ***1*****1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'AnonymousGraph');
 mol_nm_hash 
-------------
 ***1*****1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'ElementGraph');
 mol_nm_hash 
-------------
 OCC1CCCCN1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'CanonicalSmiles');
 mol_nm_hash 
-------------
 OCc1ccccn1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'MurckoScaffold');
 mol_nm_hash 
-------------
 c1ccncc1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'ExtendedMurcko');
 mol_nm_hash 
-------------
 *c1ccccn1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'MolFormula');
 mol_nm_hash 
-------------
 C6H7NO
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'AtomBondCounts');
 mol_nm_hash 
-------------
 8,8
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'DegreeVector');
 mol_nm_hash 
-------------
 0,1,6,1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'Mesomer');
         mol_nm_hash          
------------------------------
 OC[C]1[CH][CH][CH][CH][N]1_0
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'HetAtomTautomer');
           mol_nm_hash            
----------------------------------
 [O]C[C]1[CH][CH][CH][CH][N]1_1_0
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'HetAtomProtomer');
          mol_nm_hash           
--------------------------------
 [O]C[C]1[CH][CH][CH][CH][N]1_1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'RedoxPair');
        mol_nm_hash         
----------------------------
 OC[C]1[CH][CH][CH][CH][N]1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'Regioisomer');
  mol_nm_hash   
----------------
 *C.*O.c1ccncc1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'NetCharge');
 mol_nm_hash 
-------------
 0
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'SmallWorldIndexBR');
 mol_nm_hash 
-------------
 B8R1
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'SmallWorldIndexBRL');
 mol_nm_hash 
-------------
 B8R1L6
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'ArthorSubstructureOrder');
          mol_nm_hash           
--------------------------------
 000800080100060002000033000000
(1 row)

select mol_nm_hash('c1cccnc1CO'::mol,'BogusValue');
WARNING:  computeNMMolHash: hash BogusValue not recognized, using AnonymousGraph
 mol_nm_hash 
-------------
 ***1*****1
(1 row)

