diff --git a/mrdna/readers/__init__.py b/mrdna/readers/__init__.py index 8c0b352c5ad4b9b5ddc446475ee09778658b3d1e..955f236973612565b6151d448ae257e03d262e60 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 c2571081f666f3e7ac05ca2ccc89693c06fcafc4..2a1a8dd336e6ca0de31568eb0fd3c2f3a622c6c4 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")