<commit_before># Python 3
import common
import sys
sys.path.append(r"C:\Program Files (x86)\PerkinElmerInformatics\ChemOffice2016\ChemScript\Lib")
import ChemScript16 as cs

mol = cs.StructureData.LoadData("c1ccccc1")
op = cs.NormOptions()

op.AnonList = False
op.Azide = False
op.CleaveIntoSalts = False
op.CreatedDelRep_1 = False
op.CreatedDelRep_2 = False
op.CollapseZwitterion = False
op.Dative = False
op.DativeToDouble = False
op.Dekekulize = True
op.Delrep = False
op.Diazo_a = False
op.Diazo_b = False
op.FeaturelessHydrogens = False
op.Isonitrile_fg = False
op.MergeCharges = False
op.MergeMetalSalts = False
op.MoveChargeFromCarbon = False
op.NeutralDiazo_fg = False
op.RemoveIsotopy = False
op.RemoveLabel = False
op.RemoveNonGraphStereo = False
op.RemoveRTable = False
op.RemoveRxnCenters = False
op.RemoveTextAtoms = False
op.RemoveValence = False
op.RemoveWedge = False
op.StripEitherDoubleBond = False
op.StripEitherSingleBond = False
op.R3NO_b = False
op.ProvideMissingCoords = False
op.Thiazole = False
op.XMinusToX_fg = False
op.ExpandStoichiometry = False
op.ConsolidateStoichiometry = False

print(op) # Prints out the values of the options

class MyHydrogenCounter(common.HydrogenCounter):
    def getoutput(self, smi):
        mol = cs.StructureData.LoadData(smi)
        if mol is None:
            return None, "Parse_error"
        mol.NormalizeStructure(op)
        writer = cs.SDFileWriter.OpenFile("tmp.sdf", cs.OverWrite)
        writer = cs.SDFileWriter.OpenFile("tmp.sdf", cs.OverWrite)
        writer.WriteStructure(mol)
        writer.Close()
        with open("tmp.sdf", "r") as f:
            molfile = f.read()
        return None, "MOLFILE:%s" % molfile.replace("\n", "!!")

if __name__ == "__main__":
    myname = "ChemDraw_16.0"
    # MyHydrogenCounter(myname).main()<commit_msg>Update ChemDraw script to directly count the number of hydrogens rather than relying on the incorrect MOL file output.<commit_after># Python 3
import common
import sys
sys.path.append(r"C:\Program Files (x86)\PerkinElmerInformatics\ChemOffice2016\ChemScript\Lib")
import ChemScript16 as cs

op = cs.NormOptions()

op.AnonList = False
op.Azide = False
op.CleaveIntoSalts = False
op.CreatedDelRep_1 = False
op.CreatedDelRep_2 = False
op.CollapseZwitterion = False
op.Dative = False
op.DativeToDouble = False
op.Dekekulize = True
op.Delrep = False
op.Diazo_a = False
op.Diazo_b = False
op.FeaturelessHydrogens = False
op.Isonitrile_fg = False
op.MergeCharges = False
op.MergeMetalSalts = False
op.MoveChargeFromCarbon = False
op.NeutralDiazo_fg = False
op.RemoveIsotopy = False
op.RemoveLabel = False
op.RemoveNonGraphStereo = False
op.RemoveRTable = False
op.RemoveRxnCenters = False
op.RemoveTextAtoms = False
op.RemoveValence = False
op.RemoveWedge = False
op.StripEitherDoubleBond = False
op.StripEitherSingleBond = False
op.R3NO_b = False
op.ProvideMissingCoords = False
op.Thiazole = False
op.XMinusToX_fg = False
op.ExpandStoichiometry = False
op.ConsolidateStoichiometry = False

print(op) # Prints out the values of the options

class MyHydrogenCounter(common.HydrogenCounter):
    def getoutput(self, smi):
        mol = cs.StructureData.LoadData(smi)
        if mol is None:
            return None, "Parse_error"
        ok = mol.NormalizeStructure(op)
        if not ok:
            # never happens - warning to stdout but I can't capture it
            return None, "Kekulization error"
        mol.ConvertTo3DStructure() # adds hydrogens by default
        numHs = []
        for atom in mol.Atoms:
            if atom.Element != "H":
                numH = sum([1 for x in mol.BondedAtomsOf(atom) if x.Element == "H"])
                numHs.append(numH)
        return numHs, None

if __name__ == "__main__":
    myname = "ChemDraw_16.0"
    MyHydrogenCounter(myname).main()
{'fraction_non_alphanumeric': 0.09434954007884362, 'fraction_numerical': 0.008935611038107753, 'mean_word_length': 3.7814070351758793, 'pattern_counts': {'":': 3, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1833031', 'n_tokens_mistral': 1343, 'n_tokens_neox': 1292, 'n_words': 308}