コード例 #1
0
ファイル: stapled.py プロジェクト: shanilpanara/origamiUROP
def main(length=17, n_strands=10, output_format='oxdna'):
    # generate a strand
    strands = []
    staples = []
    strand, staple = generate_helix(n=length, double=True)
    staples.append(staple.copy())
    strands.append(strand.copy())

    for i in range(n_strands - 1):

        last_nuc = strands[-1].nucleotides[-1]
        direction = -last_nuc._a3
        a1 = -last_nuc._a1

        # ensure the backbone position is FENE_LENGTH away from
        # the backbone position of the previous nucleotide
        start = last_nuc.pos_back + (FENE_LENGTH - POS_BACK) * a1

        # generate strand above that's going in opposite direction
        strand, staple = generate_helix(n=length,
                                        start_position=start,
                                        direction=direction,
                                        a1=a1,
                                        double=True)
        strands.append(strand.copy())
        staples.append(staple.copy())

    print(staples)

    # using the two previously created strands create a new strand that
    # we will add to the system
    nucleotides = []
    for strand in strands:
        nucleotides += strand.nucleotides
    strand = Strand(nucleotides=nucleotides)

    # create system and add the final completed strand
    system = System(np.array([50., 50., 50.]))
    system.add_strand(strand)

    # create staples from staple list
    # iterate over every 2 staples in reverse
    # and append the last onto the first, and add to the system
    staples = staples[::-1]
    completed_staples = []
    for i, staple in enumerate(staples):
        if i % 2 != 0:
            continue
        try:
            new_nucleotides = []
            new_nucleotides += staples[i + 1].nucleotides
            new_nucleotides += staple.nucleotides
            new_staple = Strand(nucleotides=new_nucleotides)
            system.add_strand(new_staple.copy())
        except IndexError:
            pass
    if output_format.lower() == 'oxdna':
        system.write_oxDNA('stapled_turns')
    elif output_format.lower() == 'lammps':
        system.write_lammps_data('stapled_turns')
コード例 #2
0
def main(length=16, n_strands=10):
    # generate a strand
    strands = []
    strand = generate_helix(n=length)[0]
    strands.append(strand.copy())

    for i in range(n_strands - 1):

        last_nuc = strands[-1].nucleotides[-1]
        direction = -last_nuc._a3
        a1 = -last_nuc._a1

        # ensure the backbone position is FENE_LENGTH away from
        # the backbone position of the previous nucleotide
        start = last_nuc.pos_back + (FENE_LENGTH - POS_BACK) * a1

        # generate strand above that's going in opposite direction
        strand = generate_helix(n=length,
                                start_position=start,
                                direction=direction,
                                a1=a1)[0]
        strands.append(strand)

    # using the two previously created strands create a new strand that
    # we will add to the system
    nucleotides = []
    for strand in strands:
        nucleotides += strand.nucleotides
    strand = Strand(nucleotides=nucleotides)

    # create system and add the final completed strand
    system = System(np.array([50., 50., 50.]))
    system.add_strand(strand)
    system.write_oxDNA('turns')
コード例 #3
0
def with_strands(N : int = 10):
    a1 = np.array([1., 0., 0.])
    start = np.array([0., 0., 0.]) + a1 * 0.6
    direction = np.array([0., 1., 0.])
    strands = generate_helix(
        n=N,
        start_position=start,
        direction=direction,
        a1=a1,
        initial_rotation=0.0,
    )
    new_position = start + (N) * 0.39 * direction
    new_direction = np.array([0.0, 1.0, 1.0]) / 2 ** 0.5
    new_a1 = np.array([0.0, -1.0, 1.0]) / 2 ** 0.5
    #print(np.dot(new_a1, new_direction))
    rotation = -0.06
    #rotation = 0.0

    strands += generate_helix(
        n=N,
        start_position=new_position,
        direction=new_direction,
        a1=new_a1,
        initial_rotation=rotation,
    )
    strand = Strand(strands[0].nucleotides + strands[1].nucleotides)
    return [strand]
