From a5651d9d92db4ecd3d679812769fe81df05196be Mon Sep 17 00:00:00 2001
From: Chris Maffeo <cmaffeo2@illinois.edu>
Date: Mon, 17 Aug 2020 17:01:49 -0500
Subject: [PATCH] Added some convenience routines for pulling infomration from
 strands

---
 mrdna/segmentmodel.py | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/mrdna/segmentmodel.py b/mrdna/segmentmodel.py
index 3e1c069..b6d4a6c 100644
--- a/mrdna/segmentmodel.py
+++ b/mrdna/segmentmodel.py
@@ -1649,6 +1649,35 @@ class Strand(Group):
                 nt = seg._generate_oxdna_nucleotide( c, s.is_fwd, seq )
                 self.oxdna_nt.append(nt)
 
+    def get_sequence(self):
+        return ''.join([''.join(s.get_sequence()) for s in self.strand_segments])
+
+    def get_nt_positions_orientations(self, bp_offset = (5,0,0)):
+        ## TODO: remove duplicate code
+        rs = []
+        os = []
+        for s in self.strand_segments:
+            seg = s.segment
+            contour = s.get_contour_points()
+            assert( s.num_nt == 1 or (np.linalg.norm( seg.contour_to_position(contour[-1]) - seg.contour_to_position(contour[0]) ) > 0.1) )
+
+            DefaultOrientation = rotationAboutAxis([0,0,1], 90)
+            if s.is_fwd:
+                DefaultOrientation = rotationAboutAxis([1,0,0], 180).dot(DefaultOrientation)
+
+            for c,seq in zip(contour,s.get_sequence()):
+                r = seg.contour_to_position(c)
+                o = seg.contour_to_orientation(c)
+                o = o.dot(DefaultOrientation)
+
+                if isinstance(seg, SingleStrandedSegment):
+                    r = r
+                else:
+                   r = r - o.dot(np.array(bp_offset))
+
+                rs.append(r)
+                os.append(quaternion_from_matrix(o))
+        return np.array(rs), np.array(os)
 
 
 class SegmentModel(ArbdModel):
-- 
GitLab