-
Notifications
You must be signed in to change notification settings - Fork 0
/
DXseq.py
executable file
·1663 lines (1311 loc) · 50.9 KB
/
DXseq.py
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/python
import argparse
import os
import string
from math import *
import numpy as np
from linalg import *
# globally defined constants
STACK_NUM = 42 # length of base pair/ length of cylinder
RISE_ZERO = 3.4
PI = pi/180.
OMEGA_ZERO = 720.*PI/21.
RHO_ZERO = PI
TAU_ZERO = 0.
SLIDE_ZERO = 0.2
JNUM = 4
DIR = os.getcwd()
k = 1
m = 1
junction = np.array([12, 13, 28, 29])
###############################################################################
# read-in strand sequence
parser = argparse.ArgumentParser(description="produces PDB files of different \
types of DX tiles with/without hairpins",
formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument("tiletype", choices=['CR', 'STL', 'DTL', 'MDX'],
help="""choose between CR, STL, DTL, and MDX tile types.
CR : a single CR-type DX tile
STL : two DX tiles
DTL : three DX tiles
MDX : two connected regular DX tiles""")
parser.add_argument("-o", "--options", default='OO',
choices=['OO', 'OX', 'XO', 'XX'],
help="""OO : complementarity &\
geometric compatibility (default)
OX : complementarity & geometric incompatibility
XO : noncomplementarity & geometric compatibility
XX : noncomplementarity & geometric incompatibility
""")
parser.add_argument("-c", "--curvature", action="store_true",
help="""use experimental X-ray data for each nucleotide position
instead of idealized values""")
args = parser.parse_args()
if args.tiletype == 'STL':
tiletype = 'STL' + args.options
tiletype2 = None
elif args.tiletype == 'DTL':
tiletype = 'DTL' + args.options + '-1'
tiletype2 = 'DTL' + args.options + '-2'
elif args.tiletype == 'CR':
tiletype = 'CR'
tiletype2 = None
elif args.tiletype == 'MDX':
tiletype = 'MDX'
tiletype2 = None
# remove existing pdb files if they exist
if os.path.exists(DIR + r'/' + tiletype + '.pdb'):
os.remove(tiletype + '.pdb')
pdbfile = open(tiletype + ".pdb", "a")
###############################################################################
# assign strand sequences to duplexes
seq = []
with open(DIR + r"/DATA/sequence.txt") as seqfile:
for line in seqfile:
seq.append(line.rstrip())
dup1 = seq[seq.index(tiletype)+1]
dup2 = seq[seq.index(tiletype)+2]
if tiletype[0] == 'M':
dup3 = seq[seq.index(tiletype)+3]
dup4 = seq[seq.index(tiletype)+4]
# read-in hairpin sequence for ABB-type systems
if tiletype[0] == 'D':
dup3 = seq[seq.index(tiletype)+4]
dup4 = seq[seq.index(tiletype)+5]
if tiletype != 'DTLOO-1':
hp1 = seq[seq.index(tiletype)+6]
hp2 = seq[seq.index(tiletype)+7]
hp3 = hp1[:]
hp4 = hp2[:]
for i in range(STACK_NUM-len(hp1)):
hp1 += 'T'
for i in range(STACK_NUM-len(hp2)):
hp2 += 'T'
for i in range(STACK_NUM-len(hp3)):
hp3 += 'T'
for i in range(STACK_NUM-len(hp4)):
hp4 += 'T'
###############################################################################
# read-in parameters(omega,rho,tau,slide) of each base pairs
omegatable = []
rhotable = []
tautable = []
slidetable = []
with open(DIR + r'/DATA/domega.txt') as domega:
for line in domega:
omegatable.append(float(line.rstrip()))
with open(DIR + r'/DATA/drho.txt') as drho:
for line in drho:
rhotable.append(float(line.rstrip()))
with open(DIR + r'/DATA/dtau.txt') as dtau:
for line in dtau:
tautable.append(float(line.rstrip()))
with open(DIR + r'/DATA/dslide.txt') as dslide:
for line in dslide:
slidetable.append(float(line.rstrip()))
# read-in atom parameters
atom_name = []
with open(DIR + r"/DATA/atoms2.txt") as atomname_f:
for line in atomname_f:
atom_name.append(line.rstrip())
###############################################################################
def fbp_pos():
"""returns the coordinates of the first base pair,
same as 'coordinates' function in C except for index position
coordinates[base pair index][atom index][x,y,z index]
"""
coordinates = np.zeros((STACK_NUM, 164, 3))
temp_coordinates = []
with open(DIR + r'/DATA/AT.txt') as AT:
for line in AT:
temp_coordinates.append(map(float, line.rstrip().split()))
with open(DIR + r'/DATA/GC.txt') as GC:
for line in GC:
temp_coordinates.append(map(float, line.rstrip().split()))
with open(DIR + r'/DATA/CG.txt') as CG:
for line in CG:
temp_coordinates.append(map(float, line.rstrip().split()))
with open(DIR + r'/DATA/TA.txt') as TA:
for line in TA:
temp_coordinates.append(map(float, line.rstrip().split()))
coordinates[0] = temp_coordinates[:][:]
return coordinates
def calculate(coordinates, omega, rho, tau, slide, axis):
"""calculates the position of all atoms for all base pairs
with the atoms of the first base pair coordinates as the initial
coordinates
"""
R = np.identity(3, float)
sum_R = np.zeros(3)
sum_D = np.zeros(3)
# iteration between base pairs
for i in range(STACK_NUM-1):
R = transform(omega, rho, tau, R, i)
# normal vector of base pairs
sum_R[0] = sum_R[0]+R[2, 0]
sum_R[1] = sum_R[1]+R[2, 1]
sum_R[2] = sum_R[2]+R[2, 2]
# slide (D_y), slide[i] is the slide distance
sum_D[0] = sum_D[0]+slide[i]*R[1, 0]
sum_D[1] = sum_D[1]+slide[i]*R[1, 1]
sum_D[2] = sum_D[2]+slide[i]*R[1, 2]
############################################################
# leave the axis out for now
for k in range(3):
axis[i+1, k] = axis[0, 0]*R[0, k] + axis[0, 1]*R[1, k] +\
axis[0, 2]*R[2, k]
for k in range(3):
axis[i+1, k] += RISE_ZERO*(sum_R[k])+sum_D[k]
############################################################
# coordinates(1) = coordinates(0) * R_0
# coordinates(2) = coordinates(1) * R_1 = coordinates(0) * R_0 * R_1
# etc.
for j in range(164):
for k in range(3):
for l in range(3):
coordinates[i+1, j, k] += coordinates[0, j, l]*R[l, k]
coordinates[i+1, j, k] += RISE_ZERO*(sum_R[k])+sum_D[k]
return coordinates, axis
def caseselect(duplex, omega, rho, tau, slide):
duplex_c = "RABC"
duplex_x = "RY"
for i in range(STACK_NUM-3):
# the direction is always from 5' to 3',
# up one way and down the other backbone.
duplex_c = list(duplex_c)
if duplex[i] == 'A' or duplex[i] == 'G':
duplex_c[0] = duplex_x[0]
if duplex[i] == 'T' or duplex[i] == 'C':
duplex_c[0] = duplex_x[1]
duplex_c[1] = duplex[i+1]
duplex_c[2] = duplex[i+2]
if duplex[i+3] == 'A' or duplex[i+3] == 'G':
duplex_c[3] = duplex_x[0]
if duplex[i+3] == 'T' or duplex[i+3] == 'C':
duplex_c[3] = duplex_x[1]
duplex_c = ''.join(duplex_c)
if duplex_c == "RAAR" or duplex_c == "YTTY":
casenum = 0
elif duplex_c == "RAAY" or duplex_c == "RTTY":
casenum = 1
elif duplex_c == "YAAR" or duplex_c == "YTTR":
casenum = 2
elif duplex_c == "YAAY" or duplex_c == "RTTR":
casenum = 3
elif duplex_c == "RAGR" or duplex_c == "YCTY":
casenum = 4
elif duplex_c == "RAGY" or duplex_c == "RCTY":
casenum = 5
elif duplex_c == "YAGR" or duplex_c == "YCTR":
casenum = 6
elif duplex_c == "YAGY" or duplex_c == "RCTR":
casenum = 7
elif duplex_c == "RGAR" or duplex_c == "YTCY":
casenum = 8
elif duplex_c == "RGAY" or duplex_c == "RTCY":
casenum = 9
elif duplex_c == "YGAR" or duplex_c == "YTCR":
casenum = 10
elif duplex_c == "YGAY" or duplex_c == "RTCR":
casenum = 11
elif duplex_c == "RGGR" or duplex_c == "YCCY":
casenum = 12
elif duplex_c == "RGGY" or duplex_c == "RCCY":
casenum = 13
elif duplex_c == "YGGR" or duplex_c == "YCCR":
casenum = 14
elif duplex_c == "YGGY" or duplex_c == "RCCR":
casenum = 15
elif duplex_c == "RCAR" or duplex_c == "YTGY":
casenum = 16
elif duplex_c == "RCAY" or duplex_c == "RTGY":
casenum = 17
elif duplex_c == "YCAR" or duplex_c == "YTGR":
casenum = 18
elif duplex_c == "YCAY" or duplex_c == "RTGR":
casenum = 19
elif duplex_c == "RCGR" or duplex_c == "YCGY":
casenum = 20
elif duplex_c == "RCGY":
casenum = 21
elif duplex_c == "YCGR":
casenum = 22
elif duplex_c == "RTAR" or duplex_c == "YTAY":
casenum = 23
elif duplex_c == "RTAY":
casenum = 24
elif duplex_c == "YTAR":
casenum = 25
elif duplex_c == "RATR" or duplex_c == "YATY":
casenum = 26
elif duplex_c == "RATY":
casenum = 27
elif duplex_c == "YATR":
casenum = 28
elif duplex_c == "RACR" or duplex_c == "YGTY":
casenum = 29
elif duplex_c == "RACY" or duplex_c == "RGTY":
casenum = 30
elif duplex_c == "YACR" or duplex_c == "YGTR":
casenum = 31
elif duplex_c == "YACY" or duplex_c == "RGTR":
casenum = 32
elif duplex_c == "RGCR" or duplex_c == "YGCY":
casenum = 33
elif duplex_c == "RGCY":
casenum = 34
elif duplex_c == "YGCR":
casenum = 35
if args.curvature:
omega[i+1] = OMEGA_ZERO+omegatable[casenum]*PI
rho[i+1] = RHO_ZERO+rhotable[casenum]*PI
tau[i+1] = TAU_ZERO+tautable[casenum]*PI
slide[i+1] = SLIDE_ZERO+slidetable[casenum]
else:
omega[i+1] = OMEGA_ZERO
rho[i+1] = RHO_ZERO
tau[i+1] = TAU_ZERO
slide[i+1] = SLIDE_ZERO
omega[0] = OMEGA_ZERO
rho[0] = RHO_ZERO
tau[0] = TAU_ZERO
slide[0] = SLIDE_ZERO
omega[STACK_NUM-2] = OMEGA_ZERO
rho[STACK_NUM-2] = RHO_ZERO
tau[STACK_NUM-2] = TAU_ZERO
slide[STACK_NUM-2] = SLIDE_ZERO
return omega, rho, tau, slide
def backbone_modify(duplex, coordinates, duplexnum):
"""modifies the coordinates of the sugar and phosphate atoms of the DNA
so as to create the correct visual bonds in viewing programs
"""
theta = 20.*PI
angle = 2.5
R = np.identity(3, float)
STACK_NUM = 7
distcom = np.zeros(3)
unit = []
acom = np.zeros(3)
# 'unit' is a unit vector along the rotation axis
# iterate over all base pairs
# from 5' -> 3' up one side of the backbone
for i in range(STACK_NUM):
if duplex[i] == 'A':
theta = angle*PI
if (
(duplexnum == 1 and (i == 7 or i == 8)) or
(duplexnum == 2 and (i == 23 or i == 24))
):
theta = -angle*PI
############################################################
# create unit vector 'unit' along the axis of rotation
for j in range(3):
distcom[j] = coordinates[i, 10, j]-coordinates[i, 11, j]
# sum = distance(distcom, np.zeros(3))
sum = np.linalg.norm(distcom)
unit = []
for j in distcom:
unit.append(j/sum)
R = rot_matrix(unit, theta)
# check 'atoms2.txt' for atoms from 0<=j<10
for j in range(10):
# index changed
for k in range(3):
acom[k] = coordinates[i, j, k] - coordinates[i, 11, k]
# index changed
for k in range(3):
coordinates[i, j, k] =\
acom[0]*R[k, 0] + acom[1]*R[k, 1] +\
acom[2]*R[k, 2] + coordinates[i, 11, k]
elif duplex[i] == 'G':
theta = angle*PI
if (
(duplexnum == 1 and (i == 7 or i == 8)) or
(duplexnum == 2 and (i == 23 or i == 24))
):
theta = -angle*PI
############################################################
# create unit vector 'unit' along the axis of rotation
for j in range(3):
distcom[j] = coordinates[i, 51, j]-coordinates[i, 52, j]
# sum = distance(distcom, [0., 0., 0.])
sum = np.linalg.norm(distcom)
unit = []
for j in distcom:
unit.append(j/sum)
R = rot_matrix(unit, theta)
# check 'atoms2.txt' for atoms from 41<=j<51
for j in range(41, 51):
for k in range(3):
acom[k] = coordinates[i, j, k] - coordinates[i, 52, k]
for k in range(3):
coordinates[i, j, k] =\
acom[0]*R[k, 0] + acom[1]*R[k, 1] +\
acom[2]*R[k, 2] + coordinates[i, 52, k]
elif duplex[i] == 'C':
theta = angle*PI
if (
(duplexnum == 1 and (i == 7 or i == 8)) or
(duplexnum == 2 and (i == 23 or i == 24))
):
theta = -angle*PI
############################################################
# create unit vector 'unit' along the axis of rotation
for j in range(3):
distcom[j] = coordinates[i, 92, j] - coordinates[i, 93, j]
# sum = distance(distcom, [0., 0., 0.])
sum = np.linalg.norm(distcom)
unit = []
for j in distcom:
unit.append(j/sum)
R = rot_matrix(unit, theta)
for j in range(82, 92):
for k in range(3):
acom[k] = coordinates[i, j, k] - coordinates[i, 93, k]
for k in range(3):
coordinates[i, j, k] =\
acom[0]*R[k, 0] + acom[1]*R[k, 1] +\
acom[2]*R[k, 2] + coordinates[i, 93, k]
else:
theta = angle*PI
if (
(duplexnum == 1 and (i == 7 or i == 8)) or
(duplexnum == 2 and (i == 23 or i == 24))
):
theta = -angle*PI
############################################################
# create unit vector 'unit' along the axis of rotation
for j in range(3):
distcom[j] = coordinates[i, 133, j] - coordinates[i, 134, j]
# sum = distance(distcom, [0., 0., 0.])
sum = np.linalg.norm(distcom)
unit = []
for j in distcom:
unit.append(j/sum)
R = rot_matrix(unit, theta)
for j in range(123, 133):
for k in range(3):
acom[k] = coordinates[i, j, k] - coordinates[i, 134, k]
for k in range(3):
coordinates[i, j, k] =\
acom[0]*R[k, 0] + acom[1]*R[k, 1] +\
acom[2]*R[k, 2] + coordinates[i, 134, k]
# iterate over all base pairs
# from 3' -> 5' up the other side of the backbone (against the grain)
for i in range(STACK_NUM):
if duplex[i] == 'A':
theta = angle*PI
if (
(duplexnum == 2 and (i == 7 or i == 8)) or
(duplexnum == 1 and (i == 23 or i == 24))
):
theta = -angle*PI
for j in range(3):
distcom[j] = coordinates[i, 31, j]-coordinates[i, 32, j]
# sum = distance(distcom, [0., 0., 0.])
sum = np.linalg.norm(distcom)
unit = []
for j in distcom:
unit.append(j/sum)
R = rot_matrix(unit, theta)
# check 'atoms2.txt' for atoms from 21<=j<31
for j in range(21, 31):
for k in range(3):
acom[k] = coordinates[i, j, k] - coordinates[i, 32, k]
for k in range(3):
coordinates[i, j, k] =\
acom[0]*R[k, 0] + acom[1]*R[k, 1] +\
acom[2]*R[k, 2] + coordinates[i, 32, k]
elif duplex[i] == 'G':
theta = angle*PI
if (
(duplexnum == 2 and (i == 7 or i == 8)) or
(duplexnum == 1 and (i == 23 or i == 24))
):
theta = -angle*PI
for j in range(3):
distcom[j] = coordinates[i, 73, j]-coordinates[i, 74, j]
# sum = distance(distcom, [0., 0., 0.])
sum = np.linalg.norm(distcom)
unit = []
for j in distcom:
unit.append(j/sum)
R = rot_matrix(unit, theta)
# check 'atoms2.txt' for atoms from 63<=j<73
for j in range(63, 73):
for k in range(3):
acom[k] = coordinates[i, j, k] - coordinates[i, 74, k]
for k in range(3):
coordinates[i, j, k] =\
acom[0]*R[k, 0] + acom[1]*R[k, 1] +\
acom[2]*R[k, 2] + coordinates[i, 74, k]
elif duplex[i] == 'C':
theta = angle*PI
if (
(duplexnum == 2 and (i == 7 or i == 8)) or
(duplexnum == 1 and (i == 23 or i == 24))
):
theta = -angle*PI
for j in range(3):
distcom[j] = coordinates[i, 111, j]-coordinates[i, 112, j]
# sum = distance(distcom, [0., 0., 0.])
sum = np.linalg.norm(distcom)
unit = []
for j in distcom:
unit.append(j/sum)
R = rot_matrix(unit, theta)
for j in range(101, 111):
for k in range(3):
acom[k] = coordinates[i, j, k] - coordinates[i, 112, k]
for k in range(3):
coordinates[i, j, k] =\
acom[0]*R[k, 0] + acom[1]*R[k, 1] +\
acom[2]*R[k, 2] + coordinates[i, 112, k]
# T-base
else:
theta = angle*PI
if (
(duplexnum == 2 and (i == 7 or i == 8)) or
(duplexnum == 1 and (i == 23 or i == 24))
):
theta = -angle*PI
for j in range(3):
distcom[j] = coordinates[i, 153, j]-coordinates[i, 154, j]
# sum = distance(distcom, [0., 0., 0.])
sum = np.linalg.norm(distcom)
unit = []
for j in distcom:
unit.append(j/sum)
R = rot_matrix(unit, theta)
for j in range(143, 153):
for k in range(3):
acom[k] = coordinates[i, j, k] - coordinates[i, 154, k]
for k in range(3):
coordinates[i, j, k] =\
acom[0]*R[k, 0] + acom[1]*R[k, 1] +\
acom[2]*R[k, 2] + coordinates[i, 154, k]
return coordinates
def junction_builder(coord1, coord2, dup1, dup2, juncnum1, juncnum2, check):
dist1 = 9.
dist2 = 10.
R = [[int(i == j) for i in range(3)] for j in range(3)]
R2 = [[int(i == j) for i in range(3)] for j in range(3)]
if check == 53:
if dup1[juncnum1] == 'A':
m = 8
elif dup1[juncnum1] == 'G':
m = 49
elif dup1[juncnum1] == 'C':
m = 90
else:
m = 131
if dup2[juncnum2] == 'A':
n = 21
elif dup2[juncnum2] == 'G':
n = 63
elif dup2[juncnum2] == 'C':
n = 101
else:
n = 143
elif check == 35:
if dup1[juncnum1] == 'A':
m = 29
elif dup1[juncnum1] == 'G':
m = 71
elif dup1[juncnum1] == 'C':
m = 109
else:
m = 151
if dup2[juncnum2] == 'A':
n = 0
elif dup2[juncnum2] == 'G':
n = 41
elif dup2[juncnum2] == 'C':
n = 82
else:
n = 123
elif check == 55:
if dup1[juncnum1] == 'A':
m = 8
elif dup1[juncnum1] == 'G':
m = 49
elif dup1[juncnum1] == 'C':
m = 90
else:
m = 131
if dup2[juncnum2] == 'A':
n = 0
elif dup2[juncnum2] == 'G':
n = 41
elif dup2[juncnum2] == 'C':
n = 82
else:
n = 123
elif check == 33:
if dup1[juncnum1] == 'A':
m = 29
elif dup1[juncnum1] == 'G':
m = 71
elif dup1[juncnum1] == 'C':
m = 109
else:
m = 151
if dup2[juncnum2] == 'A':
n = 21
elif dup2[juncnum2] == 'G':
n = 63
elif dup2[juncnum2] == 'C':
n = 101
else:
n = 143
x1 = []
x2 = []
for i in range(3):
x1.append(coord2[juncnum2, n+4, i])
x2.append(coord2[juncnum2, n+5, i])
sum2 = distance(x1, x2)
unit2 = []
for i in range(3):
unit2.append((x1[i]-x2[i])/sum2)
theta2 = 1.*PI
R2 = rot_matrix(unit2, theta2)
while dist1 < dist2:
dist2 = dist1
for k in range(n, n+4):
acom2 = []
for l in range(3):
acom2.append(coord2[juncnum2, k, l]-coord2[juncnum2, n+5, l])
for l in range(3):
coord2[juncnum2, k, l] = acom2[0]*R2[l, 0] + \
acom2[1]*R2[l, 1] + acom2[2]*R2[l, 2] + \
coord2[juncnum2, n+5, l]
c1 = []
c2 = []
for i in range(3):
c1.append(coord1[juncnum1, m, i])
c2.append(coord2[juncnum2, n, i])
dist1 = distance(c1, c2)
x1 = []
x2 = []
for i in range(3):
x1.append(coord2[juncnum2, n+3, i])
x2.append(coord2[juncnum2, n+4, i])
sum = distance(x1, x2)
unit = []
for i in range(3):
unit.append((x1[i]-x2[i])/sum)
theta = 1.*PI
R = rot_matrix(unit, theta)
dist1 = 9.
dist2 = 10.
while(dist1 < dist2):
dist2 = dist1
for k in range(n, n+3):
acom2 = []
for l in range(3):
acom2.append(coord2[juncnum2, k, l]-coord2[juncnum2, n+4, l])
for l in range(3):
coord2[juncnum2, k, l] = acom2[0]*R[l, 0] +\
acom2[1]*R[l, 1] + acom2[2]*R[l, 2] +\
coord2[juncnum2, n+4, l]
c1 = []
c2 = []
for i in range(3):
c1.append(coord1[juncnum1, m, i])
c2.append(coord2[juncnum2, n, i])
dist1 = distance(c1, c2)
def makedxtile(coord1, coord2, dup1, dup2, junction):
bin = 11.
junction_bond = np.zeros(4)
moving_distance = np.zeros(3)
# bondrange = 1.9
for m in range(3):
md1 = coord1[junction[0], 8, m]
md2 = coord2[junction[0], 29, m]
md3 = coord1[junction[1], 8, m]
md4 = coord2[junction[1], 29, m]
md5 = coord1[junction[2], 29, m]
md6 = coord2[junction[2], 8, m]
md7 = coord1[junction[3], 29, m]
md8 = coord2[junction[3], 8, m]
moving_distance[m] = md1+md3+md5+md7-(md2+md4+md6+md8)
# md_sum = distance(moving_distance, [0., 0., 0.])
md_sum = np.linalg.norm(moving_distance)
for n in range(3):
moving_distance[n] *= bin/md_sum
# print "MD\t %f\n" % moving_distance[n]
for i in range(STACK_NUM):
for j in range(164):
for k in range(3):
coord1[i, j, k] -= moving_distance[k]
coord2[i, j, k] += moving_distance[k]
junction_builder(
coord1, coord2, dup1, dup2, junction[0], junction[0], 53)
junction_builder(
coord2, coord1, dup2, dup1, junction[1], junction[1], 35)
junction_builder(
coord2, coord1, dup2, dup1, junction[2], junction[2], 53)
junction_builder(
coord1, coord2, dup1, dup2, junction[3], junction[3], 35)
junction_builder(
coord1, coord1, dup1, dup1, junction[0]-1, junction[0], 55)
junction_builder(
coord2, coord2, dup1, dup1, junction[3]+1, junction[3], 33)
junction_builder(
coord2, coord2, dup2, dup2, junction[1]+1, junction[1], 55)
junction_builder(
coord1, coord1, dup2, dup2, junction[2]-1, junction[2], 33)
for i in range(4):
if i % 2 == 0:
# print "1st\n"
if dup1[junction[i]] == 'A':
m = 8
elif dup1[junction[i]] == 'G':
m = 49
elif dup1[junction[i]] == 'C':
m = 90
else:
m = 131
if dup2[junction[i]] == 'A':
n = 21
elif dup2[junction[i]] == 'G':
n = 63
elif dup2[junction[i]] == 'C':
n = 101
else:
n = 143
else:
# print "2nd\n"
if dup1[junction[i]] == 'A':
m = 29
elif dup1[junction[i]] == 'G':
m = 71
elif dup1[junction[i]] == 'C':
m = 109
else:
m = 151
if dup2[junction[i]] == 'A':
n = 0
elif dup2[junction[i]] == 'G':
n = 41
elif dup2[junction[i]] == 'C':
n = 82
else:
n = 123
x1 = []
x2 = []
for j in range(3):
x1.append(coord1[junction[i], m, j])
x2.append(coord2[junction[i], n, j])
junction_bond[i] = distance(x1, x2)
# while junction_bond[0]>bondrange or junction_bond[1]>bondrange or\
# junction_bond[2]>bondrange or junction_bond[3]>bondrange:
for i in range(STACK_NUM):
for j in range(164):
for k in range(3):
coord2[i, j, k] -= 0.1*moving_distance[k]
coord1[i, j, k] += 0.1*moving_distance[k]
for i in range(4):
if i == 0:
if dup1[junction[i]] == 'A':
m = 8
elif dup1[junction[i]] == 'G':
m = 49
elif dup1[junction[i]] == 'C':
m = 90
else:
m = 131
if dup2[junction[i]] == 'A':
n = 21
elif dup2[junction[i]] == 'G':
n = 63
elif dup2[junction[i]] == 'C':
n = 101
else:
n = 143
elif i == 3:
if dup1[junction[i]] == 'A':
m = 29
elif dup1[junction[i]] == 'G':
m = 71
elif dup1[junction[i]] == 'C':
m = 109
else:
m = 151
if dup2[junction[i]] == 'A':
n = 0
elif dup2[junction[i]] == 'G':
n = 41
elif dup2[junction[i]] == 'C':
n = 82
else:
n = 123
elif i == 2:
if dup2[junction[i]] == 'A':
m = 8
elif dup2[junction[i]] == 'G':
m = 49
elif dup2[junction[i]] == 'C':
m = 90
else:
m = 131
if dup1[junction[i]] == 'A':
n = 21
elif dup1[junction[i]] == 'G':
n = 63
elif dup1[junction[i]] == 'C':
n = 101
else:
n = 143
else: # i == 1
if dup2[junction[i]] == 'A':
m = 29
elif dup2[junction[i]] == 'G':
m = 71
elif dup2[junction[i]] == 'C':
m = 109
else:
m = 151
if dup1[junction[i]] == 'A':
n = 0