コード例 #4
0
def test_generate_helix_seq():
    ssDNA_with_short_seq = generate_helix(n=10, sequence="AAA")
    strand = ssDNA_with_short_seq[0]

    assert len(strand.nucleotides) == 10
    assert strand.sequence[0:3] == "AAA"

    long_seq = "AGAT" * 5
    ssDNA_with_long_seq = generate_helix(n=10, sequence=long_seq)
    strand = ssDNA_with_long_seq[0]
    assert len(strand.nucleotides) == 10
    assert strand.sequence[0:11] == long_seq[0:10]
コード例 #5
0
def test_system():
    system = System(np.array([50., 50., 50.]))
    system.add_strands(generate_helix(10, double=True))
    print(system.lammps)
    print(system.bonds)

    return system
コード例 #6
0
ファイル: fiona_gen.py プロジェクト: FionaSander/origamiUROP
def generate_system(
        n : int,
        double_strand_length : int,
        single_strand_length : int,
        box : float = None,
    ) -> System:
    """
    Generates an oxDNA system containing a single piece of DNA
    which has blocks of equal size of double-stranded portions
    and single-stranded portions.

    Parameters:
        n - number of nucleotides e.g. 100
        fraction_ds - fraction of double-strand DNA e.g. 0.5
    
    Returns:
        system - oxDNA system
    """
    # initialise system to comply with minimum image convention
    if not box:
        box = 2. * n * FENE_EPS
    print(f'Creating simulation system with box size: {box}')
    system = System(np.array([box, box, box]))

    # create a list of strands, our main strand which we will use
    # and our complementary strand
    strands = generate_helix(n, double=True)
    
    # make a copy of the complementary strand and remove it 
    # from the main list of strands
    second_strand = strands[1].copy()
    strands = strands[:1]

    # calculate how many portions there should be
    portion_size = double_strand_length + single_strand_length
    portions = n // portion_size
    print(f'Creating {portions} portions of total size: {portion_size}')

    # iterate over all portions, adding a new complementary
    # strand to the list of strands we will use
    for i in range(portions):
        # take the nucleotides from each portion and
        # create a new strand for each double-stranded part
        # of the portion
        start = portion_size * i
        end = start + double_strand_length
        nucleotides = second_strand.nucleotides[start:end]
        new_strand = Strand(nucleotides=nucleotides)
        strands.append(new_strand)

    # finally add the strands to the system and return
    # the system
    system.add_strands(strands)
    return system
コード例 #7
0
def test_generate_helix_ds():
    dsDNA_helix = generate_helix(n=10, double=True, sequence="AGGGACGATG")

    assert type(dsDNA_helix) == list
    assert len(dsDNA_helix) == 2
    assert dsDNA_helix[0].sequence == "AGGGACGATG"
    # second strand should have reverse polarity, complementary pairs: T/A & C/G
    assert dsDNA_helix[1].sequence == "CATCGTCCCT"
    assert len(dsDNA_helix[0]) == len(dsDNA_helix[1])

    print("dsDNA: \n", dsDNA_helix[0], "\n", dsDNA_helix[1])
コード例 #8
0
def test_generate_helix_ss():
    ssDNA_helix = generate_helix(n=40, double=False)

    assert type(ssDNA_helix) == list
    assert len(ssDNA_helix) == 1
    assert len(ssDNA_helix[0]) == 40
    assert len(ssDNA_helix[0].nucleotides) == 40
    assert len(ssDNA_helix[0].dataframe.columns.values) == 9

    assert ssDNA_helix[0].index != 0  # required for .top oxDNA file
    assert ssDNA_helix[0].index == 1  # put here for explanatory purposes
    print("ssDNA: \n", ssDNA_helix[0])
コード例 #9
0
def long_strand() -> Strand:
    strands = generate_helix(20)
    return strands[0]