SkillAgentSearch skills...

Tomostarpy

Python scripts to manipulate Relion tomo STAR files and much more...

Install / Use

/learn @fuzikt/Tomostarpy
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

TomoStarPy

Some useful Python scripts to manipulate Relion tomo STAR files and much more.....

Table of Contents

Installation

git clone https://github.com/fuzikt/tomostarpy.git
cd tomostarpy
./INSTALL.sh

Usage

Before usage don't forget to source the venv environment if it is not yet activated:

source <path_to_tomostarpy>/venv/bin/activate

convmap_mod_get_particles.py

Get particle parameters (cc, coordinates, Euler angles) from a convmap file at positions defined by a mod file. Output is written in emClarity csv format.

--convmap    Input _convmap.mrc file.
--mod        Input mod file (Default: empty).
--o          Output emClarity csv file (Default: empty).

create_order_list.py

Generates order_list.csv for RELION from *.tlt file according to dose-symmetric tilting scheme. (Default 2 pos, 2 neg generates: 0,1,-1,-2,2,3,-3,4...).

--i           Input *.tlt file.
--o           Output csv file.
--nr_pos      Number of consecutive positive tilts in output (Default: 2).
--nr_neg      Number of consecutive negative tilts in output (Default: 2).
--pacetomo    Pace-tomo style dose symmetric (0, ++, --, ++, --.....) (Default: False).

ctffind_tilts.py

Performs constrained CTF fit on separate tilts using Ctffind4 or Gctf. First, the middle tilt ctf is estimated then the following tilts in each direction are constrained by the --defocus_window of the previous tilt. The max resolution of the fitting is limited by 1/cos(tilt_angle) to avoid overfitting.

--i                 Input tilt-series MRC file.
--o                 Output directory of results.
--tlt               *.tlt or *.rawtlt file of the tilt series.
--defocus_window    Defocus window in Angstroms used for the restrained ctf search of the subsequent tilts (Default: 10000).
--apix              Pixel-size in Angstroms (Default: 1.0).
--voltage           Acceleration voltage of the microscope in kV (Default: 300.0).
--cs_val            Cs value of the microscope (Default: 2.7).
--amp_cont          Amplitude contrast used for CTF fitting (Default: 0.07).
--spectr_size       Size of the Fourier spectrum used for CTF fitting (Default: 512).
--min_res           Minimum resolution in Angstroms used for zero-tilt CTF fitting (Default: 30.0).
--max_res           Maximum resolution in Angstroms used for zero-tilt CTF fitting (Default: 8.0).
--min_defoc         Minimum defocus in Angstroms used for zero-tilt CTF fitting (Default: 5000.0).
--max_defoc         Maximum defocus in Angstroms used for zero-tilt CTF fitting (Default: 75000.0).
--step_defoc        Defocus step in Angstroms used for CTF fitting (Default: 100.0).
--threads           Number of parallel threads used for calculation by Ctffind4 (Default: 10).
--gctf              Use gCTF instead of CtfFind4 (Default: False).
--gpu               GPU card ID to be used by gCTF (Default: 0).
--tmpDir            Temp directory for storage of the intermediate files (Default: ctffind_tmp).
--ctffind_cmd       Name of the Ctffind4 command (Default: ctffind).
--gctf_cmd          Name of the gCTF command (Default: gctf).
--path              Path to be included in env PATH for Ctffind4 or Gctf (Default: empty).
--verb              Verbosity level (0,1) (Default: 0).

dose_correct_tomostar.py

Replace dose in warp .tomostar by value from .tltdose file.

--i        Input tomostar file.
--itlt     Input dosetlt file.
--o        Output tomostar file.

emc_csv_to_star.py

Performs conversion from emClarity template matching csv file to Relion star file. It also recalculates the particle coordinates from emClarity partial tomogram to full tomogram.

--i        Input emClarity csv file.
--o        Output prefix. Prefix of the files generated by the script.
--reconsh  emClarity *_recon.sh file of the input csv file. (located in emc_project/recon/)
--tiltcom  tilt.com file (generated by IMOD) of the original non-splitted tomogram used by Relion
--mod      Modfile used for filtering particles from the input csv. Note: Set the "--modbin" binning factor used for template matching.
--modbin   Binning factor used for template matching. Needed only if modfile filtering is enabled. (Default 1)
--outbin   Binning factor used for output coordinates and mod files. NOT used for star file (always unbinned)! (Default 1)
--cs       Cs value of the microscope. Used in opticsgroup in the output star file. (Default 2.7)
--kv       Acceleration voltage of the microscope. Used in opticsgroup in the output star file. (Default 300.0)
--apix     Apix of the unbinned tomogram. Used in opticsgroup in the output star file.
--xtilt    Tomo X axis tilt in degrees. (Default: 0)
--ytilt    Tomo Y axis tilt in degrees. (Default: 0)

