Exemple #1
0
 def test_log_targets(self):
     """Test python flags"""
     IMP.add_string_flag(
         "mystringflag",
         "mydefault",
         "Some string text")
     IMP.add_int_flag("myintflag", 3, "Some int text")
     IMP.add_bool_flag("myboolflag", "Some bool text")
     IMP.add_float_flag("myfloatflag", 10, "Some float text")
     extra = IMP.setup_from_argv(["python", "--mystringflag=hi",
                                       "--log_level=VERBOSE",
                                      "--myintflag=6", "--myfloatflag=-6.0",
                                       "--myboolflag", "zero", "one"],
                                      "test things",
                                      "arg0 arg1", 2)
     print(IMP.get_string_flag("mystringflag"))
     print(IMP.get_int_flag("myintflag"))
     print(IMP.get_float_flag("myfloatflag"))
     print(IMP.get_bool_flag("myboolflag"))
     print(IMP.get_log_level())
     print(extra)
     self.assertEqual(IMP.get_string_flag("mystringflag"), "hi")
     self.assertEqual(IMP.get_int_flag("myintflag"), 6)
     self.assertEqual(IMP.get_float_flag("myfloatflag"), -6.0)
     self.assertEqual(IMP.get_bool_flag("myboolflag"), True)
     self.assertEqual(extra[0], "zero")
     self.assertEqual(extra[1], "one")
Exemple #2
0
 def test_false_bool(self):
     """Test python bool flags are false by default"""
     IMP.add_bool_flag("myboolflag", "Some bool text")
     extra = IMP.setup_from_argv(["python", "zero", "one"],
                                      "test things",
                                      "arg0 arg1", 2)
     print(IMP.get_bool_flag("myboolflag"))
     print(IMP.get_log_level())
     print(extra)
     self.assertEqual(IMP.get_bool_flag("myboolflag"), False)
Exemple #3
0
 def test_log_targets(self):
     """Test python flags"""
     IMP.add_string_flag("mystringflag", "mydefault", "Some string text")
     IMP.add_int_flag("myintflag", 3, "Some int text")
     IMP.add_bool_flag("myboolflag", "Some bool text")
     IMP.add_float_flag("myfloatflag", 10, "Some float text")
     extra = IMP.setup_from_argv([
         "python", "--mystringflag=hi", "--log_level=VERBOSE",
         "--myintflag=6", "--myfloatflag=-6.0", "--myboolflag", "zero",
         "one"
     ], "test things", "arg0 arg1", 2)
     print(IMP.get_string_flag("mystringflag"))
     print(IMP.get_int_flag("myintflag"))
     print(IMP.get_float_flag("myfloatflag"))
     print(IMP.get_bool_flag("myboolflag"))
     print(IMP.get_log_level())
     print(extra)
     self.assertEqual(IMP.get_string_flag("mystringflag"), "hi")
     self.assertEqual(IMP.get_int_flag("myintflag"), 6)
     self.assertEqual(IMP.get_float_flag("myfloatflag"), -6.0)
     self.assertEqual(IMP.get_bool_flag("myboolflag"), True)
     self.assertEqual(extra[0], "zero")
     self.assertEqual(extra[1], "one")
Exemple #4
0
# addition, show how to visualize restraints and visualize the
# rejected conformations. Both are useful things to do when trying to
# figure out why optimization is not converging.

from __future__ import print_function
import IMP
import IMP.atom
import IMP.container
import IMP.display
import IMP.statistics
import IMP.example
import os
import sys

# not finished
IMP.add_bool_flag("run", "Whether to run the program")

# parse command line arguments so, eg profiling can be used
IMP.setup_from_argv(sys.argv, "Nup84 example")

if IMP.get_bool_flag("run") != "yes":
    exit(0)

# First we define some basic parameters for the modeling effort

