Пример #1
0
def test_compress():
    top = Topology.open(cwd + '/files/10-H2O-5-C3H6.lmp', improper_center=3)
    molecules = top.molecules
    for mol in molecules[4:]:
        for atom in mol.atoms:
            atom.charge *= 2

    top = Topology.open(cwd + '/files/Im11.zmat')
    molecules += top.molecules

    top = Topology.open(cwd + '/files/10-H2O-5-C3H6.lmp', improper_center=3)
    molecules += top.molecules

    top = Topology.open(cwd + '/files/Im11.zmat')
    molecules += top.molecules

    top = Topology()
    top.update_molecules(molecules)
    mols_unique = top.get_unique_molecules()
    for mol, count in mols_unique.items():
        print(str(mol), count)

    assert list(mols_unique.values()) == [4, 6, 5, 1, 10, 5, 1]
Пример #2
0
    if mol.n_atom > 1 and mol.n_bond == 0:
        if mol.has_position:
            logger.warning(f'{str(mol)} carries no bond. Guessing connectivity from FF')
            mol.guess_connectivity_from_ff(ff, angle_tolerance=15, pbc='xyz', cell=top.cell)
        else:
            logger.warning(f'{str(mol)} carries no bond. Make sure the topology is correct')

    if ff.is_polarizable:
        mol.generate_drude_particles(ff)
    if ff.has_virtual_site:
        mol.generate_virtual_sites(ff)
    mol.assign_mass_from_ff(ff)
    mol.assign_charge_from_ff(ff)

if args.packmol:
    top.update_molecules(list(mol_count.keys()))
    top.scale_with_packmol(list(mol_count.values()))
    sys.exit(0)

logger.info('Exporting ...')

top.update_molecules(list(mol_count.keys()), list(mol_count.values()))

if args.trj is None:
    logger.warning('Trajectory file not provided. '
                   'Will use positions and cell from the topology')
else:
    _positions_set = False
    if len(frame.positions) == top.n_atom:
        top.set_positions(frame.positions)
        _positions_set = True
Пример #3
0
                    type=float,
                    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.topology)
if args.topignore != []:
    molecules = [
        mol for mol in top.molecules if mol.name not in args.topignore
    ]
    top = Topology()
    top.update_molecules(molecules)
print('Topology info: ', top.n_atom, 'atoms;', top.n_molecule, 'molecules')
trj = Trajectory.open(args.input)
print('Trajectory info: ', trj.n_atom, 'atoms;', trj.n_frame, 'frames')

if (top.n_atom != trj.n_atom):
    raise Exception(
        'Number of atoms in topology and trajectory files do not match')

trj_out = Trajectory.open(args.output, 'w')

if args.ignore != []:
    subset = [
        atom.id for atom in top.atoms if atom.type not in args.ignoreatom
        and atom.molecule.name not in args.ignore
    ]