Commit 7e5ac2fb authored by Luka Stanisic's avatar Luka Stanisic

rel2: improving tutorial

parent 1295c197
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
##### Micrograph Parameters #######
NUMBER_PIXELS 224
PIXEL_SIZE 1.32
##### Quaterion grid points: #######
USE_QUATERNIONS
##### Constrast transfer integration: #######
CTF_B_ENV 2.0 300. 4
CTF_DEFOCUS 0.5 4.5 8
CTF_AMPLITUDE 0.01 0.601 5
SIGMA_PRIOR_B_CTF 50.
SIGMA_PRIOR_DEFOCUS 0.4
PRIOR_DEFOCUS_CENTER 2.8
##### Center displacement: #######
DISPLACE_CENTER 40 1
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
### run in /bin/bash
#$ -S /bin/bash
#$ -cwd
#$ -N bioem-test-array
#$ -l h_rt=00:30:00
### Allocating nodes with 2 GPUs each, on "phys" cluster
#$ -pe impi_hydra 24
#$ -P gpu
#$ -l use_gpus=1
#$ -l type_gpus=gtx1080
### Allocation job-array for 20 jobs
#$ -t 1-20
set -e
# Local ID of the job
x=$SGE_TASK_ID
SGE_TASK_COUNT=$((($SGE_TASK_LAST - $SGE_TASK_FIRST + 1) / $SGE_TASK_STEPSIZE))
# Loading necessary libraries
module purge
module load intel impi cuda python33/python/3.3 python33/scipy/2015.10
# Variables
#TMPDIR="/tmp/"
M=M2
MODEL=MODEL_2
GRID=smallGrid_125
PYTHON=python3.3
INPUTPROB=Output_${MODEL}
ORIENTATIONS=${TMPDIR}/Quaternion_List_${M}_P${x}
TMP1=${TMPDIR}/base${x}
TMP2=${TMPDIR}/ll${x}
OUTPUTPROB=${TMPDIR}/Output_${MODEL}_P${x}
FINALOUTTMP=Output_Tmp
FINALOUTPROB=Output_${MODEL}_Round2
##########################################################
##########################################################
##########################################################
# Creating list of quaternions
grep Maxi ${INPUTPROB} | grep -v Notat | awk -v y=${x} '{if(NR==y)print $6,$8,$10,$12}' > ${TMP1}
# Using the python numpy library to multiply the quaternions
$PYTHON ./multiply_quat.py ${TMP1} ${GRID} > ${TMP2}
# Generating the list of quaternions around the best orientation from base
echo 125 > ${ORIENTATIONS}
sed 's/,/ /g' ${TMP2} | sed 's/)/ /g' | sed 's/(/ /g' | awk '{printf"%12.8f%12.8f%12.8f%12.8f\n",$1,$2,$3,$4}' >> ${ORIENTATIONS}
rm -f ${TMP1} ${TMP2}
##########################################################
##########################################################
##########################################################
# BioEM part Round 2
# Path to your BioEM installation
BIOEM=${HOME}/BioEM_project/build/bioEM
# Running BioEM
OMP_NUM_THREADS=12 GPU=1 GPUDEVICE=-1 BIOEM_DEBUG_OUTPUT=0 BIOEM_ALGO=2 mpiexec -perhost 2 ${BIOEM} --Modelfile ${MODEL} --Particlesfile Particles/Particle_$x --Inputfile Param_Input_ModelComparision --ReadOrientation ${ORIENTATIONS} --OutputFile ${OUTPUTPROB}
##########################################################
##########################################################
##########################################################
# Writing results with a proper text in a proper order
# Note that the order in which jobs are going to finish is undetermined, but the results are written in the good order at the end
# Writing to the temporary shared file
echo Job: ${x} $(tail -2 ${OUTPUTPROB} | head -1 | sed 's/RefMap: 0/RefMap: '${x}'/') >> ${FINALOUTTMP}
echo Job: ${x} $(tail -1 ${OUTPUTPROB} | sed 's/RefMap: 0/RefMap: '${x}'/') >> ${FINALOUTTMP}
# Cleanup
rm -f ${ORIENTATIONS} ${OUTPUTTPROB}
# If this was the last job, sort everything and remove JobID
y=2
if [[ $(wc -l < ${FINALOUTTMP}) == $(( $y * $SGE_TASK_COUNT )) ]]
then
sort -n -k 2 ${FINALOUTTMP} | sed 's/Job: [0-9]\+ //' > ${FINALOUTPROB}
rm -rf ${FINALOUTTMP}
fi
#!/bin/bash -l
# Standard output and error:
#SBATCH -o ./tjob_hybrid.out.%j
#SBATCH -e ./tjob_hybrid.err.%j
# Initial working directory:
#SBATCH -D ./
# Job Name:
#SBATCH -J bioem-test-array
# Queue (Partition):
#SBATCH --partition=gpu
# Node feature:
#SBATCH --constraint="gpu"
# Number of nodes and MPI tasks per node:
#SBATCH --nodes=1
#SBATCH --ntasks-per-node=2
# for OpenMP:
#SBATCH --cpus-per-task=16
#SBATCH --time=00:30:00
# Submitting an array
#SBATCH --array=1-20
set -e
echo "Hello: I'm task $SLURM_ARRAY_TASK_ID. SLURM_ARRAY_TASK_MIN=$SLURM_ARRAY_TASK_MIN SLURM_ARRAY_TASK_MAX=$SLURM_ARRAY_TASK_MAX SLURM_ARRAY_TASK_STEP=$SLURM_ARRAY_TASK_STEP"
x=$SLURM_ARRAY_TASK_ID
# The following line is only needed for the older Slurm versions
SLURM_ARRAY_TASK_COUNT=$((($SLURM_ARRAY_TASK_MAX - $SLURM_ARRAY_TASK_MIN + 1) / $SLURM_ARRAY_TASK_STEP))
##########################################################
##########################################################
##########################################################
# Creating a list of quaternions for a specific particle image
# Code similar to the create_gridOr.sh script, only for a single particle image
# Loading Python
module purge
module load anaconda/3/4.3.1
# Variables
#TMPDIR="/tmp/"
M=M1
MODEL=MODEL_1
GRID=smallGrid_125
PYTHON=python3.6
INPUTPROB=Output_${MODEL}
ORIENTATIONS=${TMPDIR}/Quaternion_List_${M}_P${x}
TMP1=${TMPDIR}/base${x}
TMP2=${TMPDIR}/ll${x}
OUTPUTPROB=${TMPDIR}/Output_${MODEL}_P${x}
FINALOUTTMP=Output_Tmp
FINALOUTPROB=Output_${MODEL}_Round2
# Creating list of quaternions
grep Maxi ${INPUTPROB} | grep -v Notat | awk -v y=${x} '{if(NR==y)print $6,$8,$10,$12}' > ${TMP1}
# Using the python numpy library to multiply the quaternions
$PYTHON ./multiply_quat.py ${TMP1} ${GRID} > ${TMP2}
# Generating the list of quaternions around the best orientation from base
echo 125 > ${ORIENTATIONS}
sed 's/,/ /g' ${TMP2} | sed 's/)/ /g' | sed 's/(/ /g' | awk '{printf"%12.8f%12.8f%12.8f%12.8f\n",$1,$2,$3,$4}' >> ${ORIENTATIONS}
rm -f ${TMP1} ${TMP2}
##########################################################
##########################################################
##########################################################
# BioEM part Round 2
# Loading necessary modules for Intel compilers
module load intel/17.0
module load impi/2017.3
module load fftw/3.3.6
module load cuda/8.0
# Environment variables
export OMP_NUM_THREADS=16
export OMP_PLACES=cores
export GPUDEVICE=-1
export GPUWORKLOAD=100
# Environment variable to tune
export BIOEM_CUDA_THREAD_COUNT=1024
export BIOEM_DEBUG_OUTPUT=1
export BIOEM_ALGO=2
export GPU=1
export BIOEM_PROJ_CONV_AT_ONCE=16
# Path to your BioEM installation
BIOEM=${HOME}/BioEM_project/build/bioEM
# Running BioEM
mpiexec -perhost 2 ${BIOEM} --Modelfile ${MODEL} --Particlesfile Particles/Particle_$x --Inputfile Param_Input_ModelComparision --ReadOrientation ${ORIENTATIONS} --OutputFile ${OUTPUTPROB}
##########################################################
##########################################################
##########################################################
# Writing results with a proper text in a proper order
# Note that the order in which jobs are going to finish is undetermined, but the results are written in the good order at the end
# Writing to the temporary shared file
echo Job: ${x} $(tail -2 ${OUTPUTPROB} | head -1 | sed 's/RefMap: 0/RefMap: '${x}'/') >> ${FINALOUTTMP}
echo Job: ${x} $(tail -1 ${OUTPUTPROB} | sed 's/RefMap: 0/RefMap: '${x}'/') >> ${FINALOUTTMP}
# Cleanup
rm -f ${ORIENTATIONS} ${OUTPUTTPROB}
y=2
# If this was the last job, sort everything and remove JobID
if [[ $(wc -l < ${FINALOUTTMP}) == $(( $y * $SGE_TASK_COUNT )) ]]
then
sort -n -k 2 ${FINALOUTTMP} | sed 's/Job: [0-9]\+ //' > ${FINALOUTPROB}
rm -rf ${FINALOUTTMP}
fi
### to run:
# ./create_gridOr.sh $1 $2
## $1 == Output file from previous BioEM round
## $2 == Name to put on lists
# necessary python libraries:
module load python33/python/3.3 python33/scipy/2015.10
PYTHON=python3.3
TMPDIR=/tmp/
INDIR=${TMPDIR}/Quaternion_Lists_${2}
mkdir -p ${INDIR}
OUTPUTFILE=${INDIR}/Quaternion_List_${2}_P
TMP1=${TMPDIR}/base
TMP2=${TMPDIR}/ll
#Change the variable for the total number of images
numim=20
for((y=1;y<${numim}+1;y++))
do
#Extracting the best orientation from the output file from column 1
grep Maxi $1 | grep -v Notat | awk -v x=$y '{if(NR==x)print $6,$8,$10,$12}' > ${TMP1}
#Using the python numpy library to multiply the quaternions
$PYTHON ./multiply_quat.py ${TMP1} smallGrid_125 > ${TMP2}
#generating the list of quaternions around the best orientation from base
echo 125 > ${OUTPUTFILE}${y}
sed 's/,/ /g' ${TMP2} | sed 's/)/ /g' | sed 's/(/ /g' | awk '{printf"%12.8f%12.8f%12.8f%12.8f\n",$1,$2,$3,$4}' >> ${OUTPUTFILE}${y}
echo "Finished ${y}/${numim}"
rm ${TMP1} ${TMP2}
done
import math
import numpy as np
import sys
base = sys.argv[1]
smallGrid = sys.argv[2]
def q_mult(q1, q2):
x1, y1, z1, w1 = q1
x2, y2, z2, w2 = q2
w = w1 * w2 - x1 * x2 - y1 * y2 - z1 * z2
x = w1 * x2 + x1 * w2 + y1 * z2 - z1 * y2
y = w1 * y2 + y1 * w2 + z1 * x2 - x1 * z2
z = w1 * z2 + z1 * w2 + x1 * y2 - y1 * x2
return x, y, z, w
file = open(base,'r')
linesbase = file.readlines()
file.close()
for ii in linesbase:
b0 = float(ii.split()[0])
b1 = float(ii.split()[1])
b2 = float(ii.split()[2])
b3 = float(ii.split()[3])
base = np.array([b0,b1,b2,b3])
file = open(smallGrid,'r')
lines = file.readlines()
file.close()
for i in lines:
q0t = float(i.split()[0])
q1t = float(i.split()[1])
q2t = float(i.split()[2])
q3t = float(i.split()[3])
dqt = np.array([q0t,q1t,q2t,q3t])
v = q_mult(base,dqt)
print (v)
-0.02000000 -0.02000000 -0.02000000 0.99939982
-0.02000000 -0.02000000 -0.01000000 0.99954990
-0.02000000 -0.02000000 -0.00000000 0.99959992
-0.02000000 -0.02000000 0.01000000 0.99954990
-0.02000000 -0.02000000 0.02000000 0.99939982
-0.02000000 -0.01000000 -0.02000000 0.99954990
-0.02000000 -0.01000000 -0.01000000 0.99969995
-0.02000000 -0.01000000 -0.00000000 0.99974997
-0.02000000 -0.01000000 0.01000000 0.99969995
-0.02000000 -0.01000000 0.02000000 0.99954990
-0.02000000 -0.00000000 -0.02000000 0.99959992
-0.02000000 -0.00000000 -0.01000000 0.99974997
-0.02000000 -0.00000000 -0.00000000 0.99979998
-0.02000000 -0.00000000 0.01000000 0.99974997
-0.02000000 -0.00000000 0.02000000 0.99959992
-0.02000000 0.01000000 -0.02000000 0.99954990
-0.02000000 0.01000000 -0.01000000 0.99969995
-0.02000000 0.01000000 -0.00000000 0.99974997
-0.02000000 0.01000000 0.01000000 0.99969995
-0.02000000 0.01000000 0.02000000 0.99954990
-0.02000000 0.02000000 -0.02000000 0.99939982
-0.02000000 0.02000000 -0.01000000 0.99954990
-0.02000000 0.02000000 -0.00000000 0.99959992
-0.02000000 0.02000000 0.01000000 0.99954990
-0.02000000 0.02000000 0.02000000 0.99939982
-0.01000000 -0.02000000 -0.02000000 0.99954990
-0.01000000 -0.02000000 -0.01000000 0.99969995
-0.01000000 -0.02000000 -0.00000000 0.99974997
-0.01000000 -0.02000000 0.01000000 0.99969995
-0.01000000 -0.02000000 0.02000000 0.99954990
-0.01000000 -0.01000000 -0.02000000 0.99969995
-0.01000000 -0.01000000 -0.01000000 0.99984999
-0.01000000 -0.01000000 -0.00000000 0.99989999
-0.01000000 -0.01000000 0.01000000 0.99984999
-0.01000000 -0.01000000 0.02000000 0.99969995
-0.01000000 -0.00000000 -0.02000000 0.99974997
-0.01000000 -0.00000000 -0.01000000 0.99989999
-0.01000000 -0.00000000 -0.00000000 0.99995000
-0.01000000 -0.00000000 0.01000000 0.99989999
-0.01000000 -0.00000000 0.02000000 0.99974997
-0.01000000 0.01000000 -0.02000000 0.99969995
-0.01000000 0.01000000 -0.01000000 0.99984999
-0.01000000 0.01000000 -0.00000000 0.99989999
-0.01000000 0.01000000 0.01000000 0.99984999
-0.01000000 0.01000000 0.02000000 0.99969995
-0.01000000 0.02000000 -0.02000000 0.99954990
-0.01000000 0.02000000 -0.01000000 0.99969995
-0.01000000 0.02000000 -0.00000000 0.99974997
-0.01000000 0.02000000 0.01000000 0.99969995
-0.01000000 0.02000000 0.02000000 0.99954990
-0.00000000 -0.02000000 -0.02000000 0.99959992
-0.00000000 -0.02000000 -0.01000000 0.99974997
-0.00000000 -0.02000000 -0.00000000 0.99979998
-0.00000000 -0.02000000 0.01000000 0.99974997
-0.00000000 -0.02000000 0.02000000 0.99959992
-0.00000000 -0.01000000 -0.02000000 0.99974997
-0.00000000 -0.01000000 -0.01000000 0.99989999
-0.00000000 -0.01000000 -0.00000000 0.99995000
-0.00000000 -0.01000000 0.01000000 0.99989999
-0.00000000 -0.01000000 0.02000000 0.99974997
-0.00000000 -0.00000000 -0.02000000 0.99979998
-0.00000000 -0.00000000 -0.01000000 0.99995000
-0.00000000 -0.00000000 -0.00000000 1.00000000
-0.00000000 -0.00000000 0.01000000 0.99995000
-0.00000000 -0.00000000 0.02000000 0.99979998
-0.00000000 0.01000000 -0.02000000 0.99974997
-0.00000000 0.01000000 -0.01000000 0.99989999
-0.00000000 0.01000000 -0.00000000 0.99995000
-0.00000000 0.01000000 0.01000000 0.99989999
-0.00000000 0.01000000 0.02000000 0.99974997
-0.00000000 0.02000000 -0.02000000 0.99959992
-0.00000000 0.02000000 -0.01000000 0.99974997
-0.00000000 0.02000000 -0.00000000 0.99979998
-0.00000000 0.02000000 0.01000000 0.99974997
-0.00000000 0.02000000 0.02000000 0.99959992
0.01000000 -0.02000000 -0.02000000 0.99954990
0.01000000 -0.02000000 -0.01000000 0.99969995
0.01000000 -0.02000000 -0.00000000 0.99974997
0.01000000 -0.02000000 0.01000000 0.99969995
0.01000000 -0.02000000 0.02000000 0.99954990
0.01000000 -0.01000000 -0.02000000 0.99969995
0.01000000 -0.01000000 -0.01000000 0.99984999
0.01000000 -0.01000000 -0.00000000 0.99989999
0.01000000 -0.01000000 0.01000000 0.99984999
0.01000000 -0.01000000 0.02000000 0.99969995
0.01000000 -0.00000000 -0.02000000 0.99974997
0.01000000 -0.00000000 -0.01000000 0.99989999
0.01000000 -0.00000000 -0.00000000 0.99995000
0.01000000 -0.00000000 0.01000000 0.99989999
0.01000000 -0.00000000 0.02000000 0.99974997
0.01000000 0.01000000 -0.02000000 0.99969995
0.01000000 0.01000000 -0.01000000 0.99984999
0.01000000 0.01000000 -0.00000000 0.99989999
0.01000000 0.01000000 0.01000000 0.99984999
0.01000000 0.01000000 0.02000000 0.99969995
0.01000000 0.02000000 -0.02000000 0.99954990
0.01000000 0.02000000 -0.01000000 0.99969995
0.01000000 0.02000000 -0.00000000 0.99974997
0.01000000 0.02000000 0.01000000 0.99969995
0.01000000 0.02000000 0.02000000 0.99954990
0.02000000 -0.02000000 -0.02000000 0.99939982
0.02000000 -0.02000000 -0.01000000 0.99954990
0.02000000 -0.02000000 -0.00000000 0.99959992
0.02000000 -0.02000000 0.01000000 0.99954990
0.02000000 -0.02000000 0.02000000 0.99939982
0.02000000 -0.01000000 -0.02000000 0.99954990
0.02000000 -0.01000000 -0.01000000 0.99969995
0.02000000 -0.01000000 -0.00000000 0.99974997
0.02000000 -0.01000000 0.01000000 0.99969995
0.02000000 -0.01000000 0.02000000 0.99954990
0.02000000 -0.00000000 -0.02000000 0.99959992
0.02000000 -0.00000000 -0.01000000 0.99974997
0.02000000 -0.00000000 -0.00000000 0.99979998
0.02000000 -0.00000000 0.01000000 0.99974997
0.02000000 -0.00000000 0.02000000 0.99959992
0.02000000 0.01000000 -0.02000000 0.99954990
0.02000000 0.01000000 -0.01000000 0.99969995
0.02000000 0.01000000 -0.00000000 0.99974997
0.02000000 0.01000000 0.01000000 0.99969995
0.02000000 0.01000000 0.02000000 0.99954990
0.02000000 0.02000000 -0.02000000 0.99939982
0.02000000 0.02000000 -0.01000000 0.99954990
0.02000000 0.02000000 -0.00000000 0.99959992
0.02000000 0.02000000 0.01000000 0.99954990
0.02000000 0.02000000 0.02000000 0.99939982
paste $1 $2 | grep LogProb: | awk 'BEGIN{cum=0;dif=0}{if($1=="RefMap:"){dif=$4-$10;cum+=dif;printf"MapNum: %6d Mod1: %10.5f Mod2: %10.5f Dif: %10.5f Cum: %10.5f\n",$2,$4,$10,dif,cum}}'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment