summaryrefslogtreecommitdiff
path: root/cad/src/experimental/namot/hack.py
blob: e188e2d101d94fc40a78c1d584090915bca6235b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Copyright 2006-2007 Nanorex, Inc.  See LICENSE file for details. 
import os, sys

seq = 'gattaca'
n = len(seq)
strands = 2
# NAMOT seems broken for one strand? Am I using it wrong?

#########################################################
#
# We will need to ask Paul R to help us understand these distortions.
# I can see what a few of them are doing, but not all.
#
# There is also a probable confusion bug between the "bu" and "pt"
# parameters. See src/input.c lines 1086 and 1102, and notice that
# they appear to be reversed, judging by the names of the fields they
# are changing.
#

# Base parameters
bu = 0.0   # twists the bases perpendicular to helical axis
op = 0.0
pt = 0.0    # makes the inner part of each base dip by that angle

# Unit parameters
# These are applied to the bases and sugars, but NOT to the phosphates??
dx = 0.0
dy = 0.0
dz = 0.0  # additional space between bases, unlike x and y, this is cumulative
twist = 0.0
tilt = 0.0    # does some kind of A-DNA-like twist that I don't get
roll = 10.0

###################################################

def use_pynamot():
    """NAMOT includes a Python interface (pynamot.so, pynamot.dll).
    We can use this (assuming NE-1 is able to find it), but there are
    possible license implications to doing it this way.
    """
    sys.path += ['/usr/local/libexec', '/usr/local/lib']
    import pynamot
    pynamot.Cmd('generate %s d b %s' % (" sd"[strands], seq))
    if True:
        pynamot.Cmd('modify unit dx g 1:1 1:%d %f' % (n, dx))
        pynamot.Cmd('modify unit dy g 1:1 1:%d %f' % (n, dy))
        pynamot.Cmd('modify unit dz g 1:1 1:%d %f' % (n, dz))
        pynamot.Cmd('modify unit twist g 1:1 1:%d %f' % (n, twist))
        pynamot.Cmd('modify unit tilt g 1:1 1:%d %f' % (n, tilt))
        pynamot.Cmd('modify unit roll g 1:1 1:%d %f' % (n, roll))

    pynamot.Cmd('write pdb foo.pdb')


def use_cmd_line():
    # The '-nogui' option comes from our special version of main.c.
    namot = os.popen('namot -nogui', 'w')
    namot.write('generate %s d b %s\n' % (" sd"[strands], seq))

    if False:
        namot.write('modify base bu 1:1:1 1:%d:%d %f\n' % (n, strands, bu))
        namot.write('modify base op 1:1:1 1:%d:%d %f\n' % (n, strands, op))
        namot.write('modify base pt 1:1:1 1:%d:%d %f\n' % (n, strands, pt))

    if True:
        namot.write('modify unit dx l 1:1 1:%d %f\n' % (n, dx))
        namot.write('modify unit dy l 1:1 1:%d %f\n' % (n, dy))
        namot.write('modify unit dz l 1:1 1:%d %f\n' % (n, dz))
        namot.write('modify unit twist l 1:1 1:%d %f\n' % (n, twist))
        namot.write('modify unit tilt l 1:1 1:%d %f\n' % (n, tilt))
        namot.write('modify unit roll l 1:1 1:%d %f\n' % (n, roll))

    namot.write('write pdb foo.pdb\n')
    namot.write('quit\n')
    namot.close()

use_cmd_line()
#use_pynamot()

#os.system('babel foo.pdb foo.mmp')

os.system('rasmol foo.pdb')