def run(pluginManager): """ This is the entry point for the plugin manager. The plugin manager will pass a reference to itself to the function. Use the APD_Printer instance returned by pluginManager.setup() instead of the 'print' statement to generate autoformated cmd line output. :param pluginManager: Reference to the plugin manager instance. """ global printer printer = pluginManager.setup() data = pluginManager.get_variable('data') molecule = data['exp'] printer.table(['Atom 1', 'Atom 2', 'Type', 'Distance'], head=True) restraints = RestraintManager() for atom1, atom2 in iter_atom_pairs(molecule, bound=False): if atom1.get_element() == 'H' or atom2.get_element() == 'H': continue value = getBondNumber(atom1, atom2) if value: r = Restraint(value, atom1-atom2, atom1, atom2, 'exp') printer.table('{:7>},{:7<},1-{},{:5.3f}'.format(atom1.get_name(), atom2.get_name(), value+1, atom1-atom2).split(',')) restraints.add(atom1, atom2, r) printer.table(done=True) restraints = RestraintManager() for molecule in data.values(): for atom1, atom2 in iter_atom_pairs(molecule, bound=False): if atom1.get_element() == 'H' or atom2.get_element() == 'H': continue value = getBondNumber(atom1, atom2) if value: restraints.add(atom1, atom2, Restraint(value, atom1.cartDistance(atom2), atom1, atom2, modelCompound=molecule.name)) restraintList = restraints.harvestRestraints() restraints.selfSum() bondMap = restraints.mapBonds(restraintList) with open(pluginManager.arg('write'), 'w') as fp: fp.write('REM Invariom based geometry restraints:') fp.write(''.join([str(r) for r in sorted(bondMap.keys(), key=lambda string: string[17:])])) printer() printer.spacer() printer('\n{} written.'.format(pluginManager.arg('write'))) printer('\nAdd \'+{}\' to your shelxl instruction file\'s header.'.format(pluginManager.arg('write')))
def find_rings(atoms, bonds=None): graph = Graph() # bonds = None class DummyMolecule(object): pass mol = DummyMolecule() mol.atoms = atoms if bonds is None: for atom1, atom2 in iter_atom_pairs(): graph.add_edge(atom1.name, atom2.name) else: blacklist = [] for b in bonds: for atom2i in b[1:10]: string = ' : '.join(sorted([atoms[b[0]].name, atoms[atom2i].name])) if not string in blacklist: if is_bound(atoms[b[0]].cart, atoms[b[0]].element, atoms[atom2i].cart, atoms[atom2i].element): graph.add_edge(atoms[b[0]].name, atoms[atom2i].name) blacklist.append(string) ring_list = cycle_basis(graph) return ring_list
def run(pluginManager): """ Entry point for the plugin manager :param configx: plugin manager instance :return: None """ printer = pluginManager.setup() molecule = quickLoad(pluginManager, pluginManager.arg('load')) printer('Filtering Atoms:') for atom in iter_atoms(molecule): if filter_atom(pluginManager, atom, 'atomfilter'): printer(atom) printer.spacer() printer('\nFiltering Atom Pairs:') for atom1, atom2 in iter_atom_pairs(molecule, bound=False, unique=False): if filter_atom_pair(pluginManager, atom1, atom2, 'atomfilter', 'secondfilter'): printer('{} {}'.format(atom1.get_name(), atom2.get_name())) printer.spacer() printer('\nUsing Custom Filter Function:') filter.register_custom_fuction('firstOf', firstOfElement) for atom in iter_atoms(molecule): if filter_atom(pluginManager, atom, 'customfilter'): printer(atom)
def run(pluginManager): """ Entry point for the plugin manager :param pluginManager: plugin manager instance :return: None """ printer = pluginManager.setup() molecule = quickLoad(pluginManager, pluginManager.arg("load")) printer("Filtering Atoms:") for atom in iter_atoms(molecule): if filter_atom(pluginManager, atom, "atomfilter"): printer(atom) printer.spacer() printer("\nFiltering Atom Pairs:") for atom1, atom2 in iter_atom_pairs(molecule, bound=False, unique=False): if filter_atom_pair(pluginManager, atom1, atom2, "atomfilter", "secondfilter"): printer("{} {}".format(atom1.get_name(), atom2.get_name())) printer.spacer() printer("\nUsing Custom Filter Function:") filter.register_custom_fuction("firstOf", firstOfElement) for atom in iter_atoms(molecule): if filter_atom(pluginManager, atom, "customfilter"): printer(atom)