From 783baf3bd8d32ef0535f351c6bc07122ed7b3078 Mon Sep 17 00:00:00 2001
From: Co Quach <43968221+daico007@users.noreply.github.com>
Date: Mon, 11 Mar 2024 07:08:21 -0500
Subject: [PATCH] add more side chain option, switch H cap with CH2 cap (#37)

---
 surface_coatings/chains/nbdac_polymer.py      | 12 +++++++---
 .../monomers/mnbdac/side_chains/__init__.py   |  4 ++++
 .../mnbdac/side_chains/amino_methane.mol2     | 24 +++++++++++++++++++
 .../mnbdac/side_chains/amino_methyl.py        | 23 ++++++++++++++++++
 .../monomers/mnbdac/side_chains/methanol.mol2 | 22 +++++++++++++++++
 .../monomers/mnbdac/side_chains/methanol.py   | 23 ++++++++++++++++++
 .../monomers/mnbdac/side_chains/nh.py         | 21 ++++++++++++++++
 .../monomers/mnbdac/side_chains/o.py          | 19 +++++++++++++++
 8 files changed, 145 insertions(+), 3 deletions(-)
 create mode 100644 surface_coatings/monomers/mnbdac/side_chains/amino_methane.mol2
 create mode 100644 surface_coatings/monomers/mnbdac/side_chains/amino_methyl.py
 create mode 100644 surface_coatings/monomers/mnbdac/side_chains/methanol.mol2
 create mode 100644 surface_coatings/monomers/mnbdac/side_chains/methanol.py
 create mode 100644 surface_coatings/monomers/mnbdac/side_chains/nh.py
 create mode 100644 surface_coatings/monomers/mnbdac/side_chains/o.py

diff --git a/surface_coatings/chains/nbdac_polymer.py b/surface_coatings/chains/nbdac_polymer.py
index 8b1789e..7f206ca 100644
--- a/surface_coatings/chains/nbdac_polymer.py
+++ b/surface_coatings/chains/nbdac_polymer.py
@@ -11,6 +11,12 @@
 from surface_coatings.monomers.mnbdac.side_chains import AminoPropyl
 from surface_coatings.monomers.mnbdac.terminal_groups import Acetaldehyde
 
+# Create custom ch2 cap for the polymer
+# clone this when provided to the polymer
+ch2_cap = CH2()
+ch2_cap.remove(
+    ch2_cap["down"]
+)
 
 class O(mb.Compound):
     """An oxygen with two ports attached."""
@@ -91,7 +97,7 @@ class pNBDAC(mb.Compound):
     terminal_groups: mb.Compound or list of Compounds (len 2)
         Terminal groups which will be matched with side chains
     cap_front : bool, optional, default=True
-        Cap the front of the polymer (NBDAC end)
+        Cap the front of the polymer (NBDAC end) with a CH2
     cap_end : bool, optional, default=False
         Cap the end of the polymer (Silane end)
     buffer : str, optional, default=None
@@ -185,7 +191,7 @@ def __init__(
             self.labels["down"] = self["Polymer"]["down"]
 
         if cap_front:
-            front_cap = H()
+            front_cap = mb.clone(ch2_cap)
             self.add(front_cap, "front_cap")
             mb.force_overlap(
                 move_this=front_cap,
@@ -193,7 +199,7 @@ def __init__(
                 to_positions=self["up"],
             )
         if cap_end:
-            end_cap = H()
+            end_cap = mb.clone(ch2_cap)
             self.add(end_cap, "end_cap")
             mb.force_overlap(
                 move_this=end_cap,
diff --git a/surface_coatings/monomers/mnbdac/side_chains/__init__.py b/surface_coatings/monomers/mnbdac/side_chains/__init__.py
index c6d603f..ed14e57 100644
--- a/surface_coatings/monomers/mnbdac/side_chains/__init__.py
+++ b/surface_coatings/monomers/mnbdac/side_chains/__init__.py
@@ -1,6 +1,10 @@
 """__init__ file for mNBDAC side chains."""
+from .nh import NH
+from .amino_methyl import AminoMethyl
 from .amino_ethyl import AminoEthyl
 from .amino_propyl import AminoPropyl
+from .o import O
+from .methanol import Methanol
 from .cresol import Cresol
 from .propanol import Propanol
 from .toluidine import Toluidine
diff --git a/surface_coatings/monomers/mnbdac/side_chains/amino_methane.mol2 b/surface_coatings/monomers/mnbdac/side_chains/amino_methane.mol2
new file mode 100644
index 0000000..28c9829
--- /dev/null
+++ b/surface_coatings/monomers/mnbdac/side_chains/amino_methane.mol2
@@ -0,0 +1,24 @@
+@<TRIPOS>MOLECULE
+RES
+7 6 1 0 1
+SMALL
+NO_CHARGES
+@<TRIPOS>CRYSIN
+    7.4607     6.9693     6.6397    90.0000    90.0000    90.0000 1 1
+@<TRIPOS>ATOM
+       1 C           -0.5716     0.0451    -0.0118 C             1 RES     
+       2 N            0.8404    -0.0115    -0.3628 N             1 RES     
+       3 H           -0.7036    -0.1026     1.0824 H             1 RES     
+       4 H           -0.9886     1.0330    -0.3004 H             1 RES     
+       5 H           -1.1240    -0.7488    -0.5574 H             1 RES     
+       6 H            1.2108    -0.9362    -0.0445 H             1 RES     
+       7 H            1.3367     0.7211     0.1945 H             1 RES     
+@<TRIPOS>BOND
+       1        1        2 1
+       2        1        3 1
+       3        1        4 1
+       4        1        5 1
+       5        2        6 1
+       6        2        7 1
+@<TRIPOS>SUBSTRUCTURE
+       1 RES             1 RESIDUE    0 **** ROOT      0
diff --git a/surface_coatings/monomers/mnbdac/side_chains/amino_methyl.py b/surface_coatings/monomers/mnbdac/side_chains/amino_methyl.py
new file mode 100644
index 0000000..676c62f
--- /dev/null
+++ b/surface_coatings/monomers/mnbdac/side_chains/amino_methyl.py
@@ -0,0 +1,23 @@
+"""AminoMethyl side chain class."""
+import mbuild as mb
+
+
+class AminoMethyl(mb.Compound):
+    """AminoEthyl side chain class."""
+
+    def __init__(self):
+        super().__init__()
+        mb.load(
+            "amino_methane.mol2",
+            compound=self,
+            backend="gmso",
+            relative_to_module=self.__module__,
+            infer_hierarchy=False,
+        )
+
+        to_remove = [self[4], self[6]]
+        for part in to_remove:
+            self.remove(part)
+
+        self.labels["terminal"] = self["Compound[0]"].labels.pop("port[1]")
+        self.labels["side"] = self["Compound[0]"].labels.pop("port[3]")
diff --git a/surface_coatings/monomers/mnbdac/side_chains/methanol.mol2 b/surface_coatings/monomers/mnbdac/side_chains/methanol.mol2
new file mode 100644
index 0000000..4af1b66
--- /dev/null
+++ b/surface_coatings/monomers/mnbdac/side_chains/methanol.mol2
@@ -0,0 +1,22 @@
+@<TRIPOS>MOLECULE
+RES
+6 5 1 0 1
+SMALL
+NO_CHARGES
+@<TRIPOS>CRYSIN
+    7.5955     6.7325     6.5627    90.0000    90.0000    90.0000 1 1
+@<TRIPOS>ATOM
+       1 C           -0.3566    -0.0316    -0.0168 C             1 RES     
+       2 O            0.9584    -0.4372    -0.2657 O             1 RES     
+       3 H           -0.5386     0.0288     1.0783 H             1 RES     
+       4 H           -1.0555    -0.7739    -0.4544 H             1 RES     
+       5 H           -0.5477     0.9586    -0.4845 H             1 RES     
+       6 H            1.5400     0.2553     0.1430 H             1 RES     
+@<TRIPOS>BOND
+       1        1        2 1
+       2        1        3 1
+       3        1        4 1
+       4        1        5 1
+       5        2        6 1
+@<TRIPOS>SUBSTRUCTURE
+       1 RES             1 RESIDUE    0 **** ROOT      0
diff --git a/surface_coatings/monomers/mnbdac/side_chains/methanol.py b/surface_coatings/monomers/mnbdac/side_chains/methanol.py
new file mode 100644
index 0000000..7e74dbb
--- /dev/null
+++ b/surface_coatings/monomers/mnbdac/side_chains/methanol.py
@@ -0,0 +1,23 @@
+"""Methanol side chain class."""
+import mbuild as mb
+
+
+class Methanol(mb.Compound):
+    """Methanol side chain class."""
+
+    def __init__(self):
+        super().__init__()
+        mb.load(
+            "methanol.mol2",
+            compound=self,
+            backend="gmso",
+            relative_to_module=self.__module__,
+            infer_hierarchy=False,
+        )
+
+        to_remove = [self[3], self[5]]
+        for part in to_remove:
+            self.remove(part)
+
+        self.labels["terminal"] = self["Compound[0]"].labels.pop("port[1]")
+        self.labels["side"] = self["Compound[0]"].labels.pop("port[3]")
diff --git a/surface_coatings/monomers/mnbdac/side_chains/nh.py b/surface_coatings/monomers/mnbdac/side_chains/nh.py
new file mode 100644
index 0000000..1150c04
--- /dev/null
+++ b/surface_coatings/monomers/mnbdac/side_chains/nh.py
@@ -0,0 +1,21 @@
+"""A NH with 2 ports."""
+
+import numpy as np
+
+import mbuild as mb
+
+
+class NH(mb.Compound):
+    """A NH with 2 ports."""
+
+    def __init__(self):
+        super().__init__()
+
+        self.add(mb.load("N", smiles=True))
+
+        h_to_remove = [self[2], self[3]]
+        for h in h_to_remove:
+            self.remove(h)
+
+        self.labels["side"] = self["Compound[0]"].labels.pop("port[1]")
+        self.labels["terminal"] = self["Compound[0]"].labels.pop("port[3]")
diff --git a/surface_coatings/monomers/mnbdac/side_chains/o.py b/surface_coatings/monomers/mnbdac/side_chains/o.py
new file mode 100644
index 0000000..b9eda93
--- /dev/null
+++ b/surface_coatings/monomers/mnbdac/side_chains/o.py
@@ -0,0 +1,19 @@
+"""An oxygen with 2 ports."""
+
+import numpy as np
+
+import mbuild as mb
+
+
+class O(mb.Compound):
+    """A oxygen with 2 ports."""
+
+    def __init__(self):
+        super().__init__()
+        self.add(mb.Particle(name="O", element="O"))
+
+        self.add(mb.Port(anchor=self[0]), "side")
+        self["side"].translate(np.array([0, 0.07, 0]))
+
+        self.add(mb.Port(anchor=self[0]), "terminal")
+        self["terminal"].translate(np.array([0, -0.07, 0]))