c_help = 'Atom ids to use for alignment (default = all heavy atoms)' parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-i', '--allow_inversion', help=i_help, action='store_true') parser.add_argument('-f', '--output_format', help=f_help, default='cml') parser.add_argument('-c', '--center_id', help=c_help, action='append', type=int) parser.add_argument('ref_file', help='cml file containing the reference conformer that all others will be aligned to') parser.add_argument('input_files', help='cml files containing the other conformers to be algigned', nargs='+') args = parser.parse_args() input_names = args.input_files if len(input_names) == 1 and '*' in input_names[0]: # If the shell is dumb (powershell/cmd.exe), glob input files ourselves from glob import glob input_names = glob(input_names[0]) mols = [molecule.from_cml(i) for i in input_names] ref_mol = molecule.from_cml(args.ref_file) ref_num_atoms = len(ref_mol.atoms) if args.center_id: center_ids = [i - 1 for i in args.center_id] else: center_ids = [i.get_id() for i in ref_mol.atoms if i.num > 1] for each_id in center_ids: if not (0 <= each_id < ref_num_atoms): raise ValueError, 'The atom id to align molecules at must be a valid atom id for the molecule, i.e. an integer between between 1 and %d inclusive.' %ref_num_atoms for each_mol in mols: if len(each_mol.atoms) != ref_num_atoms: raise ValueError, 'Not all molecules to be aligned have the same number of atoms. Please retry with conformers of only one molecule' ref_center = numpy.array([i.coords for i in ref_mol.atoms if i.get_id() in center_ids]) ref_mol.translate(-1*ref_center.mean(axis=0)) input_names = [path.split(i) for i in input_names]
formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-s', '--scaling', help=scaling_help, type=float, default=None) parser.add_argument('-d', '--delta', help=delta_help, type=int, default=30) parser.add_argument('-i', '--allow_inversion', help=i_help, action='store_true') parser.add_argument('-o', '--output_name', help=o_help) parser.add_argument('-f', '--output_format', help=f_help, default='cml') parser.add_argument('-r', '--ring_generation', help=r_help, default=-1, type=int) parser.add_argument('-a', '--avoid_division', help=a_help, action='store_true') parser.add_argument('-b', '--break_at', help=b_help, action='append', type=int, nargs=2) parser.add_argument('file_name', help='cml file containing the molecule') args = parser.parse_args() vary_rings = args.ring_generation fix_or_split = [] try: mol = molecule.from_cml(args.file_name) except: msg = 'Reading molecule failed. Please check that the file a) exists and b) is a .cml molecule file' raise RuntimeError(msg) if args.output_name is None: in_name = os.path.normpath(args.file_name) in_path_name, in_file_name = os.path.split(in_name) base_file_name = os.path.join(in_path_name, 'Conformer_{0}_' + in_file_name) # Make sure that the file extension is appropriate to the contents of the file if args.output_format == 'xyz': base_file_name = os.path.splitext(base_file_name)[0] + '.xyz' elif args.output_format == 'gauss': base_file_name = os.path.splitext(base_file_name)[0] + '.gjf' elif args.output_format != 'cml': base_file_name = os.path.splitext(base_file_name)[0] + '.inp' else:
parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-i', '--allow_inversion', help=i_help, action='store_true') parser.add_argument('-f', '--output_format', help=f_help, default='cml') parser.add_argument('-c', '--center_id', help=c_help, action='append', type=int) parser.add_argument('ref_file', help='cml file containing the reference ' + 'conformer that all others will be aligned to') parser.add_argument('input_files', help='cml files containing the other ' + 'conformers to be algigned', nargs='+') args = parser.parse_args() input_names = args.input_files if len(input_names) == 1 and '*' in input_names[0]: # If the shell is dumb (powershell/cmd.exe), glob input files ourselves from glob import glob input_names = glob(input_names[0]) mols = [molecule.from_cml(i) for i in input_names] ref_mol = molecule.from_cml(args.ref_file) ref_num_atoms = len(ref_mol.atoms) if args.center_id: center_ids = [i - 1 for i in args.center_id] else: center_ids = [i.get_id() for i in ref_mol.atoms if i.num > 1] for each_id in center_ids: if not (0 <= each_id < ref_num_atoms): raise ValueError('The atom id to align molecules at must be a valid ' + 'atom id for the molecule, i.e. an integer between ' + 'between 1 and %d inclusive.' % ref_num_atoms) for each_mol in mols: if len(each_mol.atoms) != ref_num_atoms: raise ValueError('Not all molecules to be aligned have the same ' + 'number of atoms. Please retry with conformers ' +
parser.add_argument('-n', '--no_rmsd', help=n_help, action='store_true') parser.add_argument('-a', '--automatic', help=a_help, action='store_true') parser.add_argument('-i', '--allow_inversion', help=i_help, action='store_true') parser.add_argument('-u', '--uniqueness_cutoff', type=float, help=u_help, default=1.0) parser.add_argument('-H', '--use_hierachical_clustering', help=c_help, action='store_true') parser.add_argument('input_files', help='cml files containing the conformers to be analysed', nargs='+') # Prepare input args = parser.parse_args() input_names = args.input_files for idx, i in enumerate(input_names): if '*' in i: # If the shell is dumb (powershell/cmd.exe), glob input files ourselves input_names[idx:idx + 1] = glob(i) mols = [molecule.from_cml(i) for i in input_names] for i in mols: canonicalise(i) # Clean up the molecule names for pretty-printing mol_names = [path.splitext(path.split(i)[1])[0] for i in input_names] writer = csv.writer(args.output_name) if args.use_hierachical_clustering: cluster = cluster_hierarchy else: cluster = cluster_kmeans # Validate input if len(set([len(i.atoms) for i in mols])) != 1: raise ValueError, 'Not all molecules to be analysed have the same number of atoms. Please retry with conformers of only one molecule' if args.rmsd_arrange not in ['t', 'b', 'i']: raise ValueError, 'RMSD arrangement must be by [t]orsion clustering, [b]ounding box clustering, or conformer [i]d'
formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument('-s', '--scaling', help=scaling_help, type=float, default=None) parser.add_argument('-d', '--delta', help=delta_help, type=int, default=30) parser.add_argument('-i', '--allow_inversion', help=i_help, action='store_true') parser.add_argument('-o', '--output_name', help=o_help) parser.add_argument('-f', '--output_format', help=f_help, default='cml') parser.add_argument('-r', '--ring_generation', help=r_help, default=-1, type=int) parser.add_argument('-a', '--avoid_division', help=a_help, action='store_true') parser.add_argument('-b', '--break_at', help=b_help, action='append', type=int, nargs=2) parser.add_argument('file_name', help='cml file containing the molecule') args = parser.parse_args() vary_rings = args.ring_generation fix_or_split = [] try: mol = molecule.from_cml(args.file_name) except: msg = 'Reading molecule failed. Please check that the file a) exists and b) is a .cml molecule file' raise RuntimeError(msg) if args.output_name is None: in_name = os.path.normpath(args.file_name) in_path_name, in_file_name = os.path.split(in_name) base_file_name = os.path.join(in_path_name, 'Conformer_{0}_' + in_file_name) # Make sure that the file extension is appropriate to the contents of the file if args.output_format == 'xyz': base_file_name = os.path.splitext(base_file_name)[0] + '.xyz' elif args.output_format == 'gauss': base_file_name = os.path.splitext(base_file_name)[0] + '.gjf' elif args.output_format != 'cml': base_file_name= os.path.splitext(base_file_name)[0] + '.inp' else:
parser.add_argument('-H', '--use_hierachical_clustering', help=c_help, action='store_true') parser.add_argument('input_files', help='cml files containing the conformers' + ' to be analysed', nargs='+') # Prepare input args = parser.parse_args() input_names = args.input_files for idx, i in enumerate(input_names): if '*' in i: # If the shell is dumb (powershell/cmd.exe), glob input files ourselves input_names[idx:idx + 1] = glob(i) mols = [molecule.from_cml(i) for i in input_names] for i in mols: canonicalise(i) # Clean up the molecule names for pretty-printing mol_names = [path.splitext(path.split(i)[1])[0] for i in input_names] writer = csv.writer(args.output_name) if args.use_hierachical_clustering: cluster = cluster_hierarchy else: cluster = cluster_kmeans # Validate input if len(set([len(i.atoms) for i in mols])) != 1: raise ValueError( 'Not all molecules to be analysed have the same number ' + 'of atoms. Please retry with conformers of only one molecule')