Skip to content
This repository has been archived by the owner on Feb 9, 2024. It is now read-only.

General File Conversion

gijsschot edited this page Nov 8, 2021 · 2 revisions

Basic examples of file conversion

In order to convert data between the plethora of data formats available in the Tomography community PyTom developed a general conversion script. A basic example of a conversion between a single file in the .em format to the file in mrc format can be found below.

convert.py -f TiltImage.em -t ./ -o mrc

The following parameters were use in this conversion:

  • -f, --file Filename will convert this single file to the target format.
  • -t, --targetPath Path to new file, as a relative or absolute path to a directory, the filename will be the same as the original file. Default current directory.
  • -o, --outputFormat The format of the output file. Examples: em, mrc, xml, star, rec, st

It would also be possible that one would have a folder with several files that would need to be converted. In this case the -d flag could be used. For example:

convert.py -d /home/user/folder_with_tilt_series_in_em_format -t ./ -o mrc
  • -d, --directory A directory of files, will convert all possible files to the outputFormat specified, not te be used in combination with --file

The script will search for all files in that directory that can be converted to mrc. If you would only want to convert a subset, please fill out the prefixQuery and suffixQuery.

convert.py -d /home/user/folder_with_tilt_series_in_em_format -t ./ -o mrc --prefixQuery sorted --suffixQuery .em
  • --prefixQuery Only files that match the prefix will be converted.
  • --suffixQuery Only files that end with suffix will be converted.

Here all files in folder d that start with sorted and end with .em will be converted to mrc. If one would for instance have a .st file this file will not be converted.

A comprehensive list of all convert.py input paramaters / flags.

General flags:

  • -f, --file Filename will convert this single file to the target format. Not to be used in combination with --directory
  • -d, --directory A directory of files, will convert all possible files to the outputFormat specified, not te be used in combination with --file
  • -t, --targetPath Path to new file, as a relative or absolute path to a directory, the filename will be the same as the original file.
  • -o, --outputFormat The format of the output file, will keep the same name but only change the extension.
  • --prefixQuery Only files that match the prefix will be converted.
  • --suffixQuery Only files that end with suffix will be converted.
  • --outname Filename output file. This name with replace the default filename.

Specific flags for providing supporting data to respective conversions.

  • -c, --chainData Data needed for conversion from the special formats (pdb and mmCIF), in the format pixelsSize,cubeSize,invertDensity,chain (invertDensity is 1 or 0)
  • -s, --prefix Data needed for the conversion from coordinates to a particlelist. Path and filename for subtomogram files (e.g., MyPath/particle_)
  • -w, --wedgeAngles Data needed for the conversion from coordinates to a particlelist. Missing wedge angle(s) [counter-clock, clock] or single angle
  • --pixelSize Pixelsize in angstrom of the original nanographs.
  • --binPyTom (Linear) Binning factor of the pytom tomogram.
  • --binWarpM (Linear) Binning factor of the warp/m volumes.
  • --alignxf Final shift file from IMOD
  • --sortedFolder Sorted Images are located in this folder.
Clone this wiki locally