summaryrefslogtreecommitdiff
path: root/cad/src/dna/updater/dna_updater_commands.py
blob: a04894a25bd2b2c2a8c3a7b126bd2dbc595c22e5 (plain)
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
# Copyright 2007-2008 Nanorex, Inc.  See LICENSE file for details. 
"""
dna_updater_commands.py - UI commands offered directly by the dna updater.

@author: Bruce
@version: $Id$
@copyright: 2007-2008 Nanorex, Inc.  See LICENSE file for details.
"""

from utilities.debug import register_debug_menu_command

from model.global_model_changedicts import _changed_structure_Atoms

import foundation.env as env

from platform_dependent.PlatformDependent import fix_plurals

from utilities.Log import greenmsg

from dna.model.pam3plus5_ops import add_basepair_handles_to_atoms #k import ok?

# ==

def initialize_commands():
    _register_our_debug_menu_commands()
    return

# ==

def rescan_atoms_in_current_part(assy, only_selected = False):
    oldlen = len(_changed_structure_Atoms)
    for mol in assy.molecules:
        for atom in mol.atoms.itervalues():
            if not only_selected or atom.picked or \
               (atom.is_singlet() and atom.singlet_neighbor().picked):
                _changed_structure_Atoms[atom.key] = atom
    newlen = len(_changed_structure_Atoms)
    msg = "len(_changed_structure_Atoms) %d -> %d" % (oldlen, newlen)
    env.history.message(greenmsg( "DNA debug command:") + " " + msg)
    assy.w.win_update() #bruce 080312 bugfix
    return

def rescan_all_atoms(glpane):
    rescan_atoms_in_current_part( glpane.assy)

def rescan_selected_atoms(glpane):
    rescan_atoms_in_current_part( glpane.assy, only_selected = True)

def add_basepair_handles_to_selected_atoms(glpane): #bruce 080515
    assy = glpane.assy
    goodcount, badcount = add_basepair_handles_to_atoms(assy.selatoms.values())
    msg = "adding handles to %d duplex Gv5 atom(s)" % (goodcount,)
    if badcount:
        msg += " (but not %d other selected atom(s))" % (badcount,)
    msg = fix_plurals(msg)
    env.history.message(greenmsg( "Add basepair handles:") + " " + msg)
    assy.w.win_update()
    return

# ==

def _register_our_debug_menu_commands():
    register_debug_menu_command( "DNA: rescan all atoms", rescan_all_atoms )
    register_debug_menu_command( "DNA: rescan selected atoms", rescan_selected_atoms )
    register_debug_menu_command( "DNA: add basepair handles", add_basepair_handles_to_selected_atoms )

# end