enrgmd 2.6 KB
Newer Older
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
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import argparse
import re
import pathlib, os
import shutil
from mrdna import get_resource_path

parser = argparse.ArgumentParser(prog="mrdna",
				 description="""Easy multiresolution simulations of DNA nanotechnology objects using ARBD""")

parser.add_argument('-o','--output-prefix', type=str, default=None,
                    help="Name for your job's output")
parser.add_argument('-d','--directory', type=str,  default=None,
                    help='Directory for simulation; does not need to exist yet')
parser.add_argument('--backbone-scale', type=float, default=1.0,
                    help='Factor to scale DNA backbone in atomic model; try 0.25 to avoid clashes for atomistic simulations')

parser.add_argument('input_file', type=str,
                    help="""Any of the following:
                    (1) a cadnano JSON file;
                    (2) a vHelix Maya (.ma) file;
                    (3) an atomic PDB file""")

args = parser.parse_args()

if __name__ == '__main__':
    
    infile = pathlib.Path(args.input_file)
    try:
        prefix = infile.stem
        extension = ".".join(infile.suffixes)
    except:
        raise Exception("Unrecognized input file '{}'".format(infile))
        
    if extension == '.json':
        from mrdna.readers import read_cadnano as read_model
    elif extension == '.ma':
        from mrdna.readers import read_vhelix as read_model
    elif extension == '.pdb':
        from mrdna.readers import read_atomic_pdb as read_model
    else:
        raise Exception("Unrecognized input file '{}'".format(infile))
                    
    model = read_model( str(infile) )

    if args.output_prefix is not None:
        prefix = args.output_prefix
    directory = args.directory

    d_orig = os.getcwd()
    try:
        if directory is None:
            directory='.'
        elif not os.path.exists(directory):
            os.makedirs(directory)
        os.chdir(directory)

        print("""Generating your ENRG MD simulation files...
If your simulation results in any publications, please cite the following:
http://dx.doi.org/10.1093/nar/gkw155
""")
        model._clear_beads()
        model._generate_atomic_model(scale=args.backbone_scale)
        model.write_atomic_ENM( prefix )
        try:
            shutil.copytree( get_resource_path("charmm36.nbfix"), "charmm36.nbfix" )
        except FileExistsError:
            ...
        try:
            os.makedirs('output')
        except FileExistsError:
            ...
75
        model.atomic_simulate( output_name = prefix )
76
77
78
79
80
        
    except:
        raise
    finally:
        os.chdir(d_orig)