Skip to main content

STAR file I/O in Python

Project description

starfile

License PyPI Python Version CI codecov

starfile is a package for reading and writing STAR files in Python.

starfile can be used interactively to inspect/explore files or in scripts and larger software packages to provide basic STAR file I/O functions. Data is exposed as simple python dictionaries or pandas dataframes.

This package was designed principally for compatibility with files generated by RELION.

For more information on working with dataframes, please see the pandas docs.

For starfile specific documentation, see teamtomo.org/starfile


Quickstart

For the following file particles.star with a single data block

data_particles

loop_
_rlnCoordinateX #1
_rlnCoordinateY #2
_rlnCoordinateZ #3
_rlnAngleRot #4
_rlnAngleTilt #5
_rlnAnglePsi #6
_rlnMicrographName #7
91.798700	83.622600	203.341030	-51.740000	173.930000	32.971000	01_10.00Apx.mrc
97.635800	80.437000	203.136160	141.500000	171.760000	-134.680000	01_10.00Apx.mrc
92.415200	88.842700	210.663900	-78.750000	173.930000	87.263200	01_10.00Apx.mrc
94.607830	93.135410	205.425960	-85.215000	167.170000	85.632200	01_10.00Apx.mrc
86.187800	80.125400	204.558750	14.910000	163.260000	-16.030000	01_10.00Apx.mrc
91.824240	76.738300	203.794280	39.740000	168.410000	-57.250000	01_10.00Apx.mrc
98.253300	73.530100	203.856030	73.950000	166.380000	-84.640000	01_10.00Apx.mrc
101.303500	80.290800	194.790400	-178.878000	166.090000	73.181000	01_10.00Apx.mrc

Read the file

import starfile

df = starfile.read('particles.star')

Interact with the data

df['rlnCoordinateX'] += 10
df.head()
   rlnCoordinateX  rlnCoordinateY  rlnCoordinateZ  rlnAngleRot  rlnAngleTilt  rlnAnglePsi rlnMicrographName
0       101.79870        83.62260       203.34103      -51.740        173.93      32.9710   01_10.00Apx.mrc
1       107.63580        80.43700       203.13616      141.500        171.76    -134.6800   01_10.00Apx.mrc
2       102.41520        88.84270       210.66390      -78.750        173.93      87.2632   01_10.00Apx.mrc
3       104.60783        93.13541       205.42596      -85.215        167.17      85.6322   01_10.00Apx.mrc
4        96.18780        80.12540       204.55875       14.910        163.26     -16.0300   01_10.00Apx.mrc

Save the (modified) data to file

starfile.write(df, 'modified_particles.star')

For more advanced usage please check out the examples.


Installation

pip install starfile

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starfile-0.5.10.tar.gz (28.3 kB view details)

Uploaded Source

Built Distribution

starfile-0.5.10-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file starfile-0.5.10.tar.gz.

File metadata

  • Download URL: starfile-0.5.10.tar.gz
  • Upload date:
  • Size: 28.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for starfile-0.5.10.tar.gz
Algorithm Hash digest
SHA256 b9065776ffe088f0d4c11d7edeaa2bf0388253f9c20e47efcad30457cf6924f0
MD5 85e83a5f14d6ebb07e002efd00e9c513
BLAKE2b-256 495a5e9f714259702a0995043acc2557e4932cf7f79dc1e761f9921e999e743c

See more details on using hashes here.

Provenance

The following attestation bundles were made for starfile-0.5.10.tar.gz:

Publisher: ci.yml on teamtomo/starfile

Attestations:

File details

Details for the file starfile-0.5.10-py3-none-any.whl.

File metadata

  • Download URL: starfile-0.5.10-py3-none-any.whl
  • Upload date:
  • Size: 10.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for starfile-0.5.10-py3-none-any.whl
Algorithm Hash digest
SHA256 79f229568b2fbac677224af88872f0e284e3a091ef138c445480bf4348e209ee
MD5 5953873690b498fc611173b3ffd920c3
BLAKE2b-256 2d80d9bc5d4af14fa80251992a2d2ee80be45b660b1962c7ecff6e3fda043e05

See more details on using hashes here.

Provenance

The following attestation bundles were made for starfile-0.5.10-py3-none-any.whl:

Publisher: ci.yml on teamtomo/starfile

Attestations:

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page