コード例 #1
0
 def png(self, filename, *args, **kwargs):
     '''
     Save image to filename, with antialias=0.
     '''
     cmd.unset('antialias')
     cmd.png(filename, *args, **kwargs)
     cmd.draw()
コード例 #2
0
def sculpt_relax(selection,
                 backbone=1,
                 neighbors=0,
                 model=None,
                 cycles=100,
                 state=0,
                 quiet=1):
    '''
DESCRIPTION

    Relax the given selection.

    SO FAR ONLY SUPPORTS SELECTIONS WITHIN THE SAME MODEL!

    Do 100 iterations, 75 of them with all terms but low VDW weights,
    and 25 with only local geometry terms. With default VDW weights and
    atom clashes, the structure gets distorted very easily!

USAGE

    sculpt_relax selection [, backbone [, neighbors [, model [, cycles ]]]]
    '''
    from pymol import selector

    backbone, neighbors = int(backbone), int(neighbors)
    cycles, state, quiet = int(cycles), int(state), int(quiet)

    sele = selector.process(selection)
    org = cmd.get_object_list(sele)[0]
    if model is None:
        model = org
    elif model != org:
        sele = sele.replace('(%s)' % org, '(%s)' % model)

    cmd.protect()
    cmd.deprotect(sele)
    if not backbone:
        cmd.protect('name CA+C+N+O+OXT')

    cmd.sculpt_activate(model, state)
    cmd.set('sculpt_vdw_weight', 0.25, model)  # Low VDW forces
    cmd.set('sculpt_field_mask', 0x1FF, model)  # Default

    if neighbors:
        cmd.sculpt_iterate(model, state, int(cycles * 0.25))
        cmd.deprotect('byres (%s within 6.0 of (%s))' % (model, sele))
        if not backbone:
            cmd.protect('name CA+C+N+O+OXT')
        cmd.sculpt_iterate(model, state, cycles=int(cycles * 0.50))
    else:
        cmd.sculpt_iterate(model, state, int(cycles * 0.75))

    cmd.set('sculpt_field_mask', 0x01F, model)  # Local Geometry Only
    cmd.sculpt_iterate(model, state, int(cycles * 0.25))

    cmd.unset('sculpt_vdw_weight', model)
    cmd.unset('sculpt_field_mask', model)
    cmd.sculpt_deactivate(model)
    cmd.deprotect()
コード例 #3
0
def wait_for(name, state=0, quiet=1):
    '''
DESCRIPTION

    Wait for "name" to be available as selectable object.
    '''
    if cmd.count_atoms('?' + name, 1, state) == 0:
        s = cmd.get_setting_boolean('suspend_updates')
        if s: cmd.unset('suspend_updates')
        cmd.refresh()
        if s: cmd.set('suspend_updates')
コード例 #4
0
ファイル: modelling.py プロジェクト: Rasinj/pymol-psico
def sculpt_relax(selection, backbone=1, neighbors=0, model=None, cycles=100,
        state=0, quiet=1):
    '''
DESCRIPTION

    Relax the given selection.

    SO FAR ONLY SUPPORTS SELECTIONS WITHIN THE SAME MODEL!

    Do 100 iterations, 75 of them with all terms but low VDW weights,
    and 25 with only local geometry terms. With default VDW weights and
    atom clashes, the structure gets distorted very easily!

USAGE

    sculpt_relax selection [, backbone [, neighbors [, model [, cycles ]]]]
    '''
    from pymol import selector

    backbone, neighbors = int(backbone), int(neighbors)
    cycles, state, quiet = int(cycles), int(state), int(quiet)

    sele = selector.process(selection)
    org = cmd.get_object_list(sele)[0]
    if model is None:
        model = org
    elif model != org:
        sele = sele.replace('(%s)' % org, '(%s)' % model)

    cmd.protect()
    cmd.deprotect(sele)
    if not backbone:
        cmd.protect('name CA+C+N+O+OXT')

    cmd.sculpt_activate(model, state)
    cmd.set('sculpt_vdw_weight', 0.25, model) # Low VDW forces
    cmd.set('sculpt_field_mask', 0x1FF, model) # Default

    if neighbors:
        cmd.sculpt_iterate(model, state, int(cycles * 0.25))
        cmd.deprotect('byres (%s within 6.0 of (%s))' % (model, sele))
        if not backbone:
            cmd.protect('name CA+C+N+O+OXT')
        cmd.sculpt_iterate(model, state, cycles=int(cycles * 0.50))
    else:
        cmd.sculpt_iterate(model, state, int(cycles * 0.75))

    cmd.set('sculpt_field_mask', 0x01F, model) # Local Geometry Only
    cmd.sculpt_iterate(model, state, int(cycles * 0.25))

    cmd.unset('sculpt_vdw_weight', model)
    cmd.unset('sculpt_field_mask', model)
    cmd.sculpt_deactivate(model)
    cmd.deprotect()
コード例 #5
0
ファイル: setting.py プロジェクト: schrodinger/pymol-testing
    def testSet(self, sele, name, value, defaultvalue):
        cmd.fragment('ala')
        cmd.set(name, value, sele)
        n = cmd.iterate('first (%s)' % (sele or 'all'), 'stored.v = s.' + name)
        self.assertEqual(n, 1)
        self.assertAlmostEqual(stored.v, value)

        if sele:
            cmd.unset(name, sele)
            n = cmd.iterate('first (%s)' % (sele or 'all'), 'stored.v = s.' + name)
            self.assertEqual(n, 1)
            self.assertEqual(stored.v, defaultvalue)
コード例 #6
0
ファイル: tmalign.py プロジェクト: GerhardR/Pymol-script-repo
def save_pdb_without_ter(filename, selection, **kwargs):
	'''
DESCRIPTION

    Save PDB file without TER records. External applications like TMalign and
    DynDom stop reading PDB files at TER records, which might be undesired in
    case of missing loops.
	'''
	v = cmd.get_setting_boolean('pdb_use_ter_records')
	if v: cmd.unset('pdb_use_ter_records')
	cmd.save(filename, selection, **kwargs)
	if v: cmd.set('pdb_use_ter_records')
コード例 #7
0
ファイル: tmalign.py プロジェクト: weitzner/dotfiles
def save_pdb_without_ter(filename, selection, **kwargs):
    '''
DESCRIPTION

    Save PDB file without TER records. External applications like TMalign and
    DynDom stop reading PDB files at TER records, which might be undesired in
    case of missing loops.
	'''
    v = cmd.get_setting_boolean('pdb_use_ter_records')
    if v: cmd.unset('pdb_use_ter_records')
    cmd.save(filename, selection, **kwargs)
    if v: cmd.set('pdb_use_ter_records')
コード例 #8
0
    def testSet(self, sele, name, value, defaultvalue):
        cmd.fragment('ala')
        cmd.set(name, value, sele)
        n = cmd.iterate('first (%s)' % (sele or 'all'), 'stored.v = s.' + name)
        self.assertEqual(n, 1)
        self.assertAlmostEqual(stored.v, value)

        if sele:
            cmd.unset(name, sele)
            n = cmd.iterate('first (%s)' % (sele or 'all'),
                            'stored.v = s.' + name)
            self.assertEqual(n, 1)
            self.assertEqual(stored.v, defaultvalue)
コード例 #9
0
ファイル: labelsettings.py プロジェクト: raruiz61/ProyectoHPC
def unset_label_settings(selection):
    # skipped: label_screen_point, label_position
    names = ["label_anchor", "label_angle_digits", "label_bg_color",
            "label_bg_outline", "label_bg_transparency", "label_color",
            "label_connector", "label_connector_color",
            "label_connector_ext_length", "label_connector_mode",
            "label_connector_width", "label_digits", "label_dihedral_digits",
            "label_distance_digits", "label_font_id",
            "label_multiline_justification", "label_multiline_spacing",
            "label_outline_color", "label_padding", "label_placement_offset",
            "label_relative_mode", "label_shadow_mode", "label_size"]
    for name in names:
        cmd.unset(name, selection)
