/usr/share/pyshared/ase/io/nwchem.py is in python-ase 3.6.0.2515-1.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
| 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 | from cStringIO import StringIO
from ase.atoms import Atoms
from ase.io.xyz import read_xyz
def read_nwchem(filename):
    """Method to read geometry from a nwchem output
    """
    from ase import Atoms, Atom
    if isinstance(filename, str):
        f = open(filename)
    lines = f.readlines()
    i = 0
    while i < len(lines):
        if lines[i].find('XYZ format geometry') >=0:
            natoms = int(lines[i + 2].split()[0])
            string = ''
            for j in range(2, natoms + 4):
                xyzstring = lines[i + j]
                symbol = xyzstring.split()[0].strip()
                # replace bq ghost with X: MDTMP can we do better?
                if symbol.startswith('bq'):
                    xyzstring = xyzstring.replace(symbol, 'X')
                string += xyzstring
            atoms = read_xyz(StringIO(string))
            i += natoms + 4
        else:
            i += 1
    if type(filename) == str:
        f.close()
    return atoms
def write_nwchem(filename, atoms, geometry=None):
    """Method to write nwchem coord file
    """
    import numpy as np
    if isinstance(filename, str):
        f = open(filename, 'w')
    else: # Assume it's a 'file-like object'
        f = filename
    # autosym and autoz are defaults
    # http://www.nwchem-sw.org/index.php/Geometry
    # geometry noautoz results in higher memory demand!
    # http://www.emsl.pnl.gov/docs/nwchem/nwchem-support/2010/10/0060.RE:_NWCHEM_Geometry_problem_fwd_
    if geometry is not None:
        f.write('geometry ' + str(geometry) + '\n')
    else:
        f.write('geometry\n')
    for atom in atoms:
        if atom.tag == -71: # 71 is ascii G (Ghost)
            symbol = 'bq' + atom.symbol
        else:
            symbol = atom.symbol
        f.write('  ' + symbol + ' ' +
                str(atom.position[0]) + ' ' +
                str(atom.position[1]) + ' ' +
                str(atom.position[2]) + '\n' )
    f.write('end\n')
 |