# the spring constant to use, it doesn't really matter
k = 10
# the target resolution for the representation
resolution = 100
# the box to perform everything in, make it flat as it is a 2D structure
bb = IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(-300, -300, -50), IMP.algebra.Vector3D(300, 300, 50))
Exemple #5
0
def main():
    IMP.add_string_flag("input_rmf", "", "The input RMF file.")
    IMP.add_string_flag("output_rmf", "",
                        "The output RMF file in which to add cylinders.")
    IMP.add_string_flag(
        "ref_output", "",
        "reference output file from which info e.g. fg nup types can be extracted"
    )
    IMP.add_float_flag("radius", 5, "The radius of the cylinder.")
    IMP.add_float_flag("site_radius", 2, "The radius of the sites.")
    IMP.add_bool_flag("recolor_fgs", "recolor fg nup chains")
    IMP.add_bool_flag("recolor_floats",
                      "recolor floating (diffusing) molecules")
    IMP.add_int_flag(
        "smooth_n_frames", 1,
        "smooth by averaging over a window of specified frames (but retaining the same number of expected frames"
    )
    IMP.add_int_flag("skip_n_frames", 1, "skip every n frames of output")
    IMP.setup_from_argv(sys.argv, "Prettify a movie")
    in_fname = IMP.get_string_flag("input_rmf")
    out_fname = IMP.get_string_flag("output_rmf")
    ref_output = IMP.get_string_flag("ref_output")
    radius = IMP.get_float_flag("radius")
    # Prepare out file with same static info as in file:
    in_fh = RMF.open_rmf_file_read_only(in_fname)
    out_fh = RMF.create_rmf_file(out_fname)
    print("creating file", out_fname)
    RMF.clone_file_info(in_fh, out_fh)
    RMF.clone_hierarchy(in_fh, out_fh)
    RMF.clone_static_frame(in_fh, out_fh)
    print("opened", in_fh.get_name())
    cf = RMF.CylinderFactory(out_fh)
    rff = RMF.ReferenceFrameFactory(out_fh)
    tf = RMF.TypedFactory(out_fh)
    bf = RMF.BallFactory(out_fh)
    cdf = RMF.ColoredFactory(out_fh)
    ipf = RMF.IntermediateParticleFactory(out_fh)
    fg_types, kap_types, inert_types = _get_fg_and_floater_types(ref_output)
    #    out_fh.set_current_frame(RMF.ALL_FRAMES)
    # Modify static information:
    if (IMP.get_bool_flag("recolor_floats")):
        _recolor(out_fh.get_root_node(), tf, cdf, kap_types, kap_color)
        _recolor(out_fh.get_root_node(), tf, cdf, inert_types, inert_color)

    _resize_sites(out_fh.get_root_node(), bf,
                  IMP.get_float_flag("site_radius"))
    cylinders = []
    for i, fg_type in enumerate(fg_types):
        color = IMP.display.get_display_color(i)
        rgb = [color.get_red(), color.get_green(), color.get_blue()]
        print("Checking fg type", fg_type)
        cylinders += _add_nodes(out_fh.get_root_node(), cf, cdf, tf, [fg_type],
                                radius, rgb)  # fg_color
        if (IMP.get_bool_flag("recolor_fgs")):
            #            print "Recoloring",fg_type, rgb
            _recolor(out_fh.get_root_node(), tf, cdf, [fg_type],
                     rgb)  # fg_color
    # Clone and modify per-frame information:
    smooth_xyz_dict = {}
    smooth_n_frames = IMP.get_int_flag("smooth_n_frames")
    skip_n_frames = IMP.get_int_flag("skip_n_frames")
    print("Skip interval:", skip_n_frames, "frames")
    for f_id, f in enumerate(in_fh.get_frames()):
        is_write = f_id % skip_n_frames == 0
        in_fh.set_current_frame(f)
        if not is_write:
            if (smooth_n_frames > 1):
                _smooth(in_fh.get_root_node(),
                        tf,
                        rff,
                        smooth_xyz_dict,
                        n=smooth_n_frames,
                        is_write=False)
            print("skipping frame", f, f_id)
            continue
        print("cloning frame", f, f_id)
        out_fh.add_frame(in_fh.get_name(f), in_fh.get_type(f))
        RMF.clone_loaded_frame(in_fh, out_fh)
        if (smooth_n_frames > 1):
            _smooth(out_fh.get_root_node(),
                    tf,
                    rff,
                    smooth_xyz_dict,
                    n=smooth_n_frames,
                    is_write=True)
        for c in cylinders:
            _set_cylinder(c, cf, rff)
            if (IMP.get_bool_flag("recolor_fgs")):
                _recolor_cylinder(c, cf, cdf)
        DEBUG = False
        if DEBUG and f_id >= 5 * skip_n_frames:
            break