コード例 #10
0
 def testGet(self):
     name_bool = 'cartoon_fancy_helices'
     name_obj = 'ala'
     cmd.fragment('ala', name_obj)
     cmd.set(name_bool, 1, name_obj)
     self.assertEqual('off', cmd.get(name_bool))
     self.assertEqual('on', cmd.get(name_bool, name_obj))
     cmd.unset(name_bool, '*')
     cmd.set(name_bool)
     self.assertEqual('on', cmd.get(name_bool))
     self.assertEqual('on', cmd.get(name_bool, name_obj))
     cmd.set(name_bool, 0, name_obj)
     self.assertEqual('on', cmd.get(name_bool))
     self.assertEqual('off', cmd.get(name_bool, name_obj))
コード例 #11
0
ファイル: setting.py プロジェクト: schrodinger/pymol-testing
 def testGet(self):
     name_bool = 'cartoon_fancy_helices'
     name_obj = 'ala'
     cmd.fragment('ala', name_obj)
     cmd.set(name_bool, 1, name_obj)
     self.assertEqual('off', cmd.get(name_bool))
     self.assertEqual('on', cmd.get(name_bool, name_obj))
     cmd.unset(name_bool, '*')
     cmd.set(name_bool)
     self.assertEqual('on', cmd.get(name_bool))
     self.assertEqual('on', cmd.get(name_bool, name_obj))
     cmd.set(name_bool, 0, name_obj)
     self.assertEqual('on', cmd.get(name_bool))
     self.assertEqual('off', cmd.get(name_bool, name_obj))
コード例 #12
0
def unset_label_settings(selection):
    # skipped: label_screen_point, label_position
    names = [
        "label_anchor", "label_angle_digits", "label_bg_color",
        "label_bg_outline", "label_bg_transparency", "label_color",
        "label_connector", "label_connector_color",
        "label_connector_ext_length", "label_connector_mode",
        "label_connector_width", "label_digits", "label_dihedral_digits",
        "label_distance_digits", "label_font_id",
        "label_multiline_justification", "label_multiline_spacing",
        "label_outline_color", "label_padding", "label_placement_offset",
        "label_relative_mode", "label_shadow_mode", "label_size"
    ]
    for name in names:
        cmd.unset(name, selection)
コード例 #13
0
ファイル: B10.py プロジェクト: Almad/pymol
def load():
   cmd.set("valence")
   cmd.unset("auto_zoom")
   cmd.zoom("center",100)
   r = 0
   list = glob("pdb/*/*")
#   while list[0]!="pdb/f8/pdb1f8u":
#      list.pop(0)
   for file in list:
      try:
         cmd.delete('pdb')
         cmd.load(file,'pdb')
         cmd.set_title('pdb',1,os.path.split(file)[-1])
         cmd.refresh()
      except:
         traceback.print_exc()
コード例 #14
0
ファイル: particle02.py プロジェクト: aghozlane/pymol
                     map(lambda x:(random()-0.5)*box_size/2,[0]*3) + # x,y,z
                    [random()+0.5] + # r
                    map(lambda x:(random()-0.5),[0]*3) # vx,vy,vz
                    )
        
# create cloud object

for part in particle:
    cmd.pseudoatom("cloud",
                   resi = part[0],
                   pos = part[1:4],
                   vdw = part[4])

# draw spheres efficiently
cmd.show_as("spheres")
cmd.unset("cull_spheres") 

# defer geometry generation until needed

cmd.set("defer_builds",1)

# position the camera

cmd.zoom()
cmd.zoom("center",box_size)

# let there be color

cmd.spectrum()

# this is the main loop
コード例 #15
0
ファイル: qutemol_style.py プロジェクト: rule-lab/lab-scripts
"""
A script for stylizing PyMOL structures similarly to QuteMol.
"""

from pymol import cmd, util