emc_ctf_tlt_to_xf.py

Converts emClarity *_aliX_ctf.tlt from tomoCPR to IMOD format *.xf + *.tlt file and Ctffind4 format diag. output *.txt file.

--i        Input emClarity *_aliX_ctf.tlt file.
--o        Output prefix for IMOD style xf/tlt file and Ctffind4 style diag. output file.

eulers_zyz_from_matrix.py

Calculates ZYZ convention Euler angles from a 3x3 rotation matrix.

--i        Rotation matrix members in format: m[1,1],m[1,2],m[1,3],m[2,1],m[2,2]

exclude_lines_by_range_file.py

Removes lines defined in --exclude_file from input text file.

--i             Input file to exclude lines from.
--o             Output file.
--exclude_file  Textfile with comma separated list of excluded views (or range of views as in newstack).

exclude_tilts.py

Removes tilts defined in --exclude_file from tilt series mrc-stack and corresponding *.rawtlt, *.mdoc.

--i             Input prefix mrc-stack.
--o             Output prefix.
--exclude_file  Textfile with comma separated list of excluded views (or range of views as in newstack).

exclude_tilts_from_warp2_ts_xml.py

Removes tilts defined in --exclude_file from Warp2 tilt-series XML file and tomostar file.

    --i_xml         Input Warp2 tilt-series XML file.
    --i_tomostar    Input tomostar file.
    --o             Output prefix for XML and tomostar file.
    --exclude_file  Textfile with comma separated list of excluded views (or range of views as used in imod newstack).

Example 1: Exclude tilts from tomo1.xml and tomo1.tomostar files, the tilts to be excluded are defined in tomo1_excluded.txt.

mkdir excluded_tilts

exclude_tilts_from_warp2_ts_xml.py --i_xml warp_tiltseries/tomo1.xml --i_tomostar tomostar/tomo1.tomostar --o excluded_tilts/tomo1 --exclude_file tomo1_excluded.txt

# This will create excluded_tilts/tomo1.xml and excluded_tilts/tomo1.tomostar with the tilts defined in tomo1_excluded.txt removed.

Example of the content of tomo1_excluded.txt:
1,2,12-16,20,22-24

Example 2: A simple bash loop to exclude tilts from multiple tomograms (can be written as a script or "one-liner" in the terminal):

for i in `seq 1 10`; do
    exclude_tilts_from_warp2_ts_xml.py --i_xml warp_tiltseries/tomo${i}.xml --i_tomostar tomostar/tomo${i}.tomostar --o excluded_tilts/tomo${i} --exclude_file tomo${i}_excluded.txt
done

filter_neighbors_only.py

Select only particles that have a certain amount of neighbors in a particular distance. Useful for filtering out template matched particles.

--i               Input STAR file name with particles.
--o               Output STAR file name.
--dist            Distance in Angstroms that consider particles as neighbors. (Default 1.0)
--min_neigh       Minimum number of neighbors at --dist particle has to be kept in selection! (Default 1)
--min_corr        Minimum cross-correlation value of the neighbour to be considered as a true neighbour! (Default 0)
--lb_corr'        Label of the cross-correlation value in the star file! (Default rlnLCCmax)
--max_ang_dist    Maximum angular distance in degrees between neighbors to be considered as a true neighbour! (Default 360)

find_bad_ctf_fit_tilts.py

Analyze the Ctffind4 output txt file and write out text file with tilt-numbers that have CTF rings fitted over the threshold. Tilts are numbered from 1.

--i           Input Ctffind4 diagnostic txt file.
--o           Output text file with tilt numbers under the threshold.
--threshold   Threshold (in Angstroms) value for the resolution up to which CTF rings were fit successfully. (Default: 100)

find_dark

View on GitHub
GitHub Stars14
CategoryDevelopment
Updated12d ago
Forks3

Languages

Python

Security Score

90/100

Audited on Mar 23, 2026

No findings