From 15b4880d584862c1a49ddf3e535c7435dda1679e Mon Sep 17 00:00:00 2001
From: Chris Maffeo <cmaffeo2@illinois.edu>
Date: Sat, 19 Jan 2019 09:04:22 -0600
Subject: [PATCH] Misc. small edits

1) Fixed lattice_type setting for cadnano structures, affecting ENM
2) Raise exception for circular segments (sites that loop such as RNA stem loops remain problematic)
3) Made translate and rotate functions return if nothing is selected by filter
---
 mrdna/readers/cadnano_segments.py |  5 +++++
 mrdna/segmentmodel.py             | 14 ++++++++++++++
 mrdna/simulate.py                 |  3 ---
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/mrdna/readers/cadnano_segments.py b/mrdna/readers/cadnano_segments.py
index 205ad57..689b138 100644
--- a/mrdna/readers/cadnano_segments.py
+++ b/mrdna/readers/cadnano_segments.py
@@ -185,6 +185,11 @@ class cadnano_part(SegmentModel):
                  local_twist = False
     ):
         self.part = part
+        try:
+            self.lattice_type = part.getGridType().name.lower()
+        except:
+            print("WARNING: unable to set cadnano lattice type")
+
         self._cadnano_part_to_segments(part)
         # SegmentModel.__init__(self,...)
         # self.segments = [seg for hid,segs in self.helices.items() for seg in segs]
diff --git a/mrdna/segmentmodel.py b/mrdna/segmentmodel.py
index 245e206..00cb905 100644
--- a/mrdna/segmentmodel.py
+++ b/mrdna/segmentmodel.py
@@ -191,6 +191,8 @@ class ConnectableElement():
         self.connections.append(connection)
         if other is not self:
             other.connections.append(connection)
+        else:
+            raise NotImplementedError("Segments cannot yet be connected to themselves; if you are attempting to make a circular object, try breaking the object into multiple segments")
         l = A.container.locations
         if A not in l: l.append(A)
         l = B.container.locations
@@ -265,6 +267,10 @@ class SegmentParticle(PointParticle):
             return seg.contour_to_nt_pos(pos)
 
     def get_contour_position(self,seg):
+        """ TODO: fix paradigm where a bead maps to exactly one location in a polymer
+        - One way: modify get_contour_position to take an optional argument that indicates where in the polymer you are looking from
+        """
+
         if seg == self.parent:
             return self.contour_position
         else:
@@ -492,6 +498,7 @@ class Segment(ConnectableElement, Group):
         r = self.contour_to_position(u)
 
         ids = Segment.__filter_contours(u, r, position_filter, contour_filter)
+        if len(ids) == 0: return
 
         ## Translate
         r[ids,:] = r[ids,:] + dr[np.newaxis,:]
@@ -502,6 +509,7 @@ class Segment(ConnectableElement, Group):
         r = self.contour_to_position(u)
 
         ids = Segment.__filter_contours(u, r, position_filter, contour_filter)
+        if len(ids) == 0: return
 
         if about is None:
             ## TODO: do this more efficiently
@@ -2715,6 +2723,12 @@ class SegmentModel(ArbdModel):
                 lattice_type = self.lattice_type
             except:
                 lattice_type = "square"
+        else:
+            try:
+                if lattice_type != self.lattice_type:
+                    print("WARNING: printing ENM with a lattice type ({}) that differs from model's lattice type ({})".format(lattice_type,self.lattice_type))
+            except:
+                pass
 
         if lattice_type == "square":
             enmTemplate = enmTemplateSQ
diff --git a/mrdna/simulate.py b/mrdna/simulate.py
index c069b1d..579d047 100644
--- a/mrdna/simulate.py
+++ b/mrdna/simulate.py
@@ -4,9 +4,6 @@ from .coords import readArbdCoords, readAvgArbdCoords
 import shutil
 from . import get_resource_path
 
-arbd="/home/cmaffeo2/development/cuda/arbd.dbg/src/arbd" # reduced the mem footprint cause vmd
-namd="/home/cmaffeo2/development/namd-bin/NAMD_Git-2017-07-06_Linux-x86_64-multicore-CUDA/namd2"
-
 ## TODO: implement replicas, initial conditions specified through some restart, and a custom simulation schedule
 
     
-- 
GitLab