The alvaDescCLIWrapper package can be used to access alvaDesc functionalities from Python (3.5 or higher).
In order to work, the package requires a licensed version of alvaDesc installed on the same computer.
Minimum alvaDesc version: 1.0.14
Examples
1. Calculate two descriptors for two molecules:
aDesc = AlvaDesc(‘C:\\Program Files\\Alvascience\\alvaDesc\\alvaDescCLI.exe’) # Windows default alvaDescCLI.exe location
aDesc.set_input_SMILES([‘CCCC’, ‘CC(=O)OC1=CC=CC=C1C(=O)O’])
if not aDesc.calculate_descriptors([‘MW’, ‘AMW’]): # use calculate_descriptors(‘ALL’) to calculate them all
print(‘Error: ‘ + aDesc.get_error())
else:
print(‘Results: ‘ + aDesc.get_output())
The result is a list of lists of float containing the required descriptors:
Molecule | MW | AMW |
---|---|---|
CCCC | 58.14 | 4.15285714285714 |
CC(=O)OC1=CC=CC=C1C(=O)O | 180.17 | 8.57952380952381 |
2. Calculate the MACCS 166 fingerprint for the molecules contained in a MDL file:
aDesc = AlvaDesc(‘/usr/bin/alvaDescCLI’) # Linux default alvaDescCLI location
aDesc.set_input_file(‘./myfile.sdf’, ‘MDL’)
if not aDesc.calculate_fingerprint(‘MACCSFP’):
print(‘Error: ‘ + aDesc.get_error())
else:
print(‘Results: ‘ + aDesc.get_output())
The result is a simple list of strings containing the required fingerprint:
3. Calculate the ECFP fingerprint with size 1024 saving the result to a text file:
aDesc = AlvaDesc(‘/Applications/alvaDesc.app/Contents/MacOS/alvaDescCLI’) # macOS default alvaDescCLI location
aDesc.set_input_file(‘./myfile.sdf’, ‘MDL’)
aDesc.set_output_file(‘./test.txt’)
if not aDesc.calculate_fingerprint(‘ECFP’, 1024):
print(‘Error: ‘ + aDesc.get_error())
# the result is in the output file
#else:
# print(‘Results: ‘ + aDesc.get_output())
When using set_output_file, the results will be saved in the specified file and they won’t be available with the get_output function.