Last active
February 2, 2023 21:01
-
-
Save PlethoraChutney/119093f9ab9172fc98750e09ea5d4c29 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Test to make sure csparc2star.py is in PATH and installed correctly: | |
csparc2star.py -h &> /dev/null | |
if [ $? -ne 0 ]; then | |
echo Failed to run csparc2star.py. Are you in the correct virtual environment? Did you check your path? | |
exit | |
fi | |
# Change this to your csparc scratch directory. This should be where all your P* dirs are | |
CSPARC_DIR="/path/to/your/cryosparc/projects" | |
echo Using cryosparc dir $CSPARC_DIR | |
echo If that looks wrong, modify the script at line 11 | |
read -p "What cryosparc project are you converting? Number only: " PROJECT | |
PROJECT=P${PROJECT} | |
read -p "What is the job number of the refinement? Number only: " REFINE | |
REFINE=J${REFINE} | |
# figure out extract job's number | |
pushd $CSPARC_DIR/$PROJECT/exports/jobs/${PROJECT}_$REFINE*/*particles/ > /dev/null | |
EXTRACT=$(ls * | grep extract -B 1 | grep -o J[0-9]*) | |
popd > /dev/null | |
echo Now converting ${PROJECT} ${REFINE} to a RELION project... | |
mkdir -p ${EXTRACT}/extract | |
pushd ${EXTRACT}/extract > /dev/null | |
ln -s ${CSPARC_DIR}/${PROJECT}/${EXTRACT}/extract/*.mrc -t . | |
echo Done linking images... | |
# depending on which `rename` you have installed, you may | |
# need to use the one I've commented out here, instead of the | |
# one I use. | |
# | |
# rename .mrc .mrcs *.mrc | |
rename s/.mrc/.mrcs/g *.mrc | |
echo "Done renaming images. If you saw an error, go change the rename command (line 39)." | |
echo Converting coordinates... | |
# swapxy and inverty are important for keeping micrograph coordinates correct between the two | |
# packages. But if you get errors about particles being outside the micrograph, try removing | |
# those options | |
popd > /dev/null | |
csparc2star.py $(ls ${CSPARC_DIR}/${PROJECT}/${REFINE}/cryosparc*particles.cs | tail -n 1) from_csparc.star --swapxy --inverty | |
echo .star file created | |
sed -i 's/particles.mrc/particles.mrcs/g' from_csparc.star | |
sed -i 's/>//g' from_csparc.star | |
echo .star file fixed | |
echo "done :)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For this to work, the job must be exported (in the cryoSPARC web interface, it's one of the job actions)