Skip to content

Commit bbf54aa

Browse files
chrisjonesBSUchrisjonesBSUjennyfothergill
authored
Polymer class revamp (#851)
* added a couple new functions, moved existing code into build function * added some doc strings * added a default value to the port labels * reworked the _add_port function * saving my progress with the add_end_groups function * made progress with end group funcitonality * removing a couple print statements * added 2 new attributes to port class * removed changes from port.py, commented out orientation and separation lines * changed method of removing hydrogens, added n_monomers var for finding last monomer * adding to the doc strings * added update_separation function * update orientation func; separation property func * added the up subports to the rotations * fixed the change_orientation function * fix handling when their is no anchor particle * fix typo * docstring: separation is None when port has no anchor * added 3 unit tests * remove the port updating stuff I was trying to use * updating port separations for end groups * fix the way clone is being called * added some doc strings and comments * updated doc strings * including jupyter notebook example and walk through * example notebook ready * added to recipe examples * expanded end_group options * update alkane recipe to make tests pass * cleaned up if statements when updating head/tail ports * remove trailing whitespace * allow use of compound with existing ports to be specified in init whitespace/formatting * update alkane to new schema * update tests * blacked, changed how head/tail port work * remove debug print * update notebook * update notebook * clear nb * add back add_hydrogens * add add_hydrogens=False * add_hydrogens=False, all tests pass * changed orientation of down port to face opposite direction of up port * Few more examples added to show new functionality * adding a few unit tests * removing the example notebook from the PR * test for errors, and manually passing in end group compounds * expanded doc strings with more detailed explanations, and some examples * fix a conflict that was sticking around in the port doc strings * fix formatting in the doc strings * Doc strings to explain implementation of sequence in the build function * add unit test for value of n < 1 * 2 new tests to test for errors * remove unused imports * oops, typo Co-authored-by: chrisjonesBSU <[email protected]> Co-authored-by: Jenny <[email protected]> Co-authored-by: Jenny Fothergill <[email protected]>
1 parent df68c72 commit bbf54aa

File tree

5 files changed

+444
-72
lines changed

5 files changed

+444
-72
lines changed

mosdef_gomc/lib/moieties/ch2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def __init__(self):
1919
self.add(mb.Port(anchor=self[0]), "up")
2020
self["up"].translate([0, 0.07, 0])
2121

22-
self.add(mb.Port(anchor=self[0]), "down")
22+
self.add(mb.Port(anchor=self[0], orientation=[0, -1, 0]), "down")
2323
self["down"].translate([0, -0.07, 0])
2424

2525

mosdef_gomc/lib/recipes/alkane.py

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -71,33 +71,21 @@ def __init__(self, n=3, cap_front=True, cap_end=True):
7171

7272
# Handle general case of n >= 3
7373
else:
74+
end_groups = [None, None]
7475
# Adjust length of Polmyer for absence of methyl terminations.
75-
if not cap_front:
76-
n += 1
77-
if not cap_end:
78-
n += 1
79-
chain = mb.recipes.Polymer(
80-
CH2(), n=n - 2, port_labels=("up", "down")
81-
)
82-
self.add(chain, "chain")
8376
if cap_front:
84-
self.add(CH3(), "methyl_front")
85-
mb.force_overlap(
86-
move_this=self["chain"],
87-
from_positions=self["chain"]["up"],
88-
to_positions=self["methyl_front"]["up"],
89-
)
90-
else:
91-
# Hoist port label to Alkane level.
92-
self.add(chain["up"], "up", containment=False)
93-
77+
n -= 1
78+
end_groups[0] = CH3()
9479
if cap_end:
95-
self.add(CH3(), "methyl_end")
96-
mb.force_overlap(
97-
self["methyl_end"],
98-
self["methyl_end"]["up"],
99-
self["chain"]["down"],
100-
)
101-
else:
80+
n -= 1
81+
end_groups[1] = CH3()
82+
83+
chain = mb.recipes.Polymer(monomers=[CH2()], end_groups=end_groups)
84+
chain.build(n, add_hydrogens=False)
85+
self.add(chain, "chain")
86+
if not cap_front:
87+
# Hoist port label to Alkane level.
88+
self.add(self["chain"]["up"], "up", containment=False)
89+
if not cap_end:
10290
# Hoist port label to Alkane level.
103-
self.add(chain["down"], "down", containment=False)
91+
self.add(self["chain"]["down"], "down", containment=False)

0 commit comments

Comments
 (0)