cmd.set_color('oxygen', [1.0,0.4,0.4])
cmd.set_color('nitrogen', [0.5,0.5,1.0])
cmd.set_color('carbon', [0.2,0.2,0.2])
cmd.set_color('hydrogen', [0.7,0.7,0.7])
cmd.hide('everything')
cmd.show('spheres')
cmd.hide('everything', 'solvent')
util.cbaw
cmd.bg_color(color='white')
cmd.set('light_count', '10')
cmd.set('spec_count', '1')
cmd.set('shininess', '10')
cmd.set('specular', '0.25')
cmd.set('ambient', '0')
cmd.set('direct', '0')
cmd.set('reflect', '1.5')
cmd.set('ray_shadow_decay_factor', '0.1')
cmd.set('ray_shadow_decay_range', '2')
cmd.unset('depth_cue')
コード例 #16
0
ファイル: make_figure.py プロジェクト: ocramz/docker-pymol
def make_figure(output='', mode='',size=900,opaque='transparent'):

	"""

AUTHOR

	Martin Christen


DESCRIPTION

	"make_figure" creates publication-quality figures of the current scene.
	It understands several predefined "modes" and sizes.


USAGE

	make_figure filename [, mode] [, size (default=900 pixels)] [,opaque]


ARGUMENTS

	mode = string: type of desired figure (single, fb, sides, stereo or -nothing-)
	size = integer: size of the figure in pixels OR # panels (if <= 12)
	opaque = specify an opaque background.
	         By default, the script makes the background transparent.
EXAMPLES

	make_figure output
	make_figure output, single, 975, opaque
	make_figure output, fb, 2
	make_figure output, sides,4
	make_figure output, stereo


NOTES

	"single" mode makes a single 300 dpi figure
	
	"fb" mode makes TWO 300 dpi figure
	("front" and "back", rotating by 180 degrees about y)
	
	"sides" mode makes FOUR 300 dpi figures
	("front" "left" "right" and back, rotating by 90 degrees clockwise about y)
	
	"stereo" generates two 300 dpi, 750 px figures
	("L" and "R", to be combined as a stereo image)
	If you specify the stereo mode, the size argument is IGNORED.
		
	If no mode argument is given, the script generates quick figures
	for general	use: TWO figures (front and back) at 300 x 300 px, 72 dpi.
	
	Size is interpreted as pixels, except if the number is ridiculously small
	(<=12),	in which case the script as "number of panels" to make.

	Edit the script manually to define corresponding values.
	
	"""

	#define sizes here (in pixels)
	panel1 = 1800
	panel2 = 1350
	panel3 = 900
	panel4 = 900
	panel5 = 750
	panel6 = 750
	panel7 = 675
	panel8 = 675
	panel9 = 600
	panel10 = 585
	panel11 = 585
	panel12 = 585
	
	#verify size is an integer number and convert to pixels
	size = int(size)
	if size > 12:
		pixels = size
	
	elif size == 1:
		pixels = panel1
	
	elif size == 2:
		pixels = panel2
	
	elif size == 3:
		pixels = panel3
	
	elif size == 4:
		pixels = panel4
	
	elif size == 5:
		pixels = panel5
	
	elif size == 6:
		pixels = panel6
	
	elif size == 7:
		pixels = panel7
	
	elif size == 8:
		pixels = panel8
	
	elif size == 9:
		pixels = panel9
	
	elif size == 10:
		pixels = panel10
	
	elif size == 11:
		pixels = panel11
	
	elif size == 3:
		pixels = panel12

	#change background
	cmd.unset('opaque_background')
	if opaque == 'opaque':
		cmd.set('opaque_background')
	
	#apply mode
	if output == '':
		print 'no output filename defined\n'
		print 'try: \'make_figure filename\''
		return -1
		# abort if no output file name given

	if mode =='':
		cmd.set('surface_quality',1)
		cmd.set('opaque_background')
		cmd.png(output+"_back_quick",300,300,dpi=72)
		cmd.turn('y',180)
		cmd.png(output+"_front_quick",300,300,dpi=72)
		cmd.turn('y',180)
		cmd.set('surface_quality',0)
		# make front and back figures for quick mode

	elif mode == 'single':
		cmd.set('surface_quality',1)
		cmd.set('ray_shadow',0)
		cmd.ray(pixels, pixels)
		cmd.png(output, dpi=300)
		cmd.set('surface_quality',0)
		# make a figure for single mode
		
	elif mode == 'fb':
		cmd.set('surface_quality',1)
		cmd.set('ray_shadow',0)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_front", dpi=300)
		cmd.turn('y',180)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_back", dpi=300)
		cmd.turn('y',180)
		cmd.set('surface_quality',0)
		# make front and back figures for single mode

	elif mode == 'sides':
		cmd.set('surface_quality',1)
		cmd.set('ray_shadow',0)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_1", dpi=300)
		cmd.turn('y',90)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_2", dpi=300)
		cmd.turn('y',90)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_3", dpi=300)
		cmd.turn('y',90)
		cmd.ray(pixels, pixels)
		cmd.png(output+"_4", dpi=300)
		cmd.turn('y',90)
		cmd.set('surface_quality',0)
		# make front and back figures for single mode
		
	elif mode == 'stereo':
		cmd.set('surface_quality',1)
		cmd.set('ray_shadow',0)
		cmd.ray(750, 750, angle=-3)
		cmd.png(output+"_R", dpi=300)
		cmd.ray(750, 750, angle=3)
		cmd.png(output+"_L", dpi=300)
