# Path: src/python/pipelines/rdkit/sanify_utils.py
# def enumerateStereoIsomers(mol):
#     out = []
#     chiralCentres = Chem.FindMolChiralCenters(mol, includeUnassigned=True)
#     #return the molecule object when no chiral centres where identified
#     if chiralCentres == []:
#         return [mol]
# 
#     #All bit permutations with number of bits equals number of chiralCentres
#     elements = _spam(len(chiralCentres))
# 
#     for isoId,element in enumerate(elements):
#         for centreId,i in enumerate(element):
#             atomId = chiralCentres[centreId][0]
#             if i == 0:
#                 mol.GetAtomWithIdx(atomId).SetChiralTag(Chem.rdchem.ChiralType.CHI_TETRAHEDRAL_CW)
#             elif i == 1:
#                 mol.GetAtomWithIdx(atomId).SetChiralTag(Chem.rdchem.ChiralType.CHI_TETRAHEDRAL_CCW)
#         outmol = copy(mol)
#         utils.log("Enumerated ", Chem.MolToSmiles(mol, isomericSmiles=True))
#         out.append(outmol)
#     return out
# 
# def enumerateTautomers(mol):
#     """
#     Get all of the Tautomers of a given molecule
#     :param mol: the input molecule
#     :return: a list of Tautomers
#     """
#     smiles = Chem.MolToSmiles(mol,isomericSmiles=True)
#     tauts = enumerate_tautomers_smiles(smiles)
#     ##TODO Append Parent molecule name
#     return  [Chem.MolFromSmiles(x) for x in tauts]
# 
# STANDARD_MOL_METHODS = {"molvs": molVsStandardizer, "flatkinson": flatkinsonStandardizer}


import sys, argparse
from pipelines_utils import parameter_utils, utils
from pipelines_utils_rdkit import rdkit_utils
from rdkit import Chem
from rdkit.Chem import AllChem
from .sanify_utils import enumerateStereoIsomers,enumerateTautomers,STANDARD_MOL_METHODS
#!/usr/bin/env python

# Copyright 2019 Informatics Matters Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

### Use MolVS to do tautomer enumeration, stereochemistry enumeration, charge neutralisation.




def write_out(mols,count,writer,mol_format,file_format):
    for mol in mols:
        count += 1
        if mol is None: continue
        if mol_format == 'mol_3d':
            AllChem.EmbedMolecule(mol,AllChem.ETKDG())
            fmt = 'mol'

# Path: src/python/pipelines/rdkit/sanify_utils.py
# def enumerateStereoIsomers(mol):
#     out = []
#     chiralCentres = Chem.FindMolChiralCenters(mol, includeUnassigned=True)
#     #return the molecule object when no chiral centres where identified
#     if chiralCentres == []:
#         return [mol]
# 
#     #All bit permutations with number of bits equals number of chiralCentres
#     elements = _spam(len(chiralCentres))
# 
#     for isoId,element in enumerate(elements):
#         for centreId,i in enumerate(element):
#             atomId = chiralCentres[centreId][0]
#             if i == 0:
#                 mol.GetAtomWithIdx(atomId).SetChiralTag(Chem.rdchem.ChiralType.CHI_TETRAHEDRAL_CW)
#             elif i == 1:
#                 mol.GetAtomWithIdx(atomId).SetChiralTag(Chem.rdchem.ChiralType.CHI_TETRAHEDRAL_CCW)
#         outmol = copy(mol)
#         utils.log("Enumerated ", Chem.MolToSmiles(mol, isomericSmiles=True))
#         out.append(outmol)
#     return out
# 
# def enumerateTautomers(mol):
#     """
#     Get all of the Tautomers of a given molecule
#     :param mol: the input molecule
#     :return: a list of Tautomers
#     """
#     smiles = Chem.MolToSmiles(mol,isomericSmiles=True)
#     tauts = enumerate_tautomers_smiles(smiles)
#     ##TODO Append Parent molecule name
#     return  [Chem.MolFromSmiles(x) for x in tauts]
# 
# STANDARD_MOL_METHODS = {"molvs": molVsStandardizer, "flatkinson": flatkinsonStandardizer}


# Path: src/python/pipelines/rdkit/sanifier.py
import sys, argparse
from pipelines_utils import parameter_utils, utils
from pipelines_utils_rdkit import rdkit_utils
from rdkit import Chem
from rdkit.Chem import AllChem
from .sanify_utils import enumerateStereoIsomers,enumerateTautomers,STANDARD_MOL_METHODS

#!/usr/bin/env python

# Copyright 2019 Informatics Matters Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

### Use MolVS to do tautomer enumeration, stereochemistry enumeration, charge neutralisation.




def write_out(mols,count,writer,mol_format,file_format):
    for mol in mols:
        count += 1
        if mol is None: continue
        if mol_format == 'mol_3d':
            AllChem.EmbedMolecule(mol,AllChem.ETKDG())
            fmt = 'mol'

        elif mol_format == 'mol_2d':