Detecting error in Ubuntu environment
1
0
Entering edit mode
6.3 years ago

Hi everyone,

I have a script(Blast_helper.sh) that tries to create blast database of the reference Fasta files(ALLSeqs.faa) in UBUNTU. I do this with help of this command: "Blast_helper.sh -i ALLSeqs.faa", but I get this error: Error in tempfile() using template /tmp/parXXXXX.par: Parent directory (/tmp/) does not exist at /usr/bin/parallel line 3280. Do someone know the reason for this error? I will be very grateful for your help.

fasta Ubuntu • 2.8k views
ADD COMMENT
0
Entering edit mode

What is the output of

ls -ld /tmp

?

ADD REPLY
0
Entering edit mode

Hello :) This is the output:

ls: cannot access '/tmp': No such file or directory

ADD REPLY
0
Entering edit mode

looks like someone removed your /tmp directory. /tmp is the standard UNIX directory for putting temporary files, it should always be there. Ask your system administrator to fix it or see https://askubuntu.com/questions/178751/accidentally-deleted-tmp-folder. You might experience other problems on that system. I agree that is not really a bioinformatics problem.

ADD REPLY
0
Entering edit mode

Thank you so much for your help. I'm really grateful.

ADD REPLY
0
Entering edit mode
ADD REPLY
1
Entering edit mode
6.3 years ago
Ram 44k

This is more of an Ubuntu question than a bioinformatics question. Try running a sudo apt-get update followed by a sudo apt-get install parallel

ADD COMMENT
0
Entering edit mode

If OP does not have sudo privileges this would not work.

ADD REPLY
0
Entering edit mode

Thank you for your help sir, but I have already tried that it doesn't work, I get the same error.

ADD REPLY
0
Entering edit mode

Could you share the script. It seems it is trying to create a temp directory which you cannot excess or does not exist. Possibly changing that directory where it stores might help.

ADD REPLY
0
Entering edit mode
#!/bin/bash
############################
#Usage:
#
# Blast_helper.sh <input.fasta> <query.fasta>
# Note: To produce comaparable results the effective  database size set to 34355436272, the number 
#aminoacids in uniprot release  2017_12 of 20-Dec-201
#Requires:
#
#    -gnu-parallel
#    -blast+ (tested with versions 2.2.30)
# 
############################

#Global variable definitions

ldb_path='local_db'
db_type='prot'
type='blastp'
input=''
query=''


#echo $query



#functions

CreateBlastDB ()
{
    if ! [ -d $ldb_path ]
    then mkdir $ldb_path;
    echo 'Creating local blast database at ' ldb_path  
    fi
    makeblastdb -dbtype $db_type -in $input -input_type 'fasta' -out local_db/localDB
}

AllvsAll ()
{
    find . -empty -delete
    echo 'Starting BLAST search' $query 'vs.' $input 'using' $type.
    if [ ! -e BLAST_results_${query%.*}.csv ]
    then
    cat $query | parallel --block 100k --pipe --recstart '>' $type -evalue 0.001 -outfmt 10 -db local_db/localDB -dbsize 34355436272 -query - > BLAST_results_${query%.*}.csv
    else
    echo 'A BLAST output file matching the query name exist in the wd.'
    #Lets try to restart the BLAST search from where it was left.
    # Firts lets see what is the last record written  to the output file
    last=`tail -n1 BLAST_results_${query%.*}.csv | cut -f 1 -d ','`
    qline=`grep -n  $last $query | cut -f 1 -d ':'`
    #remove last query from the output
    sed -i -e "/^"$last"/d" BLAST_results_${query%.*}.csv
    #start from previous last query
    echo "Re-starting from line:" $qline "=" $last 
    tail -n +$qline $query | parallel  --block 100k --pipe --recstart '>' $type -evalue 0.001 -outfmt 10 -db local_db/localDB -dbsize 34355436272  -query - >> BLAST_results_${query%.*}.csv
    fi
}


usage() {
cat <<EOF
usage: $0 <options>
This script helps the user to perform local BLAST searches for protein
homology assesment. It takes as input a file with sequences in FASTA format 
from which a local BLAST database is created. This same file is use as the
query unless otherwise specified trough -q.  GNU parallel and BLAST+
should be in installed and properly cited when using this script.
-h   |  Print this help
-i   |  The input FASTA file to build a BLASTDB   
-q   |  Specify a query file, otherwise all vs. all will be performed using the "-i" file.
-p   |  Use psiblast instead of blastp
EOF
}

### Main
OPTIND=1
while getopts "hepq:i:" opt; do

    case "$opt" in
    h)
        usage
        exit 0
        ;;

    i)
        input=$OPTARG
        ;;

    q) 
        query=$OPTARG
        ;;

    p)
        type='psiblast'
        ;;

    '?')
        usage 
        exit 1
        ;;
    :)
        usage
        exit 1
        ;;
    esac

done

shift $((OPTIND-1))
if [ "$query" = "" ]
then
    query=$input
fi

echo $query vs $input
echo $type

if [ "$input" != "" ]
then
    if ls local_db/localDB* 1> /dev/null 2>&1;
    then
    echo "A local BLAST database exist, proceeding to the search step";
    AllvsAll;
    else
    echo "Creating local BLAST database."
    CreateBlastDB && AllvsAll;
    fi
else
    echo "ERROR: Input file needed [-i]"
    exit 1

fi
exit $?
ADD REPLY
2
Entering edit mode

Run mkdir ~/tmp and then run the script after changing each parallel (I see them in lines 45 and 56) to parallel --tmpdir ~/tmp

ADD REPLY

Login before adding your answer.

Traffic: 1345 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6