diff --git a/mrdna/readers/segmentmodel_from_lists.py b/mrdna/readers/segmentmodel_from_lists.py index 2d7e12097b5333dbf7b749ee42a1f396731701fb..922b3d247aa93390fed412abfe30eca33d95e0d7 100644 --- a/mrdna/readers/segmentmodel_from_lists.py +++ b/mrdna/readers/segmentmodel_from_lists.py @@ -234,7 +234,7 @@ def model_from_basepair_stack_3prime(coordinate, basepair, stack, three_prime, max_basepairs_per_bead = 5, max_nucleotides_per_bead = 5, local_twist = False, - dimensions=(5000,5000,5000),return_prop=False + dimensions=(5000,5000,5000) **model_parameters): """ Creates a SegmentModel object from lists of each nucleotide's @@ -475,11 +475,62 @@ def model_from_basepair_stack_3prime(coordinate, basepair, stack, three_prime, if sequence is None: for s in model.segments: s.randomize_unset_sequence() - if return_prop is True: - nt_prop=pd.DataFrame({"r":coordinate,"bp":basepair,"stack":stack,"fwd":fwd,"threeprime":three_prime,"seq":sequence,"orientation":orientation}) - return model,nt_prop + + 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, + max_basepairs_per_bead = 5, + max_nucleotides_per_bead = 5, + local_twist = False, + dimensions=(5000,5000,5000) + **model_parameters): + try: + c=df[coordinate_col] + except: + print("cannot locate coordinate") + try: + bp=df[bp_col] + except: + print("cannot locate bp") + try: + stack=df[stack_col] + except: + print("cannot find stack") + try: + tprime=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: + seq=None + + if orientation_col is not None: + try: + orient=df[orientation_col] + except: + print("no orientation inputted") + orient=None + else: + orient=None + + try: + model=model_from_basepair_stack_3prime(c, bp, stack, tprime, + sequence=seq, orientation=orient, + max_basepairs_per_bead = max_basepairs_per_bead, + max_nucleotides_per_bead =max_nucleotides_per_bead , + local_twist = local_twist, + dimensions=dimensions + **model_parameters) + model._dataframe=df return model + except: + print("cannot phrase DataFrame, aborted") def UNIT_circular(): """ Make a circular DNA strand, with dsDNA in the middle """