FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 046d7849 authored by Vitor Trovisco's avatar Vitor Trovisco
Browse files

Improved delete_pub_list.sh - now it automatically deletes sessions and...

Improved delete_pub_list.sh - now it automatically deletes sessions and publications, without any manual tweaking
parent f447981e
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
#!/bin/bash -x
#this script will try and delete a list of publications from Canto (one PMID per line in the file PMID_to_delete.tsv)
##if publications have associated sessions (which all loaded publications have by default, unless sessions are manulally deleted), this script will spit out the list of sessions ("sessions_to_delete.txt", newline-separated)
## if publications have associated sessions (which all loaded publications in flybase-vm's Canto should have by default... unless sessions are manulally deleted), publications cannot be deleted. Therefore, the script will a) try to delete the publications, b) any existing sessions will be listed in "sessions_to_delete.txt", c) which will then be deleted, and c) finally the original list of publications will be deleted.
###vt: I couldn't make it correctly use the file with the list of sessions to delete them. So, to delete the publications and sessions 1) use a text editor to convert the sessions list into a space-separated list, b) manually run the canto_delete.pl script using that sessions list as the argument (e.g. sudo ./canto/script/canto_docker ./script/canto_delete.pl --curs f0a6084f3c947e08 28bf95150c6d34a9) and c) manually run the canto_delete.pl script to delete the original publication list.
FILENAME="PMID_to_delete.tsv"
PMID_DEL=$(cat "${FILENAME}")
# this will delete publications any publications without sessions; if sessions exist, the curs_key/ID will be spelled out in the output, written into "temp_output.txt"
sudo ./canto/script/canto_docker ./script/canto_delete.pl --pub $(cat "${FILENAME}") > "temp_output.txt"
echo ${PMID_DEL} | tr '\n' ' ' > "PMID_to_delete1.txt"
FILENAME1="PMID_to_delete1.txt"
PMID_DEL1=$(cat "${FILENAME1}")
# curs_key will appear in a line after a double white-space
# To retrieve curs_keys and eliminate the white spaces, run:
sed -n -e '/ /p' "temp_output.txt" > "temp_output1.txt"
sed 's/ //' "temp_output1.txt" > "temp_output2.txt"
# this will delete publications without sessions and route the command log into temp_output.txt
sudo ./canto/script/canto_docker ./script/canto_delete.pl --pub ${PMID_DEL1} > "temp_output.txt"
#this will replace the odd character '/r' with a white-space and write the sessions list into the file "sessions_to_delete.txt"
# ('/r' characters would prevent sessions from being deleted, therefore they need to be deleted)
FILENAME1="temp_output2.txt"
SESS_DEL=$(cat "${FILENAME1}")
echo ${SESS_DEL} | tr '\r' ' ' > "sessions_to_delete.txt"
# If pubs have sessions, their curs_key will appear in a line after a triple white space. #To retrieve curs_keys and eliminating white spaces, run:
sed -n -e '/ /p' "temp_output.txt" > "temp_output1.txt"
sed 's/ //' "temp_output1.txt" > "sessions_to_delete.txt"
#the following lines will a) 1st remove all sessions and b) repeat the command to delete the original list of publications
FILENAME2="sessions_to_delete.txt"
sudo ./canto/script/canto_docker ./script/canto_delete.pl --curs $(cat "${FILENAME2}")
sudo ./canto/script/canto_docker ./script/canto_delete.pl --pub $(cat "${FILENAME}")
rm "temp_output.txt"
rm "temp_output1.txt"
rm "PMID_to_delete1.txt"
rm "temp_output2.txt"
rm "sessions_to_delete.txt"
rm "sessions_to_delete.txt"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment