=======
emtable
=======
Emtable is a STAR file parser originally developed to simplify and speed up metadata conversion between Scipion and Relion. It is available as a small self-contained Python module (https://pypi.org/project/emtable/) and can be used to manipulate STAR files independently from Scipion.
How to cite
-----------
Please cite the code repository DOI: `10.5281/zenodo.4303966 <https://zenodo.org/record/4303966>`_
Authors
-------
* Jose Miguel de la Rosa-TrevĂn, Department of Biochemistry and Biophysics, Science for Life Laboratory, Stockholm University, Stockholm, Sweden
* Grigory Sharov, MRC Laboratory of Molecular Biology, Cambridge Biomedical Campus, England
Testing
-------
``python3 -m unittest discover emtable/tests``
Examples
--------
To start using the package, simply do:
.. code-block:: python
from emtable import Table
Each table in STAR file usually has a *data\_* prefix. You only need to specify the remaining table name:
``Table(fileName=modelStar, tableName='perframe_bfactors')``
Be aware that from Relion 3.1 particles table name has been changed from "data_Particles" to "data_particles".
Reading
#######
For example, we want to read the whole *rlnMovieFrameNumber* column from modelStar file, table *data_perframe_bfactors*.
The code below will return a list of column values from all rows:
.. code-block:: python
table = Table(fileName=modelStar, tableName='perframe_bfactors')
frame = table.getColumnValues('rlnMovieFrameNumber')
We can also iterate over rows from "data_particles" Table:
.. code-block:: python
table = Table(fileName=dataStar, tableName='particles')
for row in table:
print(row.rlnRandomSubset, row.rlnClassNumber)
Alternatively, you can use **iterRows** method which also supports sorting by a column:
.. code-block:: python
mdIter = Table.iterRows('particles@' + fnStar, key='rlnImageId')
If for some reason you need to clear all rows and keep just the Table structure, use **clearRows()** method on any table.
Writing
#######
If we want to create a new table with 3 pre-defined columns, add rows to it and save as a new file:
.. code-block:: python
tableShifts = Table(columns=['rlnCoordinateX',
'rlnCoordinateY',
'rlnAutopickFigureOfMerit',
'rlnClassNumber'])
tableShifts.addRow(1024.54, 2944.54, 0.234, 3)
tableShifts.addRow(445.45, 2345.54, 0.266, 3)
tableShifts.write(f, tableName="test", singleRow=False)
*singleRow* is **False** by default. If *singleRow* is **True**, we don't write a *loop_*, just label-value pairs. This is used for "one-column" tables, such as below:
.. code-block:: bash
data_general
_rlnImageSizeX 3710
_rlnImageSizeY 3838
_rlnImageSizeZ 24
_rlnMicrographMovieName Movies/20170629_00026_frameImage.tiff
_rlnMicrographGainName Movies/gain.mrc
_rlnMicrographBinning 1.000000
_rlnMicrographOriginalPixelSize 0.885000
_rlnMicrographDoseRate 1.277000
_rlnMicrographPreExposure 0.000000
_rlnVoltage 200.000000
_rlnMicrographStartFrame 1
_rlnMotionModelVersion 1
Raw data
{
"_id": null,
"home_page": "https://github.com/delarosatrevin/emtable",
"name": "emtable",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "electron-microscopy cryo-em structural-biology image-processing",
"author": "J.M. De la Rosa Trevin, Grigory Sharov",
"author_email": "delarosatrevin@gmail.com, gsharov@mrc-lmb.cam.ac.uk",
"download_url": "https://files.pythonhosted.org/packages/6a/63/b92c5914e9e607758a7e3c475e0203c7340e006e9532464cc24d4205ad7c/emtable-0.0.14.tar.gz",
"platform": null,
"description": "=======\nemtable\n=======\n\nEmtable is a STAR file parser originally developed to simplify and speed up metadata conversion between Scipion and Relion. It is available as a small self-contained Python module (https://pypi.org/project/emtable/) and can be used to manipulate STAR files independently from Scipion.\n\nHow to cite\n-----------\n\nPlease cite the code repository DOI: `10.5281/zenodo.4303966 <https://zenodo.org/record/4303966>`_\n\nAuthors\n-------\n\n * Jose Miguel de la Rosa-Trev\u00edn, Department of Biochemistry and Biophysics, Science for Life Laboratory, Stockholm University, Stockholm, Sweden\n * Grigory Sharov, MRC Laboratory of Molecular Biology, Cambridge Biomedical Campus, England\n\nTesting\n-------\n\n``python3 -m unittest discover emtable/tests``\n\nExamples\n--------\n\nTo start using the package, simply do:\n\n.. code-block:: python\n\n from emtable import Table\n\nEach table in STAR file usually has a *data\\_* prefix. You only need to specify the remaining table name:\n\n``Table(fileName=modelStar, tableName='perframe_bfactors')``\n\nBe aware that from Relion 3.1 particles table name has been changed from \"data_Particles\" to \"data_particles\".\n\nReading\n#######\n\nFor example, we want to read the whole *rlnMovieFrameNumber* column from modelStar file, table *data_perframe_bfactors*.\n\nThe code below will return a list of column values from all rows:\n\n.. code-block:: python\n\n table = Table(fileName=modelStar, tableName='perframe_bfactors')\n frame = table.getColumnValues('rlnMovieFrameNumber')\n\nWe can also iterate over rows from \"data_particles\" Table:\n\n.. code-block:: python\n\n table = Table(fileName=dataStar, tableName='particles')\n for row in table:\n print(row.rlnRandomSubset, row.rlnClassNumber)\n\nAlternatively, you can use **iterRows** method which also supports sorting by a column:\n\n.. code-block:: python\n\n mdIter = Table.iterRows('particles@' + fnStar, key='rlnImageId')\n\nIf for some reason you need to clear all rows and keep just the Table structure, use **clearRows()** method on any table.\n\n\nWriting\n#######\n\nIf we want to create a new table with 3 pre-defined columns, add rows to it and save as a new file:\n\n.. code-block:: python\n\n tableShifts = Table(columns=['rlnCoordinateX',\n 'rlnCoordinateY',\n 'rlnAutopickFigureOfMerit',\n 'rlnClassNumber'])\n tableShifts.addRow(1024.54, 2944.54, 0.234, 3)\n tableShifts.addRow(445.45, 2345.54, 0.266, 3)\n\n tableShifts.write(f, tableName=\"test\", singleRow=False)\n\n*singleRow* is **False** by default. If *singleRow* is **True**, we don't write a *loop_*, just label-value pairs. This is used for \"one-column\" tables, such as below:\n\n\n.. code-block:: bash\n\n data_general\n\n _rlnImageSizeX 3710\n _rlnImageSizeY 3838\n _rlnImageSizeZ 24\n _rlnMicrographMovieName Movies/20170629_00026_frameImage.tiff\n _rlnMicrographGainName Movies/gain.mrc\n _rlnMicrographBinning 1.000000\n _rlnMicrographOriginalPixelSize 0.885000\n _rlnMicrographDoseRate 1.277000\n _rlnMicrographPreExposure 0.000000\n _rlnVoltage 200.000000\n _rlnMicrographStartFrame 1\n _rlnMotionModelVersion 1\n\n\n",
"bugtrack_url": null,
"license": "",
"summary": "Simple module to deal with EM tabular data (aka metadata)",
"version": "0.0.14",
"split_keywords": [
"electron-microscopy",
"cryo-em",
"structural-biology",
"image-processing"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "97b833e80fd0fe89fcac5225a763e512",
"sha256": "7847c7c9454f0e491e36491025cc53302ae9e89cd615f1e4abbebfcbc40a9b43"
},
"downloads": -1,
"filename": "emtable-0.0.14-py3-none-any.whl",
"has_sig": false,
"md5_digest": "97b833e80fd0fe89fcac5225a763e512",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 21663,
"upload_time": "2022-07-25T10:55:08",
"upload_time_iso_8601": "2022-07-25T10:55:08.998285Z",
"url": "https://files.pythonhosted.org/packages/19/ba/e18bc0351a3692339fa335f04cfaf98e738735641bf2191b969557fca1bc/emtable-0.0.14-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "921629141e3dad2b31f46ce69b4d1943",
"sha256": "e531cdfb0fe38c9b81ef2cb71503b69a64309652044538f1f1853b43ed52840f"
},
"downloads": -1,
"filename": "emtable-0.0.14.tar.gz",
"has_sig": false,
"md5_digest": "921629141e3dad2b31f46ce69b4d1943",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 23531,
"upload_time": "2022-07-25T10:55:10",
"upload_time_iso_8601": "2022-07-25T10:55:10.477509Z",
"url": "https://files.pythonhosted.org/packages/6a/63/b92c5914e9e607758a7e3c475e0203c7340e006e9532464cc24d4205ad7c/emtable-0.0.14.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-07-25 10:55:10",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "delarosatrevin",
"github_project": "emtable",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "emtable"
}