Commit c25c9dc3 authored by Oliver Smart's avatar Oliver Smart
Browse files

start working on a fragment_html option for ccd_utils_cli.

Not sure it is going to be useful.
issue #34
parent 1d13adc5
......@@ -36,16 +36,24 @@ def __parse_command_line_args():
parser.add_argument('CIF', help='input PDB-CCD mmcif file (must be specified)')
help='use this fragment library in place of the one supplied with the code.')
parser.add_argument('--svg', help='write an 2D image of the compound to svg file')
parser.add_argument('--svg', help='write a svg file with a 2D image of the compound')
atom_labels_parser = parser.add_mutually_exclusive_group(required=False)
atom_labels_parser.add_argument('--atom_labels', dest='atom_labels', action='store_true',
help='turn on atom labels for 2D image.')
atom_labels_parser.add_argument('--no_atom_labels', dest='atom_labels', action='store_false',
help='turn off atom labels for 2D image (the default).')
help='write an html file with a report on the fragments identified within the compound')
parser.add_argument('--debug', action='store_true', help='turn on debug message logging output')
return parser.parse_args()
def _log_fragments(logger, fragments):' fragments:')
for (name, list_of_atom_list) in fragments.items():' {} occurs {} times:'.format(name, len(list_of_atom_list)))
for atoms in list_of_atom_list:' {}'.format(' '.join(atoms)))
def main():
logger = logging.getLogger(' ')
......@@ -56,6 +64,7 @@ def main():
cif_file = args.CIF
svg_file = args.svg
fragment_html_file = args.fragment_html
atom_labels = args.atom_labels
library = args.library
logger.debug('CIF is {}'.format(cif_file))
......@@ -67,17 +76,15 @@ def main():' chem_comp_id {} '.format(pdb_cc_rdkit.chem_comp_id))' chem_comp_name: {}'.format(pdb_cc_rdkit.chem_comp_name))
frag_lib = FragmentLibrary(override_fragment_library_file_path=library)
fragments = frag_lib.fragments_for_pdb_chemical_components_rdkit(pdb_cc_rdkit)' fragments:')
for (name, list_of_atom_list) in fragments.items():' {} occurs {} times:'.format(name, len(list_of_atom_list)))
for atoms in list_of_atom_list:' {}'.format(' '.join(atoms)))
if svg_file is not None:
pdb_cc_rdkit.image_file_or_string(file_name=svg_file, atom_labels=atom_labels, pixels_x=400, pixels_y=400)
frag_lib = FragmentLibrary(override_fragment_library_file_path=library)
fragments = frag_lib.fragments_for_pdb_chemical_components_rdkit(pdb_cc_rdkit)
_log_fragments(logger, fragments)
if fragment_html_file is not None:
frag_lib.html_report_of_fragments(pdb_cc_rdkit, fragment_html_file)
if __name__ == "__main__":
......@@ -75,6 +75,17 @@ class FragmentLibrary(object):
return fragments
def html_report_of_fragments(self, pdb_ccd_rdkit, html_file_name):
idea produce an html report to a file of the fragments identified within a molecule
pdb_ccd_rdkit: A PdbChemicalComponentsRDKit molecule
html_file_name (str): file bane for the output html file
raise NotImplementedError('html_report_of_fragments to be written')
def _load(self, fragment_file_name):
loads fragment library from the file in data.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment