Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
66edf18
Add compute_twist.py
stevenluo22 Apr 23, 2024
df488c7
Add PU.1/AMHGo specific analysis script
stevenluo22 Apr 23, 2024
3d6bdd4
Add and Reassign name protein-DNA info.dat analysis file
stevenluo22 Apr 23, 2024
2d5b08f
File for DNA (only) info.dat analysis, not functional
stevenluo22 Apr 23, 2024
df53b17
Add run and analysis scripts
stevenluo22 Nov 15, 2024
88854a0
fixed protein_DNA_run force and velocity setup minimizations
stevenluo22 Nov 15, 2024
f6d7702
Initialize output.dcd before second simulation initialize
stevenluo22 Nov 15, 2024
bc1ecdf
add energy diagnostic script
stevenluo22 Nov 20, 2024
0c7c449
add Platform CPU/OpenCL argument
stevenluo22 Nov 21, 2024
95b2235
Separated forces setup code into separate file as in OpenAWSEM
stevenluo22 Dec 12, 2024
df2047d
Add forces_setup.py and old versions of scripts
stevenluo22 Dec 12, 2024
a25fc9a
renamed old_scripts to old_scripts_v1
stevenluo22 Dec 12, 2024
46f6730
revamped protein DNA analysis script
stevenluo22 Dec 14, 2024
dba6dd1
removed sl206-specific code
stevenluo22 Dec 18, 2024
8c13b48
fixed quotation marks for aries interpretations
stevenluo22 Dec 18, 2024
9e7f6f0
Fixed open3spn2 capitalization
stevenluo22 Dec 19, 2024
7f70c64
Revert capitialization changes
stevenluo22 Dec 19, 2024
bcc5332
Removed units from forces_setup.py
stevenluo22 Dec 20, 2024
b1df455
update forces_setup.py; adds advisory for terms in same forceGroup; a…
stevenluo22 May 23, 2025
3444161
move old scripts into subdirectory
stevenluo22 May 23, 2025
cea9edf
fix argparse input to int for steps and Frames
stevenluo22 May 31, 2025
91a5587
adds protein-dna bias for multiple chains
stevenluo22 Jun 18, 2025
9bb7c55
Adds DNA position constraint; not complete and placeholder code added
stevenluo22 Jun 18, 2025
b3f280e
adds protein-DNA bias distance and energy multichain
stevenluo22 Jun 30, 2025
d30b144
Got DNA position anchors compiling; will need testing
stevenluo22 Jul 1, 2025
d6fa1b6
adds CMMotion remover
stevenluo22 Jul 12, 2025
e85dd76
Fix boolean logic of remove CM motion remover
stevenluo22 Jul 12, 2025
40d4915
Update protein_DNA_energy.py
stevenluo22 Jul 25, 2025
7b1ee50
allow user to specify debye length and nonbonded cutoff for dna.Elect…
ftclark3 May 27, 2026
ded7e97
allow user to specify nonbonded cutoff, debye length, and excluded vo…
ftclark3 May 27, 2026
06b0184
revert to former default nonbonded cutoff in dna.Electrostatics
ftclark3 May 27, 2026
f8d3170
clarified comments
ftclark3 May 28, 2026
834069e
allow user to specify debye length and nonbonded cutoff
ftclark3 May 28, 2026
7ea49ff
added steven's dna force classes
ftclark3 May 28, 2026
7e7b881
updated StringProteinDNA with steven's logical changes commented out.…
ftclark3 May 28, 2026
90c9a57
condense protein distance distance bias classes
ftclark3 May 28, 2026
5f1e763
added protein-dna biasing functions based on electrostatics and the p…
ftclark3 May 28, 2026
253318c
added steven's scripts
ftclark3 May 28, 2026
5c51e84
Update cutoff_distance to use nanometer units
ftclark3 May 28, 2026
697ae35
Update protein_dna.py
ftclark3 May 28, 2026
68b0c88
setting up new branch
ftclark3 Jun 1, 2026
7c8e235
Merge remote-tracking branch 'ftclark3/sync_with_steven' into sync_wi…
ftclark3 Jun 1, 2026
17468e7
updated imports
ftclark3 Jun 1, 2026
7764ef6
Merges #27
cabb99 Jun 2, 2026
821dfd9
Merge pull request #26 from stevenluo22
cabb99 Jun 2, 2026
3c54c06
Add a centratized force groups definition
cabb99 Jun 2, 2026
bab9e66
Fix AMHgoProteinDNA bugs and inputs
cabb99 Jun 2, 2026
bfe5e43
Split protein-DNA biases and readouts into dedicated optional modules
cabb99 Jun 2, 2026
ca373f8
Add lazy optional_forces registry for opt-in biases and CVs
cabb99 Jun 2, 2026
241ddf2
Adds tests
cabb99 Jun 3, 2026
ff37503
Adds AMHGo bias
cabb99 Jun 4, 2026
6ef3464
Removes scripts from original commit
cabb99 Jun 4, 2026
a3bc16f
Removes previous scripts
cabb99 Jun 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 0 additions & 158 deletions examples/DNA_analysis.py

This file was deleted.

1 change: 1 addition & 0 deletions open3SPN2/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from open3SPN2.ff3SPN2 import *
from .optional_forces import optional_forces

from . import _version
__version__ = _version.get_versions()['version']
118 changes: 118 additions & 0 deletions open3SPN2/compute_twist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
#define these functions

import numpy as np
import math

def vector(p1, p2):
return [p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]]

def vadd(p1,p2):
return [p2[0]/2+p1[0]/2, p2[1]/2+p1[1]/2, p2[2]/2+p1[2]/2]

def vmulti(p1,k):
return [p1[0]*k,p1[1]*k,p1[2]*k]

def vabs(a):
return math.sqrt(pow(float(a[0]),2)+pow(float(a[1]),2)+pow(float(a[2]),2))

def v_product(p1,p2):
return p1[0]*p2[0]+p1[1]*p2[1]+p1[2]*p2[2]

def vcross_product(a, b):
cx = a[1]*b[2]-a[2]*b[1]
cy = a[2]*b[0]-a[0]*b[2]
cz = a[0]*b[1]-a[1]*b[0]
return [cx, cy, cz]

#Various methods of calculations of twist. These are similar, using slightly different methods. But they should yield the same results.
def Xun_twist_OG(b_atoms): #original Xun's code
dna_length = int(len(b_atoms)/2)
b1_atoms = b_atoms[0:dna_length]
b2_atoms = b_atoms[dna_length:dna_length*2]
Twist = ""
for i in range(dna_length-1):
b_atom_1 = b_atoms[i]
b_atom_2 = b_atoms[-1-i]
b_atomn_1 = b_atoms[i+1]
b_atomn_2 = b_atoms[-1-i-1]
b_center = vadd(b_atom_1,b_atom_2)
b_centern = vadd(b_atomn_1,b_atomn_2)
zmst=vector(b_center,b_centern)
ys = vector(b_atom_1,b_atom_2)
ysn = vector(b_atomn_1,b_atomn_2)
yr = vector(ys,vmulti(zmst,v_product(ys,zmst)))
yrn = vector(ysn,vmulti(zmst,v_product(ysn,zmst)))
zmsto = vcross_product(yr,yrn)
ozmst = v_product(zmst,zmsto)
#print v_product(yr,yrn)/(vabs(yr)*vabs(yrn))
twist = math.acos(v_product(yr,yrn)/(vabs(yr)*vabs(yrn)))/3.15159*180
if twist > 180:
twist = twist - 180
elif twist < -180:
twist = twist + 180
if ozmst > 0:
twist = twist
else:
twist = 0 - twist
Twist += str(twist) + " "
return Twist

def Xun_twist(Vec_1, Vec_2, Vec_3, Vec_4): #Steven's implementation of Xun's code!!
#WARNING: Sign is not taken into account but under in vivo conditions, should be but an edge case!
b_atom_1 = [float(x)/vabs(Vec_1[0]) for x in Vec_1[0]]
b_atom_2 = [float(x)/vabs(Vec_2[0]) for x in Vec_2[0]]
b_atomn_1 = [float(x)/vabs(Vec_3[0]) for x in Vec_3[0]]
b_atomn_2 = [float(x)/vabs(Vec_4[0]) for x in Vec_4[0]]
b_center = vadd(b_atom_1,b_atom_2)
b_centern = vadd(b_atomn_1,b_atomn_2)
zmst=vector(b_center,b_centern)
ys = vector(b_atom_1,b_atom_2)
ysn = vector(b_atomn_1,b_atomn_2)
yr = vector(ys,vmulti(zmst,v_product(ys,zmst)))
yrn = vector(ysn,vmulti(zmst,v_product(ysn,zmst)))
#zmsto = vcross_product(yr,yrn)
#ozmst = v_product(zmst,zmsto)
#print v_product(yr,yrn)/(vabs(yr)*vabs(yrn))
twist = math.acos(v_product(yr,yrn)/(vabs(yr)*vabs(yrn))) #/3.15159*180 #Conversion from radians to degrees?
return twist

def Steven_twist(Vec_1, Vec_2, Vec_3, Vec_4): #original Steven's code
x1, y1, z1 = Vec_1[0].astype(float)
x2, y2, z2 = Vec_2[0].astype(float)
x3, y3, z3 = Vec_3[0].astype(float)
x4, y4, z4 = Vec_4[0].astype(float)

# Calculate vector A, B, and M
Ax, Ay, Az = x2 - x1, y2 - y1, z2 - z1
Bx, By, Bz = x4 - x3, y4 - y3, z4 - z3
Mx, My, Mz = (x4 + x3)/2 - (x1 + x2)/2, (y4 + y3)/2 - (y1 + y2)/2, (z4 + z3)/2 - (z1 + z2)/2

# Calculate vector C and D
Cx, Cy, Cz = Ay*Mz - Az*My, Az*Mx - Ax*Mz, Ax*My - Ay*Mx
Dx, Dy, Dz = By*Mz - Bz*My, Bz*Mx - Bx*Mz, Bx*My - By*Mx

# Calculate magnitudes of vectors C and D
Cm = np.sqrt(Cx**2 + Cy**2 + Cz**2)
Dm = np.sqrt(Dx**2 + Dy**2 + Dz**2)

# Calculate dot product and theta
dot = (Cx*Dx + Cy*Dy + Cz*Dz) / (Cm * Dm)
theta = np.arccos(np.clip(dot, -1, 1))

# Define Ex, Ey, and Ez
Ex, Ey, Ez = Cy*Dz-Cz*Dy, Cz*Dx-Cx*Dz, Cx*Dy-Cy*Dx
dot_sign = Ex*Mx+Ey*My+Ez*Mz

# Calculate the angle according to the provided formula
angle = theta - 2*(np.sign(dot_sign) < 0)*(theta - np.pi)

return angle

def diff_twist(Vec_1, Vec_2, Vec_3, Vec_4):
return Steven_twist(Vec_1, Vec_2, Vec_3, Vec_4) - Xun_twist(Vec_1, Vec_2, Vec_3, Vec_4)

def test_twist(Vec_1, Vec_2, Vec_3, Vec_4):
return Steven_twist(Vec_1, Vec_2, Vec_3, Vec_4)

if __name__=='__main__':
test_twist()
14 changes: 10 additions & 4 deletions open3SPN2/force/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
#from .template import DNAForce
#from .template import ProteinDNAForce
"""Core 3SPN2 + protein-DNA force-field terms.

Only the physical force-field forces are exported here; these are the forces
auto-added by ``System.add3SPN2forces`` / ``addProteinDNAforces``.

Opt-in biases and collective-variable readouts live in
:mod:`open3SPN2.force.bias` and :mod:`open3SPN2.force.collective_variables` and
are reached through :mod:`open3SPN2.optional_forces` (or imported directly from
those submodules), so an error in one of them cannot break ``import open3SPN2``.
"""

from .dna import Bond
from .dna import Angle
Expand All @@ -13,5 +21,3 @@

from .protein_dna import ExclusionProteinDNA
from .protein_dna import ElectrostaticsProteinDNA
from .protein_dna import AMHgoProteinDNA
from .protein_dna import String_length_ProteinDNA
Loading