예제 #1
0
파일: cifio.py 프로젝트: chenweis/pymatgen
 def __init__(self, filename):
     """
     Args:
         filename - cif file name.  bzipped or gzipped cifs are fine too.
     """
     if isinstance(filename, basestring):
         with file_open_zip_aware(filename, "r") as f:
             self._cif = CifFile.ReadCif(f)
     else:
         self._cif = CifFile.ReadCif(filename)
예제 #2
0
파일: queen.py 프로젝트: chenweis/pymatgen
 def save_data(self, filename):
     """
     Save the assimilated data to a file.
     
     Args:
         filename:
             filename to save the assimilated data to. Note that if the
             filename ends with gz or bz2, the relevant gzip or bz2
             compression will be applied.
     """
     with file_open_zip_aware(filename, "w") as f:
         json.dump(list(self._data), f)
예제 #3
0
파일: queen.py 프로젝트: chenweis/pymatgen
 def load_data(self, filename):
     """
     Load assimilated data from a file
     """
     with file_open_zip_aware(filename, "r") as f:
         self._data = json.load(f)
예제 #4
0
excluded_bonding_elements = args.exclude_bonding[0].split(',') if args.exclude_bonding else []

file_format = args.format
filename = args.input_file[0]

s = None

if filename.endswith(".cif"):
    file_format = "cif"
elif filename.startswith("POSCAR"):
    file_format = "poscar"
elif re.search('\.json', filename):
    file_format = 'mpjson'


if file_format == 'poscar':
    p = Poscar.from_file(filename)
    s = p.struct
elif file_format == 'cif':
    r = CifParser(filename)
    s = r.get_structures(False)[0]
else:
    d = json.load(file_open_zip_aware(filename))
    ts = TransformedStructure.from_dict(d)
    s = ts.final_structure

if s:
    vis = StructureVis(excluded_bonding_elements=excluded_bonding_elements)
    vis.set_structure(s)
    vis.show()