1import sys
2
3import CDPL.Pharm as Pharm
4import CDPL.Chem as Chem
5
6
7# outputs all (available) properties of the features stored in the given feature container
8def outputFeatureProps(ph4: Pharm.FeatureContainer) -> None:
9 ftr_type_str = { Pharm.FeatureType.UNKNOWN : 'UNKNOWN',
10 Pharm.FeatureType.HYDROPHOBIC : 'HYDROPHOBIC',
11 Pharm.FeatureType.AROMATIC : 'AROMATIC',
12 Pharm.FeatureType.NEGATIVE_IONIZABLE : 'NEGATIVE_IONIZABLE',
13 Pharm.FeatureType.POSITIVE_IONIZABLE : 'POSITIVE_IONIZABLE',
14 Pharm.FeatureType.H_BOND_DONOR : 'H_BOND_DONOR',
15 Pharm.FeatureType.H_BOND_ACCEPTOR : 'H_BOND_ACCEPTOR',
16 Pharm.FeatureType.HALOGEN_BOND_DONOR : 'HALOGEN_BOND_DONOR',
17 Pharm.FeatureType.HALOGEN_BOND_ACCEPTOR : 'HALOGEN_BOND_ACCEPTOR',
18 Pharm.FeatureType.EXCLUSION_VOLUME : 'EXCLUSION_VOLUME' }
19
20 geom_str = { Pharm.FeatureGeometry.UNDEF : 'UNDEF',
21 Pharm.FeatureGeometry.SPHERE : 'SPHERE',
22 Pharm.FeatureGeometry.VECTOR : 'VECTOR',
23 Pharm.FeatureGeometry.PLANE : 'PLANE' }
24
25 print('Composition of pharmacophore \'%s\':' % Pharm.getName(ph4))
26
27 for i in range(0, len(ph4)):
28 ftr = ph4[i]
29
30 print(' - Feature #%s:' % str(i))
31 print(' - Type: %s' % ftr_type_str[Pharm.getType(ftr)])
32 print(' - Geometry: %s' % geom_str[Pharm.getGeometry(ftr)])
33 print(' - Tolerance: %s' % Pharm.getTolerance(ftr))
34 print(' - Weight: %s' % Pharm.getWeight(ftr))
35 print(' - Optional: %s' % Pharm.getOptionalFlag(ftr))
36 print(' - Disabled: %s' % Pharm.getDisabledFlag(ftr))
37 print(' - Length: %s' % Pharm.getLength(ftr))
38 print(' - Hydrophobicity: %s' % Pharm.getHydrophobicity(ftr))
39
40 if Chem.has3DCoordinates(ftr): # Pharm.Feature derives from Chem.Entity3D - therefore a function from the Chem package is used here!
41 print(' - Position: %s' % Chem.get3DCoordinates(ftr))
42
43 if Pharm.hasOrientation(ftr):
44 print(' - Orientation: %s' % Pharm.getOrientation(ftr))
45
46def main() -> None:
47 if len(sys.argv) < 2:
48 sys.exit('Usage: %s <input pharm. file>' % sys.argv[0])
49
50 # create reader for input pharmacophores (format specified by file extension)
51 reader = Pharm.PharmacophoreReader(sys.argv[1])
52
53 # create an instance of the default implementation of the Pharm.Pharmacophore interface
54 ph4 = Pharm.BasicPharmacophore()
55
56 # read and process pharmacophores one after the other until the end of input has been reached
57 try:
58 while reader.read(ph4):
59 try:
60 outputFeatureProps(ph4)
61 except Exception as e:
62 sys.exit('Error: processing of pharmacophore failed: ' + str(e))
63
64 except Exception as e: # handle exception raised in case of severe read errors
65 sys.exit('Error: reading pharmacophore failed: ' + str(e))
66
67 sys.exit(0)
68
69if __name__ == '__main__':
70 main()