本家様 https://github.com/asarnow/pyem

pyemのwiki https://github.com/asarnow/pyem/wiki

「A collection of Python modules and command-line utilities for electron microscopy of biological samples.」とある。
deepL先生訳
「生物試料の電子顕微鏡観察用のPythonモジュールとコマンドラインユーティリティのコレクション」

pyenv/anaconda

crYOLOと同じように pyenv を敷いて anaconda か miniforge でconda環境を用意してます
*既に crYOLO とかで構築済みなら不要。その環境を使い回します

git clone https://github.com/yyuu/pyenv.git /apps/pyenv
export PYENV_ROOT=/apps/pyenv
export PATH=$PYENV_ROOT/bin:$PATH
pyenv install --list    <-- 最新版らを確認
 
pyenv install anaconda3-2024.06-1
(あるいは pyenv install miniforge3-23.11.0-0 )

サイトでは miniforge を進めてます. まぁmambaが使えますからね.

その後にconda環境を作れるようにするために

source /apps/pyenv/versions/anaconda3-2024.06-1/etc/profile.d/conda.sh
 
(あるいは source /apps/pyenv/versions/miniforge3-23.11.0-0/etc/profile.d/conda.sh

とします

PyEM 向けの仮想実行環境を作って、PyEMをインストールします

PyEMの仮想環境名ですが単純に「PyEM」としてます. まぁ、pyemでも構いませんl

[root@rockylinux ~]# conda create -n PyEM python=3.9 -c conda-forge -y
 
[root@rockylinux ~]# conda activate PyEM
 
(PyEM) [root@rockylinux ~]# conda install numba numpy scipy matplotlib seaborn pandas pathos pyfftw healpy natsort starfile ipython -c conda-forge -y
(PyEM) [root@rockylinux ~]# cd /apps
 
(PyEM) [root@rockylinux apps]# git clone https://github.com/asarnow/pyem.git
(PyEM) [root@rockylinux apps]# cd pyem/
 
(PyEM) [root@rockylinux pyem]# which pip
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/pip
 
(PyEM) [root@rockylinux pyem]# pip install --no-dependencies -e .
 
(PyEM) [root@rockylinux pyem]# pip install cs2star   (ついでです)

一応確認 ついでに cs2star も入れてます. 参照https://pypi.org/project/cs2star/

(PyEM) [root@rockylinux ~]# ls /apps/pyem/pyem/cli/
angdist.py      ctf2star.py     __init__.py  mcstar.py    projection_subtraction.py  reconstruct.py  star2bild.py     subset.py
cfsc.py         disparticle.py  map.py       par2star.py  project.py                 sort.py         star.py          varmap.py
csparc2star.py  emcalc.py       mask.py      pose.py      recenter.py                stack.py        subparticles.py
 
(PyEM) [root@rockylinux ~]# 
(PyEM) [root@rockylinux ~]# ls /apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/*.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/cfsc.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/csparc2star.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/ctf2star.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/disparticle.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/emcalc.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/map.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/mask.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/mcstar.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/par2star.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/projection_subtraction.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/project.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/stack.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/star2bild.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/star.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/subparticles.py
/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/varmap.py
(PyEM) [root@rockylinux ~]#

「/apps/pyem/pyem/cli」にあって、「/apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM/bin/*.py」にないものとかある( angdist.py, recenter.py, reconstruct.py, sort.py, subset.py )

なので、EnvironmentModulesは下記のようにします

EnvironmentModules

「/apps/modulefiles/PyEM」

#%Module1.0
set PyEM /apps/pyem/
set root /apps/pyenv/versions/anaconda3-2024.06-1/envs/PyEM
prepend-path PATH $root/bin:$PyEM/pyem/cli

実行するには

みんな大好き csparc2star.py のヘルプを出してみた.

[saber@rockylinux ~]$ module use /apps/modulefiles/
[saber@rockylinux ~]$ module load PyEM
 
[saber@rockylinux ~]$ csparc2star.py -h
usage: csparc2star.py [-h] [--movies] [--boxsize BOXSIZE] [--class CLS] [--minphic MINPHIC] [--stack-path STACK_PATH]
                      [--micrograph-path MICROGRAPH_PATH] [--copy-micrograph-coordinates COPY_MICROGRAPH_COORDINATES] [--swapxy] [--noswapxy]
                      [--invertx] [--inverty] [--flipy] [--cached] [--transform TRANSFORM] [--relion2] [--strip-uid [STRIP_UID]] [--10k]
                      [--loglevel LOGLEVEL]
                      [input ...] output
 
positional arguments:
  input                 Cryosparc metadata .csv (v0.6.5) or .cs (v2+) files
  output                Output .star file
 
optional arguments:
  -h, --help            show this help message and exit
  --movies              Write per-movie star files into output directory
  --boxsize BOXSIZE     Cryosparc refinement box size (if different from particles)
  --class CLS           Keep this class in output, may be passed multiple times
  --minphic MINPHIC     Minimum posterior probability for class assignment
  --stack-path STACK_PATH
                        Path to single particle stack
  --micrograph-path MICROGRAPH_PATH
                        Replacement path for micrographs or movies
  --copy-micrograph-coordinates COPY_MICROGRAPH_COORDINATES
                        Source for micrograph paths and particle coordinates (file or quoted glob)
  --swapxy              Swap X and Y axes when converting particle coordinates from normalized to absolute
  --noswapxy            Do not swap X and Y axes when converting particle coordinates
  --invertx             Invert particle coordinate X axis
  --inverty             Invert particle coordinate Y axis
  --flipy               Invert refined particle Y shifts
  --cached              Keep paths from the Cryosparc 2+ cache when merging coordinates
  --transform TRANSFORM
                        Apply rotation matrix or 3x4 rotation plus translation matrix to particles (Numpy format)
  --relion2, -r2        Relion 2 compatible outputs
  --strip-uid [STRIP_UID]
                        Strip all leading UIDs from file names
  --10k                 Only read first 10,000 particles for rapid testing.
  --loglevel LOGLEVEL, -l LOGLEVEL
                        Logging level and debug output
[saber@rockylinux ~]$
 
[saber@rockylinux ~]$
[saber@rockylinux ~]$ cs2star -h
Usage: cs2star [OPTIONS] JOB_DIR [DEST_DIR]
 
  Copy and convert a cryosparc dir into a relion-ready dir.
 
  \b Parameters ========== JOB_DIR:     a cryosparc job containing particles
  files. DEST_DIR:     the destination directory. [default: '.']
 
  WARNING! This script will use --swapxy by default. This is because *usually*
  this is the convention change between cryosparc and relion. However, your
  mileage may vary, so you are encouraged to check you data after conversion.
 
  Note that if -p/-m are not passed, those columns are not usable (due to the
  mrc extension and broken path).
 
Options:
  -f, --overwrite             overwrite the existing destination directory if
                              present.Passed once, overwrite star file only.
                              Twice, also files/symlinks  [default: 0]
  -d, --dry-run               do not perform the command, simply check inputs
                              and show what will be done.
  -c, --copy / -s, --symlink  copy the images or symlink to them  [default: s]
  -m, --micrographs           copy/link the full micrographs
  -p, --patches               copy/link the particle patches, if available
  --sets TEXT                 only use these sets (only used if job is
                              Particle Sets Tool). Comma-separated list.
  --classes TEXT              only use particles from these classes. Comma-
                              separated list.
  --swapxy / --no-swapxy      swap x and y axes  [default: swapxy]
  --inverty / --no-inverty    invert y axis  [default: no-inverty]
  --invertx / --no-invertx    invert x axis  [default: no-invertx]
  --version                   Show the version and exit.
  -h, --help                  Show this message and exit.
[saber@rockylinux ~]$

とかで



ただ、、

recenter.py

「recenter.py」スクリプトを実行すると

[saber@rockylinux ~]$ recenter.py
Traceback (most recent call last):
  File "/apps/pyem//pyem/cli/recenter.py", line 24, in <module>
    from star import parse_star, write_star
ImportError: cannot import name 'parse_star' from 'star' (/apps/pyem/pyem/cli/star.py)
 
[saber@rockylinux ~]$

と言われる.

強引な方法だけどこのPyEM仮想実行環境に eman-dev をcondaで入れてしまう

[root@rockylinux ~]# source /apps/pyenv/versions/anaconda3-2024.06-1/etc/profile.d/conda.sh
[root@rockylinux ~]# conda activate PyEM
 
(PyEM) [root@rockylinux ~]# conda install eman-dev -c cryoem -c conda-forge

そのうえで、ちょっと「recenter.py」を弄る

--- /apps/pyem/pyem/cli/recenter.py.orig        2024-07-07 01:41:51.218929388 +0900
+++ /apps/pyem/pyem/cli/recenter.py     2024-07-07 02:13:10.286641708 +0900
@@ -21,7 +21,7 @@
 import logging
 import sys
 import numpy as np
-from star import parse_star, write_star
+from pyem.star import parse_star, write_star
 from EMAN2 import EMData, Vec3f, Transform

そうすると、

[saber@rockylinux ~]$ module use /apps/modulefiles/
[saber@rockylinux ~]$ module load PyEM
[saber@rockylinux ~]$
[saber@rockylinux ~]$
[saber@rockylinux ~]$ recenter.py -h
usage: recenter.py [-h] [--class-2d CLASS_2D] [--class-3d CLASS_3D] [--zero-origin ZERO_ORIGIN] input output
 
positional arguments:
  input                 Input .star file
  output                Output .star file
 
optional arguments:
  -h, --help            show this help message and exit
  --class-2d CLASS_2D   2D class images for recentering (pass glob in quotes for multiple files)
  --class-3d CLASS_3D   3D class images for recentering (pass glob in quotes for multiple files)
  --zero-origin ZERO_ORIGIN
                        Subtract particle origin from particle coordinates in output
[saber@rockylinux ~]$

と動くようになる

めも

eman-dev を入れてしまうので、eman2 向けとしてアプリを用意して、その中にPyEMを入れたほうがいいのかも.

最新の60件
2024-07-25 2024-07-24 2024-07-16 2024-07-15 2024-07-12 2024-07-07
  • PyEM
2024-06-29 2024-06-22 2024-06-21 2024-06-17 2024-06-14 2024-06-11 2024-06-10 2024-06-08 2024-06-07 2024-06-02 2024-06-01 2024-05-30 2024-05-16 2024-04-26 2024-04-15 2024-04-11 2024-04-06 2024-04-05 2024-03-30 2024-03-29 2024-03-19 2024-03-15 2024-03-06 2024-03-05 2024-03-03 2024-02-23 2024-02-22 2024-02-21 2024-02-20 2024-02-19 2024-02-18 2024-02-13 2024-02-12 2024-02-09 2024-02-04 2024-02-03

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2024-07-07 (日) 02:27:38