From df296ad8886748cece22fcb6d20f87576329e87f Mon Sep 17 00:00:00 2001
From: pinyili2 <pinyili2@illinois.edu>
Date: Tue, 20 Aug 2024 19:40:43 -0500
Subject: [PATCH] add

---
 mrdna/readers/__init__.py                |  4 +--
 mrdna/readers/segmentmodel_from_lists.py | 36 +++++++++++-------------
 2 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/mrdna/readers/__init__.py b/mrdna/readers/__init__.py
index 8c0b352..955f236 100644
--- a/mrdna/readers/__init__.py
+++ b/mrdna/readers/__init__.py
@@ -37,10 +37,10 @@ def read_list(infile,**model_parameters):
     return model_from_basepair_stack_3prime(coords, bp, stack, three_prime)
 
 def read_pandas(df,coordinate_col="r",bp_col="bp",stack_col="stack",three_prime_col="threeprime",
-                        seq_col=None,orientation_col=None):
+                        seq_col="seq",orientation_col="orientation"):
     from .segmentmodel_from_lists import model_from_pandas
     return model_from_pandas(df,coordinate_col,bp_col,stack_col,three_prime_col,
-                        seq_col,orientation_col),
+                        seq_col,orientation_col)
 
 def read_atomic_pdb(pdb_file, **model_parameters):
     from .segmentmodel_from_pdb import SegmentModelFromPdb
diff --git a/mrdna/readers/segmentmodel_from_lists.py b/mrdna/readers/segmentmodel_from_lists.py
index c257108..2a1a8dd 100644
--- a/mrdna/readers/segmentmodel_from_lists.py
+++ b/mrdna/readers/segmentmodel_from_lists.py
@@ -477,45 +477,39 @@ def model_from_basepair_stack_3prime(coordinate, basepair, stack, three_prime,
     return model
 
 def model_from_pandas(df,coordinate_col="r",bp_col="bp",stack_col="stack",three_prime_col="threeprime",
-                        seq_col=None,orientation_col=None,
+                        seq_col="seq",orientation_col="orientation",
                         max_basepairs_per_bead = 5,
                         max_nucleotides_per_bead = 5,
                         local_twist = False,
                         dimensions=(5000,5000,5000)
                         ,**model_parameters):
     try:
-        c=df[coordinate_col]
+        c=np.array(list(df[coordinate_col]))
     except:
         print("cannot locate coordinate")
     try:
-        bp=df[bp_col]
+        bp=np.array(df[bp_col])
     except:
         print("cannot locate bp")
     try:
-        stack=df[stack_col]
+        stack=np.array(df[stack_col])
     except:
         print("cannot find stack")
     try:
-        tprime=df[three_prime_col]
+        tprime=np.array(df[three_prime_col])
     except:
         print("cannot locate 3's")
-    if seq_col is not None:
-        try:
-            seq=df[seq_col]
-        except:
-            print("no sequence inputted")
-            seq=None
-    else:
+    try:
+        seq=np.array(df[seq_col])
+    except:
+        print("no sequence inputted")
         seq=None
     
-    if orientation_col is not None:
-        try:
-            orient=df[orientation_col]
-        except:
-            print("no orientation inputted")
-            orient=None
-    else:
-        orient=None   
+    try:
+        orient=np.array(list(df[orientation_col]))
+    except:
+        print("no orientation inputted")
+        orient=None
     
     try:
         model=model_from_basepair_stack_3prime(c, bp, stack, tprime,
@@ -525,6 +519,8 @@ def model_from_pandas(df,coordinate_col="r",bp_col="bp",stack_col="stack",three_
                                         local_twist = local_twist,
                                         dimensions=dimensions,
                                         **model_parameters)
+        model._dataframe=df
+
         return model
     except:
         print("cannot phrase DataFrame, aborted")
-- 
GitLab