Thank you for developing (and maintaining) this collection of beautiful and practical DNA geometry software!I've enjoyed maintaining 3DNA for nearly two decades. With NIH funding support over the past 9 years, I created DSSR as a replacement of 3DNA v2.x. Alas, I am now out of luck to continuously serve the community for free via NIH funding support, as it used to be.
import random
import numpy as np
n_bp = len(sequence)
remainder = (n_bp % 10)
if remainder != 0:
raw_turns = n_bp / 10
turns = int((n_bp-remainder) / 10)
turn_angle = 360/turns
bp_angle = 360/n_bp
turn_indices = list(np.arange(0,n_bp,10))
selection = sorted(random.sample(turn_indices[1:], remainder))
count = 0
new_turn_indices = []
for index in turn_indices:
if index in selection:
count +=1
new_turn_indices.append(index+count)
else:
new_turn_indices.append(index+count)
differences = [new_turn_indices[n]-new_turn_indices[n-1] for n in range(1,len(new_turn_indices))]
turn_angles = [diff*bp_angle for diff in differences]
count = 0
roll_angles = []
for i in range(0,n_bp):
if i in new_turn_indices:
roll_angles.append(turn_angles[count])
count+=1
else:
roll_angles.append(0)
new_twist = 360/11
twist = 360/10
twists = []
for diff in differences:
if diff == 10:
twists.extend([twist]*diff)
else:
twists.extend([new_twist]*diff)