1import sys
2
3import CDPL.Chem as Chem
4import CDPL.MolProp as MolProp
5
6
7# outputs the corresponding properties of each atom of the provided molecular graph
8def outputProperties(molgraph: Chem.MolecularGraph) -> None:
9 for atom in molgraph.atoms:
10 print('- Atom #%s' % str(molgraph.getAtomIndex(atom)))
11 print('\tAtomic weight: %s' % str(MolProp.getAtomicWeight(atom)))
12 print('\tPTE IUPAC group: %s' % str(MolProp.getIUPACGroup(atom)))
13 print('\tPTE period: %s' % str(MolProp.getPeriod(atom)))
14 print('\tVdW radius: %s' % str(MolProp.getVdWRadius(atom)))
15 print('\tCovalent radius (bond order=1): %s' % str(MolProp.getCovalentRadius(atom, 1)))
16 print('\tCovalent radius (bond order=2): %s' % str(MolProp.getCovalentRadius(atom, 2)))
17 print('\tCovalent radius (bond order=3): %s' % str(MolProp.getCovalentRadius(atom, 3)))
18 print('\tAllred Rochow electronegativity: %s' % str(MolProp.getAllredRochowElectronegativity(atom)))
19 print('\tElement name: %s' % MolProp.getElementName(atom))
20 print('\tValence electron count: %s' % str(MolProp.getElementValenceElectronCount(atom)))
21 print('\tAtom type specifies chemical element: %s' % str(MolProp.isChemicalElement(atom)))
22 print('\tIs main group element: %s' % str(MolProp.isMainGroupElement(atom)))
23 print('\tIs metal: %s' % str(MolProp.isMetal(atom)))
24 print('\tIs transition metal: %s' % str(MolProp.isTransitionMetal(atom)))
25 print('\tIs non-metal: %s' % str(MolProp.isNonMetal(atom)))
26 print('\tIs semi-metal: %s' % str(MolProp.isSemiMetal(atom)))
27 print('\tIs halogen: %s' % str(MolProp.isHalogen(atom)))
28 print('\tIs noble gas: %s' % str(MolProp.isNobleGas(atom)))
29
30def main() -> None:
31 if len(sys.argv) < 2:
32 sys.exit('Usage: %s <input mol. file>' % sys.argv[0])
33
34 # create reader for input molecules (format specified by file extension)
35 reader = Chem.MoleculeReader(sys.argv[1])
36
37 # create an instance of the default implementation of the Chem.Molecule interface
38 mol = Chem.BasicMolecule()
39
40 # read and process molecules one after the other until the end of input has been reached
41 try:
42 while reader.read(mol):
43 try:
44 outputProperties(mol)
45 except Exception as e:
46 sys.exit('Error: processing of molecule failed: ' + str(e))
47
48 except Exception as e: # handle exception raised in case of severe read errors
49 sys.exit('Error: reading molecule failed: ' + str(e))
50
51 sys.exit(0)
52
53if __name__ == '__main__':
54 main()