[ase-users] Converting different format files
Matt Addicoat
madd.cluster at gmail.com
Tue Feb 13 16:43:38 CET 2018
Hi Rasoul,
A basic script can convert files using ASE. I've written one below.
You'll need argparse as well as ASE. Be careful, it doesn't do any error
checking in case one format cannot be converted to some other.
#!/usr/bin/python
from ase.atom import Atom
from ase.atoms import Atoms
from ase.io import read, write
import argparse
import os
parser = argparse.ArgumentParser(description="Translate any ASE-readable
file to any ASE-writable format")
parser.add_argument('inputfile', nargs="?", type=str, default="in.xyz",
help="input file, default=in.xyz")
parser.add_argument("-o", "--output-extn", type=str, default="gen",
help="extn (format) for the output molecule,
default=gen")
args = parser.parse_args()
file_name, file_extension = os.path.splitext(args.inputfile)
output=file_name+'.'+args.output_extn
mol = read(args.inputfile)
write(output,mol)
---
Save the script somewhere (e.g. myconvert.py) then you would use it by:
myconvert.py -o gen structure.xyz
Warm regards,
Matt
On 13/02/2018 15:10, Rasoul Khaledialidusti via ase-users wrote:
>
> To be honest, I have installed ASE and run the ase test successfully.
> But, I am wondering how I could use the capability of converting
> different file formats using ASE.
>
> I would appreciate you if you teach me the procedure of concerting
> files using ASE.
>
> Thanks a lot,
>
> Sincerely,
> Rasoul
>
>
>
> _______________________________________________
> ase-users mailing list
> ase-users at listserv.fysik.dtu.dk
> https://listserv.fysik.dtu.dk/mailman/listinfo/ase-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listserv.fysik.dtu.dk/pipermail/ase-users/attachments/20180213/21549cb6/attachment.html>
More information about the ase-users
mailing list