Difference between revisions of "Save Mopac"

From PyMOLWiki
Jump to navigation Jump to search
(Created page with "{{Infobox script-repo |type = script |filename = save_mopac.py |author = Thomas Holder |license = Unknown }} = Overview = ''Save MOPAC'' attempts to...")
 
(moved to github, update license)
 
Line 3: Line 3:
 
|filename  = save_mopac.py
 
|filename  = save_mopac.py
 
|author    = [[User:Speleo3|Thomas Holder]]
 
|author    = [[User:Speleo3|Thomas Holder]]
|license  = Unknown
+
|license  = BSD-2-Clause
 
}}
 
}}
  
= Overview =
+
'''save_mopac''' attempts to save a PDB file in the MOPAC file format.
''Save MOPAC'' attempts to save a PDB file in the MOPAC file format.
 
  
<source lang="python">
+
== Usage ==
from pymol import cmd, CmdException
 
  
def save_mopac(filename, selection='all', zero='none', state=-1, quiet=1):
+
save_mopac filename [, selection [, zero [, state ]]]
    '''
 
DESCRIPTION
 
  
    Save to MOPAC format
+
[[Category:Script_Library]]
 
+
[[Category:ThirdParty_Scripts]]
ARGUMENTS
 
  
    filename = string: file path to be written
+
== See Also ==
 
    selection = string: atoms to save {default: all}
 
  
    zero = string: atoms to save with zero flag {default: none}
+
* [http://www.mail-archive.com/pymol-users@lists.sourceforge.net/msg10678.html thread on the pymol-users mailing list]
 
+
* [http://openmopac.net/ openmopac.net]
    state = integer: state to save {default: -1 (current state)}
 
    '''
 
    state, quiet = int(state), int(quiet)
 
 
 
    fmt = '%5s(%6i %3s%4i) %12.8f +%i %12.8f +%i %12.8f +%i %26.4f\n'
 
 
 
    zero_idx = set()
 
    cmd.iterate(zero, 'zero_idx.add((model,index))', space=locals())
 
 
 
    serial = [0]
 
    def callback(model, index, e, resn, resv, x, y, z, c):
 
        flag = 0 if (model, index) in zero_idx else 1
 
        serial[0] += 1
 
        handle.write(fmt % (e, serial[0], resn, resv,
 
            x, flag, y, flag, z, flag, c))
 
 
 
    with open(filename, 'w') as handle:
 
        cmd.iterate_state(state, selection,
 
                'callback(model, index, elem, resn, resv,'
 
                ' x, y, z, partial_charge)',
 
                space=locals())
 
 
 
    if not quiet:
 
        print ' Save-MOPAC: Wrote %i atoms to file' % (serial[0])
 
 
 
cmd.extend('save_mopac', save_mopac)</source>
 
 
 
[[Category:Script_Library]]
 
[[Category:ThirdParty_Scripts]]
 

Latest revision as of 17:50, 23 June 2012

Type Python Script
Download save_mopac.py
Author(s) Thomas Holder
License BSD-2-Clause
This code has been put under version control in the project Pymol-script-repo

save_mopac attempts to save a PDB file in the MOPAC file format.

Usage

save_mopac filename [, selection [, zero [, state ]]]

See Also