Skip to content

Commit

Permalink
peach API fixes (#21)
Browse files Browse the repository at this point in the history
* syntax error fix

* add comment

* comment code relaying on Peach API and echo a msg

* Update lsf.sh

Co-authored-by: Iris Diana Yu <[email protected]>

* add suggestions

Co-authored-by: Iris Diana Yu <[email protected]>
  • Loading branch information
pmb59 and irisdianauy authored Jan 10, 2023
1 parent 7f85e73 commit 94b8a20
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 31 deletions.
65 changes: 34 additions & 31 deletions generic_routines.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
IFS="
"

PEACH_API_URI=${PEACH_API_URI:'http://peach.ebi.ac.uk:8480/api'}
# deprecated by biostudies
#PEACH_API_URI=${PEACH_API_URI:-'http://peach.ebi.ac.uk:8480/api'}

# Check that a given variable is defined

Expand Down Expand Up @@ -89,40 +90,42 @@ function capitalize_first_letter {
## -GEOD-/-ERAD-/-ENAD- are loaded as public from now on
peach_api_privacy_status() {
expAcc=$1
exp_import=$(echo $expAcc | awk -F"-" '{print $2}')

if [ $exp_import == "MTAB" ]; then
response=$(curl -s "${PEACH_API_URI}/privacy.txt?acc=$expAcc")
if [ -z "$response" ]; then
die "WARNING: Got empty response from ${PEACH_API_URI}/privacy.txt?acc=$expAcc" 0
fi
privacyStatus=$(echo $response | awk '{print $2}' | awk -F":" '{print $2}')
## if not MTAB, ie. GEOD or ENAD or ERAD are all loaded as public
else
privacyStatus=$(echo "public")
fi

echo $privacyStatus
#exp_import=$(echo $expAcc | awk -F"-" '{print $2}')
#
#if [ $exp_import == "MTAB" ]; then
# response=$(curl -s "${PEACH_API_URI}/privacy.txt?acc=$expAcc")
# if [ -z "$response" ]; then
# die "WARNING: Got empty response from ${PEACH_API_URI}/privacy.txt?acc=$expAcc" 0
# fi
# privacyStatus=$(echo $response | awk '{print $2}' | awk -F":" '{print $2}')
# ## if not MTAB, ie. GEOD or ENAD or ERAD are all loaded as public
#else
# privacyStatus=$(echo "public")
#fi
#
#echo $privacyStatus
echo "Privacy status can no longer be obtained via the Peach API"
}

peach_api_release_date() {
expAcc=$1
exp_import=$(echo $expAcc | awk -F"-" '{print $2}')

if [ $exp_import == "MTAB" ]; then
response=$(curl -s "$PEACH_API_URI/privacy.txt?acc=$expAcc")
if [ -z "$response" ]; then
die "WARNING: Got empty response from ${PEACH_API_URI}/privacy.txt?acc=$expAcc" 0
fi
releaseDate=$(echo $response | awk '{print $3}' | awk -F":" '{print $2}')

## if not MTAB, ie. GEOD or ENAD or ERAD are all loaded as of today, considering its public and have release date
## not less than 2 days
else
releaseDate="$(date --date="2 days ago" +%Y-%m-%d)"
fi

echo $releaseDate
#exp_import=$(echo $expAcc | awk -F"-" '{print $2}')
#
#if [ $exp_import == "MTAB" ]; then
# response=$(curl -s "$PEACH_API_URI/privacy.txt?acc=$expAcc")
# if [ -z "$response" ]; then
# die "WARNING: Got empty response from ${PEACH_API_URI}/privacy.txt?acc=$expAcc" 0
# fi
# releaseDate=$(echo $response | awk '{print $3}' | awk -F":" '{print $2}')
#
### if not MTAB, ie. GEOD or ENAD or ERAD are all loaded as of today, considering its public and have release date
### not less than 2 days
#else
# releaseDate="$(date --date="2 days ago" +%Y-%m-%d)"
#fi
#
#echo $releaseDate
echo "Release date information can no longer be obtained from the Peach API."
}

enad_experiment() {
Expand Down
3 changes: 3 additions & 0 deletions lsf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@ lsf_submit(){
if [ -n "$workingDir" ]; then workingDir=" -cwd \"$workingDir\""; fi
if [ -n "$condaEnv" ]; then
condaBase=$(conda info --json | awk '/conda_prefix/ { gsub(/"|,/, "", $2); print $2 }')
#condaCmd=". ${condaBase}/bin/activate ${condaBase}/envs/${condaEnv}"
###### the lines below were added to enable the activation of a conda env that is not inside the base conda env directory
condaEnvPath="${condaBase}/envs/${condaEnv}"
if [ -d "$condaEnv" ]; then condaEnvPath="$condaEnv"; fi
condaCmd=". ${condaBase}/bin/activate ${condaEnvPath}"
######
commandString="${condaCmd} && ${commandString}"
fi
if [ -n "$logPrefix" ]; then
Expand Down

0 comments on commit 94b8a20

Please sign in to comment.