Skip to content

Commit e1098ba

Browse files
committed
Add loadCrystal convenience function.
Create Crystal object from a path to CIF file. This closes #8.
1 parent 5af28d3 commit e1098ba

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

pyobjcryst/__init__.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,19 @@
7171
import pyobjcryst.spacegroup
7272
import pyobjcryst.unitcell
7373
import pyobjcryst.zscatterer
74+
75+
76+
def loadCrystal(filename):
77+
"""Load pyobjcryst Crystal object from a CIF file.
78+
79+
filename -- CIF file to be loaded
80+
81+
Return a new Crystal object.
82+
83+
See pyobjcryst.crystal.CreateCrystalFromCIF for additional
84+
options for constructing Crystal object from CIF data.
85+
"""
86+
from pyobjcryst.crystal import CreateCrystalFromCIF
87+
with open(filename) as fp:
88+
rv = CreateCrystalFromCIF(fp)
89+
return rv

pyobjcryst/tests/pyobjcrysttestutils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def datafile(filename):
211211

212212

213213
def loadcifdata(filename):
214-
from pyobjcryst.crystal import CreateCrystalFromCIF
214+
from pyobjcryst import loadCrystal
215215
fullpath = datafile(filename)
216-
crst = CreateCrystalFromCIF(open(fullpath))
216+
crst = loadCrystal(fullpath)
217217
return crst

0 commit comments

Comments
 (0)