|
| 1 | +atomium |
| 2 | +======= |
| 3 | + |
| 4 | +atomium is a molecular modeller and file parser. |
| 5 | + |
| 6 | +Example |
| 7 | +------- |
| 8 | + |
| 9 | + >>> import atomium |
| 10 | + >>> glucose = atomium.xyz_from_file("glucose.xyz") |
| 11 | + >>> glucose.comment() |
| 12 | + 'glucose from 2gbp' |
| 13 | + >>> glucose.model() |
| 14 | + <Model (12 atoms)> |
| 15 | + >>> glucose.model().mass() |
| 16 | + 168.0606 |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | + |
| 21 | + |
| 22 | +Installing |
| 23 | +---------- |
| 24 | + |
| 25 | +pip |
| 26 | +~~~ |
| 27 | + |
| 28 | +atomium can be installed using pip: |
| 29 | + |
| 30 | +``$ pip3 install atomium`` |
| 31 | + |
| 32 | +atomium is written for Python 3, and does not support Python 2. |
| 33 | + |
| 34 | +If you get permission errors, try using ``sudo``: |
| 35 | + |
| 36 | +``$ sudo pip3 install atomium`` |
| 37 | + |
| 38 | + |
| 39 | +Development |
| 40 | +~~~~~~~~~~~ |
| 41 | + |
| 42 | +The repository for atomium, containing the most recent iteration, can be |
| 43 | +found `here <http://github.com/samirelanduk/atomium/>`_. To clone the |
| 44 | +atomium repository directly from there, use: |
| 45 | + |
| 46 | +``$ git clone git://github.com/samirelanduk/atomium.git`` |
| 47 | + |
| 48 | + |
| 49 | +Requirements |
| 50 | +~~~~~~~~~~~~ |
| 51 | + |
| 52 | +atomium requires the Python library |
| 53 | +`geometrica <https://geometrica.samireland.com/>`_ - pip will install this |
| 54 | +automatically when it installs atomium. |
| 55 | + |
| 56 | + |
| 57 | +Overview |
| 58 | +-------- |
| 59 | + |
| 60 | +atomium allows you to open .xyz files, manipulate the model within, and save |
| 61 | +them as new .xyz files. |
| 62 | + |
| 63 | +From .xyz |
| 64 | +~~~~~~~~~ |
| 65 | + |
| 66 | +You can load a .xyz file as follows: |
| 67 | + |
| 68 | + >>> import atomium |
| 69 | + >>> glucose = atomium.xyz_from_file("glucose.xyz") |
| 70 | + >>> glucose.comment() |
| 71 | + 'glucose from 2gbp' |
| 72 | + >>> glucose.model() |
| 73 | + <Model (12 atoms)> |
| 74 | + |
| 75 | +The ``Xyz.comment`` property, |
| 76 | +which describes the file, and a ``Xyz.model`` property, which returns |
| 77 | +the ``Model`` the file describes. |
| 78 | + |
| 79 | +The Model |
| 80 | +~~~~~~~~~ |
| 81 | + |
| 82 | +A ``Model`` is a representation of some molecular system and every |
| 83 | +``Atom`` within it, as described by a file. |
| 84 | + |
| 85 | +As an ``AtomicStructure`` you can query its atoms, transform it in |
| 86 | +space, get its mass or formula, and get its centre of mass and radius of |
| 87 | +gyration: |
| 88 | + |
| 89 | + >>> model = glucose.model() |
| 90 | + >>> model.atoms() |
| 91 | + {<C Atom at (38.553, 30.4, 50.259)>, <C Atom at (35.884, 30.895, 49.12)>, <C A |
| 92 | + tom at (36.177, 29.853, 50.124)>, <C Atom at (37.296, 30.296, 51.074)>, <O Ato |
| 93 | + m at (39.261, 32.018, 46.92)>, <C Atom at (38.357, 31.29, 49.044)>, <C Atom at |
| 94 | + (39.559, 31.209, 48.082)>, <O Atom at (37.441, 29.265, 52.113)>, <O Atom at ( |
| 95 | + 34.923, 29.775, 50.91)>, <O Atom at (34.968, 30.34, 48.234)>, <O Atom at (37.1 |
| 96 | + 55, 30.858, 48.364)>, <O Atom at (39.572, 30.954, 51.086)>} |
| 97 | + >>> model.atoms(element="O") |
| 98 | + {<O Atom at (37.441, 29.265, 52.113)>, <O Atom at (39.261, 32.018, 46.92)>, <O |
| 99 | + Atom at (37.155, 30.858, 48.364)>, <O Atom at (34.968, 30.34, 48.234)>, <O At |
| 100 | + om at (34.923, 29.775, 50.91)>, <O Atom at (39.572, 30.954, 51.086)>} |
| 101 | + >>> model.atom(element="O") |
| 102 | + <O Atom at (37.441, 29.265, 52.113)> |
| 103 | + >>> model.mass() |
| 104 | + 168.0606 |
| 105 | + >>> model.formula() |
| 106 | + Counter({'C': 6, 'O': 6}) |
| 107 | + >>> model.translate(34, -12, 3.5) |
| 108 | + >>> model.rotate("x", 45) |
| 109 | + >>> model.atom(element="O") |
| 110 | + <O Atom at (71.441, -27.11613084494172, 51.53252799931321)> |
| 111 | + >>> model.center_of_mass() |
| 112 | + (71.39909500620611, -24.411126748628675, 50.69765860848817) |
| 113 | + >>> model.radius_of_gyration() |
| 114 | + 2.3076405766875925 |
| 115 | + |
| 116 | +``AtomicStructure.atoms` returns all matching elements as a ``set``` |
| 117 | +while ``AtomicStructure.atom`` returns the first matching atom. |
| 118 | + |
| 119 | +The atoms themselves have properties for their coordinates and elements, and |
| 120 | +also for finding the distance between them: |
| 121 | + |
| 122 | + >>> atom = model.atom(element="C") |
| 123 | + >>> atom.x(), atom.y(), atom.z() |
| 124 | + (72.553, -25.00258867597513, 51.02411822364008) |
| 125 | + >>> atom.element() |
| 126 | + 'C' |
| 127 | + >>> atom.distance_to(model.atom(element="O")) |
| 128 | + 2.4417381104450953 |
| 129 | + |
| 130 | +Instead of an atom, you can also provide a coordinate and get the atom's |
| 131 | +distance to that: |
| 132 | + |
| 133 | + >>> atom.distance_to(model.center_of_mass()) |
| 134 | + 1.3371237139950765 |
| 135 | + |
| 136 | + |
| 137 | +Saving |
| 138 | +~~~~~~ |
| 139 | + |
| 140 | +A model can be saved to file using: |
| 141 | + |
| 142 | + >>> model.save("new.xyz", description="Modifed glucose") |
| 143 | + |
| 144 | +The ``Xyz`` object itself can also be saved: |
| 145 | + |
| 146 | + >>> glucose.comment("Modified glucose") |
| 147 | + >>> glucose.save("new.xyz") |
| 148 | + |
| 149 | + |
| 150 | +Changelog |
| 151 | +--------- |
| 152 | + |
| 153 | +Release 0.1.0 |
| 154 | +~~~~~~~~~~~~~ |
| 155 | + |
| 156 | +`1 June 2017` |
| 157 | + |
| 158 | +* Added basic Model and Atom classes. |
| 159 | +* Added .xyz parsing. |
0 commit comments