コード例 #17
0
ファイル: modelling.py プロジェクト: Rasinj/pymol-psico
def peptide_rebuild(name, selection='all', cycles=1000, state=1, quiet=1):
    '''
DESCRIPTION

    Rebuild the peptide from selection. All atoms which are present in
    selection will be kept fixed, while atoms missing in selection are
    placed by sculpting.

USAGE

    peptide_rebuild name [, selection [, cycles [, state ]]]

SEE ALSO

    stub2ala, add_missing_atoms, peptide_rebuild_modeller
    '''
    from chempy import fragments, feedback, models

    cycles, state, quiet = int(cycles), int(state), int(quiet)

    # suppress feedback for model merging
    feedback['actions'] = False

    # work with named selection
    namedsele = cmd.get_unused_name('_')
    cmd.select(namedsele, selection, 0)

    identifiers = []
    cmd.iterate(namedsele + ' and polymer and guide and alt +A',
            'identifiers.append([segi,chain,resi,resv,resn])', space=locals())

    model = models.Indexed()
    for (segi,chain,resi,resv,resn) in identifiers:
        try:
            fname = resn.lower() if resn != 'MSE' else 'met'
            frag = fragments.get(fname)
        except IOError:
            print(' Warning: unknown residue:', resn)
            continue

        for a in frag.atom:
            a.segi = segi
            a.chain = chain
            a.resi = resi
            a.resi_number = resv
            a.resn = resn

        model.merge(frag)

    if not quiet:
        print(' Loading model...')

    cmd.load_model(model, name, 1, zoom=0)
    if cmd.get_setting_boolean('auto_remove_hydrogens'):
        cmd.remove(name + ' and hydro')

    cmd.protect(name + ' in ' + namedsele)
    cmd.sculpt_activate(name)
    cmd.update(name, namedsele, 1, state)
    cmd.delete(namedsele)

    if not quiet:
        print(' Sculpting...')

    cmd.set('sculpt_field_mask', 0x003, name) # bonds and angles only
    cmd.sculpt_iterate(name, 1, int(cycles / 4))

    cmd.set('sculpt_field_mask', 0x09F, name) # local + torsions
    cmd.sculpt_iterate(name, 1, int(cycles / 4))

    cmd.set('sculpt_field_mask', 0x0FF, name) # ... + vdw
    cmd.sculpt_iterate(name, 1, int(cycles / 2))

    cmd.sculpt_deactivate(name)
    cmd.deprotect(name)
    cmd.unset('sculpt_field_mask', name)

    if not quiet:
        print(' Connecting peptide...')

    pairs = cmd.find_pairs(name + ' and name C', name + ' and name N', 1, 1, 2.0)
    for pair in pairs:
        cmd.bond(*pair)
    cmd.h_fix(name)

    if not quiet:
        print(' peptide_rebuild: done')
コード例 #18
0
for resi in range(0, particle_count):
    particle.append([resi] +
                    map(lambda x: (random() - 0.5) * box_size / 2, [0] *
                        3) +  # x,y,z
                    [random() + 0.5] +  # r
                    map(lambda x: (random() - 0.5), [0] * 3)  # vx,vy,vz
                    )

