def read(fn, **kwargs):
ext = fn[fn.rfind('<STR_LIT:.>'):].split('<STR_LIT:@>')<EOL>if len(ext) == <NUM_LIT:1>:<EOL><INDENT>if ext[<NUM_LIT:0>] == '<STR_LIT>' or ext[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>dirname = os.path.dirname(fn)<EOL>if len(dirname) == <NUM_LIT:0>:<EOL><INDENT>dirname = '<STR_LIT:.>'<EOL><DEDENT>cycfn = dirname+'<STR_LIT>'<EOL>if os.path.exists(cycfn):<EOL><INDENT>return read_atoms(fn, cycfn=cycfn)<EOL><DEDENT>return read_atoms(fn)<EOL><DEDENT>elif ext[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>traj = NetCDFTrajectory(fn, **kwargs)<EOL>return traj[-<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>return ase.io.read(fn, **kwargs)<EOL><DEDENT><DEDENT>elif len(ext) == <NUM_LIT:2>:<EOL><INDENT>if ext[<NUM_LIT:0>] == '<STR_LIT>':<EOL><INDENT>frame = int(ext[<NUM_LIT:1>])<EOL>fn = fn[:fn.rfind('<STR_LIT:@>')]<EOL>traj = NetCDFTrajectory(fn)<EOL>return traj[frame]<EOL><DEDENT>else:<EOL><INDENT>return ase.io.read(fn, **kwargs)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return ase.io.read(fn, **kwargs)<EOL><DEDENT>
Convenience function: Detect file extension and read via Atomistica or ASE.
If reading a NetCDF files, frame numbers can be appended via '@'.
e.g., a = read('traj.nc@5')