Skip to content

Commit

Permalink
Merge pull request #57 from open-forcefield-group/searchList
Browse files Browse the repository at this point in the history
Fixing bug with basetypes vs. used_basetypes
  • Loading branch information
davidlmobley authored Jul 11, 2016
2 parents cb2f093 + be3dd26 commit 4423c1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/AlkEtOH2/atomtypes/decorators.smarts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% bonded to atoms
$(*-z) simply-bonded
$(*-z) singly-bonded
$(*=z) doubly-bonded
$(*#z) triply-bonded
$(*:z) aromatic-bond
Expand Down
16 changes: 13 additions & 3 deletions smarty/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,6 @@ def sample_atomtypes(self):

# Update proposed parent dictionary
proposed_parents[original_basetype].append([proposed_atomtype, proposed_typename])
print "proposed_parents: " + str(proposed_parents)

proposed_parents[proposed_atomtype] = []

Expand Down Expand Up @@ -568,7 +567,6 @@ def sample_atomtypes(self):
self.atomtypes = proposed_atomtypes
self.molecules = proposed_molecules
self.parents = proposed_parents
print "------------ self.parents= " + str(self.parents)
self.atom_type_matches = proposed_atom_type_matches
self.total_atom_type_matches = proposed_total_atom_type_matches
return True
Expand Down Expand Up @@ -718,7 +716,7 @@ def get_unfinishedAtomList(self, atom_typecounts, molecule_typecounts, atomtype_
reference_counts[typename] = count

# If all of a basetype and it's children match found atoms and reference remove from list
for [base_smarts, base_typename] in self.basetypes:
for [base_smarts, base_typename] in self.used_basetypes:
includeBase = True

# If the number of atoms matches the references are the same for basetypes and their children
Expand Down Expand Up @@ -797,6 +795,18 @@ def run(self, niterations, trajFile=None):
self.show_type_statistics(self.atomtypes, atom_typecounts, molecule_typecounts, atomtype_matches=self.atom_type_matches)
print('')

# Print parent tree as it is now.
roots = self.parents.keys()
# Remove keys from roots if they are children
for parent, children in self.parents.items():
child_smarts = [smarts for [smarts, name] in children]
for child in child_smarts:
if child in roots:
roots.remove(child)

print("Atom type hierarchy:")
self.print_parent_tree(roots, '\t')

if trajFile is not None:
# make "trajectory" file
if os.path.isfile(trajFile):
Expand Down

0 comments on commit 4423c1a

Please sign in to comment.