Exemple #6
0
def main():
    IMP.add_string_flag("input_rmf", "", "The input RMF file.")
    IMP.add_string_flag("output_rmf", "", "The output RMF file in which to add cylinders.")
    IMP.add_string_flag("ref_output", "", "reference output file from which info e.g. fg nup types can be extracted")
    IMP.add_float_flag("radius", 5, "The radius of the cylinder.")
    IMP.add_float_flag("site_radius", 2, "The radius of the sites.")
    IMP.add_bool_flag("recolor_fgs", "recolor fg nup chains")
    IMP.add_bool_flag("recolor_floats", "recolor floating (diffusing) molecules")
    IMP.add_int_flag("smooth_n_frames", 1,
                     "smooth by averaging over a window of specified frames (but retaining the same number of expected frames")
    IMP.add_int_flag("skip_n_frames", 1,
                     "skip every n frames of output")
    IMP.setup_from_argv(sys.argv, "Prettify a movie")
    in_fname= IMP.get_string_flag("input_rmf")
    out_fname= IMP.get_string_flag("output_rmf")
    ref_output = IMP.get_string_flag("ref_output")
    radius= IMP.get_float_flag("radius")
    # Prepare out file with same static info as in file:
    in_fh = RMF.open_rmf_file_read_only(in_fname)
    out_fh = RMF.create_rmf_file(out_fname)
    print("creating file", out_fname)
    RMF.clone_file_info(in_fh, out_fh)
    RMF.clone_hierarchy(in_fh, out_fh)
    RMF.clone_static_frame(in_fh, out_fh)
    print("opened", in_fh.get_name())
    cf = RMF.CylinderFactory(out_fh)
    rff = RMF.ReferenceFrameFactory(out_fh)
    tf = RMF.TypedFactory(out_fh)
    bf = RMF.BallFactory(out_fh)
    cdf = RMF.ColoredFactory(out_fh)
    ipf = RMF.IntermediateParticleFactory(out_fh)
    fg_types, kap_types, inert_types = _get_fg_and_floater_types( ref_output )
#    out_fh.set_current_frame(RMF.ALL_FRAMES)
    # Modify static information:
    if(IMP.get_bool_flag("recolor_floats")):
        _recolor(out_fh.get_root_node(), tf, cdf, kap_types, kap_color)
        _recolor(out_fh.get_root_node(), tf, cdf, inert_types, inert_color)

    _resize_sites(out_fh.get_root_node(), bf, IMP.get_float_flag("site_radius"))
    cylinders = []
    for i, fg_type in enumerate(fg_types):
        color = IMP.display.get_display_color(i)
        rgb = [color.get_red(), color.get_green(), color.get_blue()]
        print("Checking fg type", fg_type)
        cylinders += _add_nodes(out_fh.get_root_node(), cf, cdf, tf, [fg_type], radius, rgb) # fg_color
        if(IMP.get_bool_flag("recolor_fgs")):
            #            print "Recoloring",fg_type, rgb
            _recolor(out_fh.get_root_node(), tf, cdf, [fg_type], rgb) # fg_color
    # Clone and modify per-frame information:
    smooth_xyz_dict={}
    smooth_n_frames=IMP.get_int_flag("smooth_n_frames")
    skip_n_frames=IMP.get_int_flag("skip_n_frames")
    print("Skip interval:", skip_n_frames, "frames")
    for f_id, f in enumerate(in_fh.get_frames()):
        is_write= f_id % skip_n_frames == 0
        in_fh.set_current_frame(f)
        if not is_write:
            if(smooth_n_frames>1):
                _smooth(in_fh.get_root_node(),
                        tf,
                        rff,
                        smooth_xyz_dict,
                        n=smooth_n_frames,
                        is_write=False)
            print("skipping frame", f, f_id)
            continue
        print("cloning frame", f, f_id)
        out_fh.add_frame(in_fh.get_name(f), in_fh.get_type(f))
        RMF.clone_loaded_frame(in_fh, out_fh)
        if(smooth_n_frames>1):
            _smooth(out_fh.get_root_node(),
                    tf,
                    rff,
                    smooth_xyz_dict,
                    n=smooth_n_frames,
                    is_write=True)
        for c in cylinders:
            _set_cylinder(c, cf, rff)
        DEBUG=False
        if DEBUG and f_id >= 5*skip_n_frames:
            break
Exemple #7
0
# addition, show how to visualize restraints and visualize the
# rejected conformations. Both are useful things to do when trying to
# figure out why optimization is not converging.

from __future__ import print_function
import IMP
import IMP.atom
import IMP.container
import IMP.display
import IMP.statistics
import IMP.example
import os
import sys

# not finished
IMP.add_bool_flag("run", "Whether to run the program")

# parse command line arguments so, eg profiling can be used
IMP.setup_from_argv(sys.argv, "Nup84 example")

if IMP.get_bool_flag("run") != "yes":
    exit(0)

# First we define some basic parameters for the modeling effort

# the spring constant to use, it doesn't really matter
k = 10
# the target resolution for the representation
resolution = 100
# the box to perform everything in, make it flat as it is a 2D structure
bb = IMP.algebra.BoundingBox3D(IMP.algebra.Vector3D(-300, -300, -50),