Mercurial > repos > bgruening > qed
comparison qed.py @ 1:ab73abead7fa draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/chemicaltoolbox/silicos-it/qed commit ed9b6859de648aa5f7cde483732f5df20aaff90e
author | bgruening |
---|---|
date | Tue, 07 May 2019 13:41:23 -0400 |
parents | 5ccd3a432785 |
children | 52a8d34dd08f |
comparison
equal
deleted
inserted
replaced
0:5ccd3a432785 | 1:ab73abead7fa |
---|---|
328 args = parser.parse_args() | 328 args = parser.parse_args() |
329 | 329 |
330 # Elucidate filetype and open supplier | 330 # Elucidate filetype and open supplier |
331 ifile = os.path.abspath(args.input) | 331 ifile = os.path.abspath(args.input) |
332 if not os.path.isfile(ifile): | 332 if not os.path.isfile(ifile): |
333 print "Error: ", ifile, " is not a file or cannot be found." | 333 print("Error: ", ifile, " is not a file or cannot be found.") |
334 sys.exit(1) | 334 sys.exit(1) |
335 if not os.path.exists(ifile): | 335 if not os.path.exists(ifile): |
336 print "Error: ", ifile, " does not exist or cannot be found." | 336 print("Error: ", ifile, " does not exist or cannot be found.") |
337 sys.exit(1) | 337 sys.exit(1) |
338 if not os.access(ifile, os.R_OK): | 338 if not os.access(ifile, os.R_OK): |
339 print "Error: ", ifile, " is not readable." | 339 print("Error: ", ifile, " is not readable.") |
340 sys.exit(1) | 340 sys.exit(1) |
341 | 341 |
342 if not args.iformat: | 342 if not args.iformat: |
343 # try to guess the filetype | 343 # try to guess the filetype |
344 filetype = check_filetype( ifile ) | 344 filetype = check_filetype(ifile) |
345 else: | 345 else: |
346 filetype = args.iformat # sdf or smi | 346 filetype = args.iformat # sdf or smi |
347 | 347 |
348 | 348 |
349 """ | 349 """ |
350 We want to store the original SMILES in the output. So in case of a SMILES file iterate over the file and convert each line separate. | 350 We want to store the original SMILES in the output. So in case of a SMILES file iterate over the file and convert each line separate. |
351 """ | 351 """ |
352 if filetype == 'sdf': | 352 if filetype == 'sdf': |
353 supplier = Chem.SDMolSupplier( ifile ) | 353 supplier = Chem.SDMolSupplier(ifile) |
354 # Process file | 354 # Process file |
355 if args.header: | 355 if args.header: |
356 args.outfile.write("MW\tALOGP\tHBA\tHBD\tPSA\tROTB\tAROM\tALERTS\tLRo5\tQED\tNAME\n") | 356 args.outfile.write("MW\tALOGP\tHBA\tHBD\tPSA\tROTB\tAROM\tALERTS\tLRo5\tQED\tNAME\n") |
357 count = 0 | 357 count = 0 |
358 for mol in supplier: | 358 for mol in supplier: |
359 count += 1 | 359 count += 1 |
360 if mol is None: | 360 if mol is None: |
361 print "Warning: skipping molecule ", count, " and continuing with next." | 361 print("Warning: skipping molecule ", count, " and continuing with next.") |
362 continue | 362 continue |
363 props = properties(mol) | 363 props = properties(mol) |
364 | 364 |
365 if args.method == 'max': | 365 if args.method == 'max': |
366 calc_qed = weights_max(mol, True, props) | 366 calc_qed = weights_max(mol, True, props) |
397 smiles = tokens[0] | 397 smiles = tokens[0] |
398 title = '' | 398 title = '' |
399 mol = Chem.MolFromSmiles(smiles) | 399 mol = Chem.MolFromSmiles(smiles) |
400 count += 1 | 400 count += 1 |
401 if mol is None: | 401 if mol is None: |
402 print "Warning: skipping molecule ", count, " and continuing with next." | 402 print("Warning: skipping molecule ", count, " and continuing with next.") |
403 continue | 403 continue |
404 props = properties(mol) | 404 props = properties(mol) |
405 | 405 |
406 if args.method == 'max': | 406 if args.method == 'max': |
407 calc_qed = weights_max(mol, True, props) | 407 calc_qed = weights_max(mol, True, props) |