Ejemplo n.º 1
0
def test_write():
    zmat = Topology.open(cwd + '/files/Im11.zmat')
    tmp = os.path.join(tmpdir, 'zmat-out.xyz')
    zmat.write(tmp)
    assert filecmp.cmp(tmp, cwd + '/files/baselines/zmat-out.xyz')

    mol = Molecule.from_smiles('C[n+]1cn(cc1)CCCC[B-](F)(F)F')
    top = Topology([mol])
    tmp = os.path.join(tmpdir, 'smi-out.xyz')
    top.write(tmp)
    filecmp.cmp(tmp, cwd + '/files/baselines/smi-out.xyz')
Ejemplo n.º 2
0
def test_write_swm4():
    ff = ForceField.open(cwd + '/../forcefield/files/SWM4-NDP.zfp')
    mol = Topology.open(cwd + '/files/TIP3P.zmat').molecules[0]
    mol.generate_virtual_sites(ff)
    mol.generate_drude_particles(ff)
    mol.assign_charge_from_ff(ff)

    top = Topology([mol], numbers=[10])
    tmp = os.path.join(tmpdir, 'swm4-out.psf')
    top.write(tmp)

    assert filecmp.cmp(tmp, cwd + '/files/baselines/swm4-out.psf')
Ejemplo n.º 3
0
                    help='overwrite the box dimensions')
parser.add_argument('--shift',
                    nargs=3,
                    default=[0, 0, 0],
                    type=float,
                    help='shift the positions of all atoms')
args = parser.parse_args()

top = Topology.open(args.input)
if args.ignore != []:
    molecules = [mol for mol in top.molecules if mol.name not in args.ignore]
    top = Topology(molecules)
print('Topology info: ', top.n_atom, 'atoms;', top.n_molecule, 'molecules')

if args.qscale != 1:
    for atom in top.atoms:
        if atom.type in args.qscaleignoreatom or atom.molecule.name in args.qscaleignore:
            continue
        atom.charge *= args.qscale

box = [
    args.box[k] if args.box[k] != -1 else top.cell.size[k] for k in range(3)
]
top.cell.set_box(box)

if top.has_position and set(args.shift) != {0}:
    for atom in top.atoms:
        atom.position += args.shift

top.write(args.output)