segmentmodel_example.py 1.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import numpy as np
from segmentmodel import SegmentModel, SingleStrandedSegment, DoubleStrandedSegment
from nbPot import nbDnaScheme

"""
Example of using segmentmodel to construct a CG

May need to execute after running:
PATH=/home/cmaffeo2/anaconda3/bin:$PATH; source activate cadnano 

"""



if __name__ == "__main__":

17
    seg1 = DoubleStrandedSegment("strand", num_bp = 46)
18
19

    seg2 = SingleStrandedSegment("strand", 
20
                                 start_position = seg1.end_position + np.array((5,0,5)),
21
22
23
                                 num_nts = 12)

    seg3 = SingleStrandedSegment("strand", 
24
25
                                 start_position = seg1.start_position + np.array((-5,0,-5)),
                                 end_position = seg1.end_position + np.array((-5,0,5)),
26
27
28
29
30
31
32
33
34
35
36
                                 num_nts = 128)

    seg1.start3
    seg1.start5
    seg1.end3
    seg1.end5

    seg1.connect_end3(seg2)     # equivalent for ssDNA to: seg1.connect_end3(seg2.end5)
    seg1.connect_end5(seg3)
    seg1.connect_start3(seg3)

cmaffeo2's avatar
cmaffeo2 committed
37
38
39
40
    model = SegmentModel( [seg1, seg2, seg3], 
                          local_twist = True,
                          max_basepairs_per_bead = 5,
                          max_nucleotides_per_bead = 5,
41
42
                          dimensions=(5000,5000,5000),
                      )
43

44
    model.simulate( outputPrefix = 'strand-test', outputPeriod=1e4, numSteps=1e6, gpu=1 )