1import sys
2import os
3
4import CDPL.Pharm as Pharm
5
6
7# function called for each read pharmacophore
8def procPharmacophore(ph4: Pharm.Pharmacophore) -> None:
9 print('Read pharmacophore \'%s\' comprising %s features' % (Pharm.getName(ph4), str(ph4.numFeatures)))
10
11def main() -> None:
12 if len(sys.argv) < 2:
13 sys.exit('Usage: %s <input pharm. file>' % sys.argv[0])
14
15 # create reader for input pharmacophores (format specified by file extension)
16 reader = Pharm.PharmacophoreReader(sys.argv[1])
17
18 # create an instance of the default implementation of the Pharm.Pharmacophore interface
19 ph4 = Pharm.BasicPharmacophore()
20
21 # read and process pharmacophores one after the other until the end of input has been reached
22 try:
23 while reader.read(ph4):
24 try:
25 procPharmacophore(ph4)
26 except Exception as e:
27 sys.exit('Error: processing of pharmacophore failed: ' + str(e))
28
29 except Exception as e: # handle exception raised in case of severe read errors
30 sys.exit('Error: reading pharmacophore failed: ' + str(e))
31
32 sys.exit(0)
33
34if __name__ == '__main__':
35 main()