Anonymous committed 1517753

Changed "--output-all-structures" to "--output-all"
Fixed bug: complete-sdf with a 'smiles' tag saved the full
SMILES instead of the fragment SMILES

  • Participants
  • Parent commits bc9fd97

Comments (0)

Files changed (1)

     return mol_block + "".join(tag_data)
-def _save_other_tags(fragment, mcs, mol, subgraph, args):
+def _save_other_tags(mol, fragment, mcs, orig_mol, subgraph, args):
     if args.save_counts_tag is not None:
         if not mcs:
             line = "-1 -1 -1"
             line = "0 0 0"
             line = "1 %d %d" % (mcs.num_atoms, mcs.num_bonds)
-        fragment.SetProp(args.save_counts_tag, line)
+        mol.SetProp(args.save_counts_tag, line)
     if args.save_smiles_tag is not None:
         if mcs and mcs.num_atoms > 0:
             smiles = Chem.MolToSmiles(fragment)
             smiles = "-"
-        fragment.SetProp(args.save_smiles_tag, smiles)
+        mol.SetProp(args.save_smiles_tag, smiles)
     if args.save_smarts_tag is not None:
         if mcs and mcs.num_atoms > 0:
             smarts = mcs.smarts
             smarts = "-"
-        fragment.SetProp(args.save_smarts_tag, smarts)
+        mol.SetProp(args.save_smarts_tag, smarts)
 # Convert a subgraph into an SD file
         if atom_classes is not None:
             fragment.SetProp(output_tag, " ".join(map(str, atom_classes)))
-    _save_other_tags(fragment, mcs, mol, subgraph, args)
+    _save_other_tags(fragment, fragment, mcs, mol, subgraph, args)
     return _MolToSDBlock(fragment)
         s = " ".join(str(index) for index in subgraph.atom_indices)
         fragment.SetProp(output_tag, s)
-    _save_other_tags(fragment, mcs, mol, subgraph, args)
+    _save_other_tags(fragment, subgraph_to_fragment(mol, subgraph), mcs, mol, subgraph, args)
     return _MolToSDBlock(fragment)
                     "'complete-sdf' writes the entire SD file with the fragment information stored in "
                     "the tag specified by --save-fragment-indices-tag. (Default: smarts)")
-parser.add_argument("--output-all-structures", action="store_true",
+parser.add_argument("--output-all", action="store_true",
                     "By default the structure output formats only show an MCS for the first input structure. "
                     "If this option is enabled then an MCS for all of the structures are shown.")
                 assign_isotopes_from_class_tag(mol, atom_class_tag)
             except ValueError, err:
                 raise SystemExit("Structure #%d: %s" % (molno+1, err))
         if args.verbosity > 1:
             if len(structures) % 100 == 0:
             outfile.write(make_structure_format(args.output_format, mcs, structure, subgraph, args))
-            if not args.output_all_structures:
+            if not args.output_all:
     if args.output: