@@ -7,8 +7,85 @@ them as new .xyz files.
77From .xyz
88~~~~~~~~~
99
10+ You can load a .xyz file as follows:
11+
12+ >>> import atomium
13+ >>> glucose = atomium.xyz_from_file(" glucose.xyz" )
14+ >>> glucose.comment()
15+ 'glucose from 2gbp'
16+ >>> glucose.model()
17+ <Model (12 atoms)>
18+
19+ The :py:class: `.Xyz ` object you get has a :py:meth: `~.Xyz.comment ` property,
20+ which describes the file, and a :py:meth: `~.Xyz.model ` property, which returns
21+ the :py:class: `.Model ` the file describes.
22+
1023The Model
1124~~~~~~~~~
1225
26+ A :py:class: `.Model ` is a representation of some molecular system and every
27+ :py:class: `.Atom ` within it, as described by a file.
28+
29+ As an :py:class: `.AtomicStructure ` you can query its atoms, transform it in
30+ space, get its mass or formula, and get its centre of mass and radius of
31+ gyration:
32+
33+ >>> model = glucose.model()
34+ >>> model.atoms()
35+ {<C Atom at (38.553, 30.4, 50.259)>, <C Atom at (35.884, 30.895, 49.12)>, <C A
36+ tom at (36.177, 29.853, 50.124)>, <C Atom at (37.296, 30.296, 51.074)>, <O Ato
37+ m at (39.261, 32.018, 46.92)>, <C Atom at (38.357, 31.29, 49.044)>, <C Atom at
38+ (39.559, 31.209, 48.082)>, <O Atom at (37.441, 29.265, 52.113)>, <O Atom at (
39+ 34.923, 29.775, 50.91)>, <O Atom at (34.968, 30.34, 48.234)>, <O Atom at (37.1
40+ 55, 30.858, 48.364)>, <O Atom at (39.572, 30.954, 51.086)>}
41+ >>> model.atoms(element = " O" )
42+ {<O Atom at (37.441, 29.265, 52.113)>, <O Atom at (39.261, 32.018, 46.92)>, <O
43+ Atom at (37.155, 30.858, 48.364)>, <O Atom at (34.968, 30.34, 48.234)>, <O At
44+ om at (34.923, 29.775, 50.91)>, <O Atom at (39.572, 30.954, 51.086)>}
45+ >>> model.atom(element = " O" )
46+ <O Atom at (37.441, 29.265, 52.113)>
47+ >>> model.mass()
48+ 168.0606
49+ >>> model.formula()
50+ Counter({'C': 6, 'O': 6})
51+ >>> model.translate(34 , - 12 , 3.5 )
52+ >>> model.rotate(" x" , 45 )
53+ >>> model.atom(element = " O" )
54+ <O Atom at (71.441, -27.11613084494172, 51.53252799931321)>
55+ >>> model.center_of_mass()
56+ (71.39909500620611, -24.411126748628675, 50.69765860848817)
57+ >>> model.radius_of_gyration()
58+ 2.3076405766875925
59+
60+ :py:meth: `~.AtomicStructure.atoms ` returns all matching elements as a ``set ``
61+ while :py:meth: `~.AtomicStructure.atom ` returns the first matching atom.
62+
63+ The atoms themselves have properties for their coordinates and elements, and
64+ also for finding the distance between them:
65+
66+ >>> atom = model.atom(element = " C" )
67+ >>> atom.x(), atom.y(), atom.z()
68+ (72.553, -25.00258867597513, 51.02411822364008)
69+ >>> atom.element()
70+ 'C'
71+ >>> atom.distance_to(model.atom(element = " O" ))
72+ 2.4417381104450953
73+
74+ Instead of an atom, you can also provide a coordinate and get the atom's
75+ distance to that:
76+
77+ >>> atom.distance_to(model.center_of_mass())
78+ 1.3371237139950765
79+
80+
1381Saving
1482~~~~~~
83+
84+ A model can be saved to file using:
85+
86+ >>> model.save(" new.xyz" , description = " Modifed glucose" )
87+
88+ The ``Xyz `` object itself can also be saved:
89+
90+ >>> glucose.comment(" Modified glucose" )
91+ >>> glucose.save(" new.xyz" )
0 commit comments