#author("2024-03-06T10:14:34+00:00","default:sysosa","sysosa") #author("2024-03-06T14:07:18+00:00","default:sysosa","sysosa") 本家様 [[https://grigoriefflab.umassmed.edu/ctf_estimation_ctffind_ctftilt>+https://grigoriefflab.umassmed.edu/ctf_estimation_ctffind_ctftilt]] ***ctffind5 [#cca99470] 記事 [[https://www.biorxiv.org/content/10.1101/2024.02.26.582023v1>+https://www.biorxiv.org/content/10.1101/2024.02.26.582023v1]] この記事の中でコンパイルされたバージョンが[[https://cistem.org/development>+https://cistem.org/development]]に用意されているみたい. さっそくCTFFIND5が入っているcisTEMを取得してみた. cisTEM-ctffind5-151-d42312b.tar.gz(1.6GB) #code(nonumber){{ [root@rockylinux ~]# cat /etc/redhat-release Rocky Linux release 8.9 (Green Obsidian) [root@rockylinux ~]# cd /apps/ [root@rockylinux apps]# tar xf /Public/em/cisTEM-ctffind5-151-d42312b.tar.gz [root@rockylinux apps]# ls -l cisTEM/bin/ : -rwxr-xr-x. 1 saber saber 40459144 Feb 27 00:54 create_mask -rwxr-xr-x. 1 saber saber 40907928 Feb 27 00:54 ctffind -rwxr-xr-x. 1 saber saber 40459240 Feb 27 00:54 divide_two_stacks : [root@rockylinux apps]# [root@rockylinux apps]# /apps/cisTEM/bin/ctffind ** Welcome to Ctffind ** Version : 5.0.0 Compiled : Feb 26 2024 Library Version : 2.0.0-alpha-151-d42312b-dirty From Branch : ctffind5 Mode : Interactive Input image file name [input.mrc] : ^C [root@rockylinux apps]# [root@rockylinux apps]# ldd /apps/cisTEM/bin/ctffind linux-vdso.so.1 (0x00007ffc3b5f6000) libm.so.6 => /lib64/libm.so.6 (0x00007fedce9a2000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fedce782000) libc.so.6 => /lib64/libc.so.6 (0x00007fedce3bd000) /lib64/ld-linux-x86-64.so.2 (0x00007fedced24000) libdl.so.2 => /lib64/libdl.so.2 (0x00007fedce1b9000) [root@rockylinux apps]# }} 一応、「/apps/cisTEM/bin/ctffind」のみを持ち出せれるみたい 次にソースから作ってみる #code(nonumber){{ [root@rockylinux ~]# cd /apps/src/ [root@rockylinux src]# git clone https://github.com/GrigorieffLab/cisTEM [root@rockylinux src]# cd cisTEM/ [root@rockylinux cisTEM]# git branch --all * main : remotes/origin/ctffind5 : [root@rockylinux cisTEM]# git checkout remotes/origin/ctffind5 [root@rockylinux cisTEM]# ./regenerate_project.b [root@rockylinux cisTEM]# mkdir build && cd build [root@rockylinux build]# ../configure --prefix=/apps/cisTEM [root@rockylinux build]# make -j 20 }} コンパイルが終われば build/src にバイナリーが用意される. make installで「--prefix」にコピーされる. 確認したらこんな感じ. #code(nonumber){{ [root@rockylinux build]# ./src/ctffind ** Welcome to Ctffind ** Version : 5.0.0 Compiled : Mar 6 2024 Library Version : 2.0.0-alpha-153-2d3c4ad-dirty From Branch : (HEAD Mode : Interactive Input image file name [input.mrc] : ^C [root@rockylinux build]# }} ***ctffind4.1.14 [#l344dced] &color(lightseagreen){''RockyLinux8''};で使ってみる 提供されているバイナリーバージョンの「ctffind-4.1.14-linux64.tar.gz」はREL7系(CentOS7)ではうまく動く. しかしRHEL8系のRockyLinux8では実行すると下記のようにcore dumpして終わる. #code(nonumber){{ Segmentation fault (core dumped) }} 動かいないみたい。 っで、ソースコードを入手して、コンパイルしてみる。 ***ソース展開、コンパイル [#ma15efed] コンパイルに必要なライブラリをインストールします。 #code(nonumber){{ [root@c ~]# dnf --enablerepo=epel install wxBase3-devel wxGTK3-devel fftw-devel libtiff-devel libjpeg-turbo-devel }} 本家様からソースコードをダウンロードして展開します #code(nonumber){{ [root@c ~]# cd /apps/src [root@c src]# gzip -cd ctffind-4.1.14.tar.gz | tar xf - [root@c src]# cd ctffind-4.1.14 }} ここで [[https://grigoriefflab.umassmed.edu/comment/1696#comment-1696>+https://grigoriefflab.umassmed.edu/comment/1696#comment-1696]]にある調整を加えます 具体的には下記のようにプログラムコードを修正します #code(diff,nonumber){{ --- ctffind-4.1.14/src/programs/ctffind/ctffind.cpp.orig 2020-05-09 02:28:31.000000000 +0900 +++ ctffind-4.1.14/src/programs/ctffind/ctffind.cpp 2021-11-09 13:08:47.351398779 +0900 @@ -267,11 +267,11 @@ float FindRotationalAlignmentBetweenTwoStacksOfImages(Image *self, Image *other_image, int number_of_images, float search_half_range, float search_step_size, float minimum_radius, float maximum_radius); void ComputeImagesWithNumberOfExtremaAndCTFValues(CTF *ctf, Image *number_of_extrema, Image *ctf_values); int ReturnSpectrumBinNumber(int number_of_bins, float number_of_extrema_profile[], Image *number_of_extrema, long address, Image *ctf_values, float ctf_values_profile[]); -bool ComputeRotationalAverageOfPowerSpectrum( Image *spectrum, CTF *ctf, Image *number_of_extrema, Image *ctf_values, int number_of_bins, double spatial_frequency[], double average[], double average_fit[], double average_renormalized[], float number_of_extrema_profile[], float ctf_values_profile[]); +void ComputeRotationalAverageOfPowerSpectrum( Image *spectrum, CTF *ctf, Image *number_of_extrema, Image *ctf_values, int number_of_bins, double spatial_frequency[], double average[], double average_fit[], double average_renormalized[], float number_of_extrema_profile[], float ctf_values_profile[]); void ComputeEquiPhaseAverageOfPowerSpectrum( Image *spectrum, CTF *ctf, Curve *epa_pre_max, Curve *epa_post_max); void OverlayCTF( Image *spectrum, CTF *ctf, Image *number_of_extrema, Image *ctf_values, int number_of_bins_in_1d_spectra, double spatial_frequency[], double rotational_average_astig[], float number_of_extrema_profile[], float ctf_values_profile[], Curve *equiphase_average_pre_max, Curve *equiphase_average_post_max); void ComputeFRCBetween1DSpectrumAndFit( int number_of_bins, double average[], double fit[], float number_of_extrema_profile[], double frc[], double frc_sigma[], int first_fit_bin); -bool RescaleSpectrumAndRotationalAverage( Image *spectrum, Image *number_of_extrema, Image *ctf_values, int number_of_bins, double spatial_frequency[], double average[], double average_fit[], float number_of_extrema_profile[], float ctf_values_profile[], int last_bin_without_aliasing, int last_bin_with_good_fit ); +void RescaleSpectrumAndRotationalAverage( Image *spectrum, Image *number_of_extrema, Image *ctf_values, int number_of_bins, double spatial_frequency[], double average[], double average_fit[], float number_of_extrema_profile[], float ctf_values_profile[], int last_bin_without_aliasing, int last_bin_with_good_fit ); void Renormalize1DSpectrumForFRC( int number_of_bins, double average[], double fit[], float number_of_extrema_profile[]); float ReturnAzimuthToUseFor1DPlots(CTF *ctf); @@ -2419,7 +2419,7 @@ // Rescale the spectrum and its 1D rotational avereage so that the peaks and troughs are at 0.0 and 1.0. The location of peaks and troughs are worked out // by parsing the suppilied 1D average_fit array -bool RescaleSpectrumAndRotationalAverage( Image *spectrum, Image *number_of_extrema, Image *ctf_values, int number_of_bins, double spatial_frequency[], double average[], double average_fit[], float number_of_extrema_profile[], float ctf_values_profile[], int last_bin_without_aliasing, int last_bin_with_good_fit ) +void RescaleSpectrumAndRotationalAverage( Image *spectrum, Image *number_of_extrema, Image *ctf_values, int number_of_bins, double spatial_frequency[], double average[], double average_fit[], float number_of_extrema_profile[], float ctf_values_profile[], int last_bin_without_aliasing, int last_bin_with_good_fit ) { MyDebugAssertTrue(spectrum->is_in_memory, "Spectrum memory not allocated"); MyDebugAssertTrue(number_of_bins > 1,"Bad number of bins: %i\n",number_of_bins); @@ -2762,7 +2762,7 @@ } // -bool ComputeRotationalAverageOfPowerSpectrum( Image *spectrum, CTF *ctf, Image *number_of_extrema, Image *ctf_values, int number_of_bins, double spatial_frequency[], double average[], double average_fit[], double average_rank[], float number_of_extrema_profile[], float ctf_values_profile[]) +void ComputeRotationalAverageOfPowerSpectrum( Image *spectrum, CTF *ctf, Image *number_of_extrema, Image *ctf_values, int number_of_bins, double spatial_frequency[], double average[], double average_fit[], double average_rank[], float number_of_extrema_profile[], float ctf_values_profile[]) { MyDebugAssertTrue(spectrum->is_in_memory, "Spectrum memory not allocated"); MyDebugAssertTrue(number_of_extrema->is_in_memory,"Number of extrema image not allocated"); }} そうして #code(nonumber){{ [root@c ctffind-4.1.14]# ./configure --prefix=/apps/ctffind-4.1.14 [root@c ctffind-4.1.14]# make; make install }} ***使う [#iab7e9fe] 大抵は relion からコールされて使うのが常なのであんまりそのままでは使わない。 けど、こんな感じでインターラクティヴに使うものです。 (ヒアドキュメントみたいな実行方法もあるけど) #code(nonumber){{ [root@c ~]# /apps/ctffind-4.1.14/bin/ctffind ** Welcome to Ctffind ** Version : 4.1.14 Compiled : Nov 9 2021 Mode : Interactive Input image file name [input.mrc] : }} ***コンパイルしたアプリを使うなら [#b3b3ce89] コンパイル済みのアプリを他のpcに運んで使う際、下記が必要みたい #code(nonumber){{ wxBase3 }} が必要 ***m1 macOSでctffind [#h8af7d91] 作ってみた まず [[Apple/command#s51b110d]] のように Homebrew をインストールします その後に #code(nonumber){{ [supervisor@mini-m1 ~]$ brew install fftw [supervisor@mini-m1 ~]$ brew install wxWidgets }} と fftw と wxWidgets をインストールします. っでctffindのソースを展開して #code(nonumber){{ [supervisor@mini-m1 ~]$ cd src [supervisor@mini-m1 ~/src]$ tar xf ctffind-4.1.14.tar.gz [supervisor@mini-m1 ~/src]$ cd ctffind-4.1.14 [supervisor@mini-m1 ~/src/ctffind-4.1.14]$ }} ここでソースコードの一部を修正します。上記のvoid修正を施した後に追加で下記のように「src/core/matrix.cpp」を修正します #code(diff,nonumber){{ --- src/core/matrix.cpp.orig 2022-09-28 01:19:32.000000000 +0900 +++ src/core/matrix.cpp 2022-09-28 01:27:54.000000000 +0900 @@ -4,7 +4,11 @@ // think i got it from a book i had about game programming in c.. it's probably slower than what the compiler would do these days. #define AL_PI 3.14159265358979323846 -#define _AL_SINCOS(x, s, c) __asm__ ("fsincos" : "=t" (c), "=u" (s) : "0" (x)) +#if defined(__i386__) || defined(__x86_64__) +#define _AL_SINCOS(x, s, c) __asm__ ("fsincos" : "=t" (c), "=u" (s) : "0" (x)) +#else +#define _AL_SINCOS(x, s, c) s = sinf(x); c = cosf(x); +#endif #define FLOATSINCOS(x, s, c) _AL_SINCOS((x) * AL_PI / 128.0, s ,c) #define MAKE_ROTATION_f(x, y, z) \ }} その上で #code(nonumber){{ [supervisor@mini-m1 ~/src/ctffind-4.1.14]$ ./configure --with-fftw-dir=/opt/homebrew [supervisor@mini-m1 ~/src/ctffind-4.1.14]$ make }} これで ctffind が作れます #code(nonumber){{ [supervisor@mini-m1 ~/src/ctffind-4.1.14]$ ./ctffind ** Welcome to Ctffind ** Version : 4.1.14 Compiled : Sep 28 2022 Mode : Interactive Input image file name [input.mrc] : ^C [supervisor@mini-m1 ~/src/ctffind-4.1.14]$ }} な感じです