# create cloud object

for part in particle:
    cmd.pseudoatom("cloud", resi=part[0], pos=part[1:4], vdw=part[4])

# draw spheres efficiently
cmd.show_as("spheres")
cmd.unset("cull_spheres")

# position the camera

cmd.zoom()
cmd.zoom("center", box_size)

# let there be color

cmd.spectrum()

# this is the main loop


def simulation():
    import traceback
コード例 #19
0
ファイル: make_figure.py プロジェクト: ocramz/docker-pymol
def make_figure(output='', mode='', size=900, opaque='transparent'):
    """

AUTHOR

	Martin Christen


DESCRIPTION

	"make_figure" creates publication-quality figures of the current scene.
	It understands several predefined "modes" and sizes.


USAGE

	make_figure filename [, mode] [, size (default=900 pixels)] [,opaque]


ARGUMENTS

	mode = string: type of desired figure (single, fb, sides, stereo or -nothing-)
	size = integer: size of the figure in pixels OR # panels (if <= 12)
	opaque = specify an opaque background.
	         By default, the script makes the background transparent.
EXAMPLES

	make_figure output
	make_figure output, single, 975, opaque
	make_figure output, fb, 2
	make_figure output, sides,4
	make_figure output, stereo


NOTES

	"single" mode makes a single 300 dpi figure
	
	"fb" mode makes TWO 300 dpi figure
	("front" and "back", rotating by 180 degrees about y)
	
	"sides" mode makes FOUR 300 dpi figures
	("front" "left" "right" and back, rotating by 90 degrees clockwise about y)
	
	"stereo" generates two 300 dpi, 750 px figures
	("L" and "R", to be combined as a stereo image)
	If you specify the stereo mode, the size argument is IGNORED.
		
	If no mode argument is given, the script generates quick figures
	for general	use: TWO figures (front and back) at 300 x 300 px, 72 dpi.
	
	Size is interpreted as pixels, except if the number is ridiculously small
	(<=12),	in which case the script as "number of panels" to make.

	Edit the script manually to define corresponding values.
	
	"""

    #define sizes here (in pixels)
    panel1 = 1800
    panel2 = 1350
    panel3 = 900
    panel4 = 900
    panel5 = 750
    panel6 = 750
    panel7 = 675
    panel8 = 675
    panel9 = 600
    panel10 = 585
    panel11 = 585
    panel12 = 585

    #verify size is an integer number and convert to pixels
    size = int(size)
    if size > 12:
        pixels = size

    elif size == 1:
        pixels = panel1

    elif size == 2:
        pixels = panel2

    elif size == 3:
        pixels = panel3

    elif size == 4:
        pixels = panel4

    elif size == 5:
        pixels = panel5

    elif size == 6:
        pixels = panel6

    elif size == 7:
        pixels = panel7

    elif size == 8:
        pixels = panel8

    elif size == 9:
        pixels = panel9

    elif size == 10:
        pixels = panel10

    elif size == 11:
        pixels = panel11

    elif size == 3:
        pixels = panel12

    #change background
    cmd.unset('opaque_background')
    if opaque == 'opaque':
        cmd.set('opaque_background')

    #apply mode
    if output == '':
        print 'no output filename defined\n'
        print 'try: \'make_figure filename\''
        return -1
        # abort if no output file name given

    if mode == '':
        cmd.set('surface_quality', 1)
        cmd.set('opaque_background')
        cmd.png(output + "_back_quick", 300, 300, dpi=72)
        cmd.turn('y', 180)
        cmd.png(output + "_front_quick", 300, 300, dpi=72)
        cmd.turn('y', 180)
        cmd.set('surface_quality', 0)
        # make front and back figures for quick mode

    elif mode == 'single':
        cmd.set('surface_quality', 1)
        cmd.set('ray_shadow', 0)
        cmd.ray(pixels, pixels)
        cmd.png(output, dpi=300)
        cmd.set('surface_quality', 0)
        # make a figure for single mode

    elif mode == 'fb':
        cmd.set('surface_quality', 1)
        cmd.set('ray_shadow', 0)
        cmd.ray(pixels, pixels)
        cmd.png(output + "_front", dpi=300)
        cmd.turn('y', 180)
        cmd.ray(pixels, pixels)
        cmd.png(output + "_back", dpi=300)
        cmd.turn('y', 180)
        cmd.set('surface_quality', 0)
        # make front and back figures for single mode

    elif mode == 'sides':
        cmd.set('surface_quality', 1)
        cmd.set('ray_shadow', 0)
        cmd.ray(pixels, pixels)
        cmd.png(output + "_1", dpi=300)
        cmd.turn('y', 90)
        cmd.ray(pixels, pixels)
        cmd.png(output + "_2", dpi=300)
        cmd.turn('y', 90)
        cmd.ray(pixels, pixels)
        cmd.png(output + "_3", dpi=300)
        cmd.turn('y', 90)
        cmd.ray(pixels, pixels)
        cmd.png(output + "_4", dpi=300)
        cmd.turn('y', 90)
        cmd.set('surface_quality', 0)
        # make front and back figures for single mode

    elif mode == 'stereo':
        cmd.set('surface_quality', 1)
        cmd.set('ray_shadow', 0)
        cmd.ray(750, 750, angle=-3)
        cmd.png(output + "_R", dpi=300)
        cmd.ray(750, 750, angle=3)
        cmd.png(output + "_L", dpi=300)
コード例 #20
0
def peptide_rebuild(name, selection='all', cycles=1000, state=1, quiet=1):
    '''
DESCRIPTION

    Rebuild the peptide from selection. All atoms which are present in
    selection will be kept fixed, while atoms missing in selection are
    placed by sculpting.

USAGE

    peptide_rebuild name [, selection [, cycles [, state ]]]

SEE ALSO

    stub2ala, add_missing_atoms, peptide_rebuild_modeller
    '''
    from chempy import fragments, feedback, models

    cycles, state, quiet = int(cycles), int(state), int(quiet)

    # suppress feedback for model merging
    feedback['actions'] = False

    # work with named selection
    namedsele = cmd.get_unused_name('_')
    cmd.select(namedsele, selection, 0)

    identifiers = []
    cmd.iterate(namedsele + ' and polymer and guide and alt +A',
            'identifiers.append([segi,chain,resi,resv,resn])', space=locals())

    model = models.Indexed()
    for (segi,chain,resi,resv,resn) in identifiers:
        try:
            fname = resn.lower() if resn != 'MSE' else 'met'
            frag = fragments.get(fname)
        except IOError:
            print(' Warning: unknown residue: ' + resn)
            continue

        for a in frag.atom:
            a.segi = segi
            a.chain = chain
            a.resi = resi
            a.resi_number = resv
            a.resn = resn

        model.merge(frag)

    if not quiet:
        print(' Loading model...')

    cmd.load_model(model, name, 1, zoom=0)
    if cmd.get_setting_boolean('auto_remove_hydrogens'):
        cmd.remove(name + ' and hydro')

    cmd.protect(name + ' in ' + namedsele)
    cmd.sculpt_activate(name)
    cmd.update(name, namedsele, 1, state)
    cmd.delete(namedsele)

    if not quiet:
        print(' Sculpting...')

    cmd.set('sculpt_field_mask', 0x003, name) # bonds and angles only
    cmd.sculpt_iterate(name, 1, int(cycles / 4))

    cmd.set('sculpt_field_mask', 0x09F, name) # local + torsions
    cmd.sculpt_iterate(name, 1, int(cycles / 4))

    cmd.set('sculpt_field_mask', 0x0FF, name) # ... + vdw
    cmd.sculpt_iterate(name, 1, int(cycles / 2))

    cmd.sculpt_deactivate(name)
    cmd.deprotect(name)
    cmd.unset('sculpt_field_mask', name)

    if not quiet:
        print(' Connecting peptide...')

    pairs = cmd.find_pairs(name + ' and name C', name + ' and name N', 1, 1, 2.0)
    for pair in pairs:
        cmd.bond(*pair)
    cmd.h_fix(name)

    if not quiet:
        print(' peptide_rebuild: done')