Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have the following .sh script in which I am trying to do all major writing in $TMPDIR.

However, when it gets to line 86, it returns the following error:

/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_2304_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_2107_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_1209_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_1301_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_2115_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_2210_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_2307_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_2302_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_2303_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_1306_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_1115_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_1110_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_1204_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_2214_Header.sam: No such file or directory
/var/spool/uge/bnbhimem2/job_scripts/855849: line 86: /tmp/uge/855849.2.primary.q//tmp/uge/855849.2.primary.q/Alignments_2308_Header.sam: No such file or directory

I thought this file was supposed to be created with the output of cat , why is it complaining that it does not exist?

Thanks, Carmen

  1 #!/bin/sh
  2 
  3 ##Usage: run_Split_by_Tile_AWK.sh [0-7]
  4 
  5 # Run on the current working directory
  6 #$ -cwd
  7 # Give this job a name
  8 #$ -N Split_by_Tile_AWK
  9 # Join standard output and error to a single file
 10 #$ -j y
 11 # Name the file where to redirect standard output and error
 12 ## -o AWK_Split_by_Tile
 13 # Send an email when the job begins and when it ends running
 14 #$ -m be
 15 # Whom to send the email to
 16 #$ -M [email protected]
 17 # Local disk space and memory necessary
 18 ## –l tmp_free=900G
 19 #$ -l m_mem_free=400G
 20 # Array job options
 21 #$ -t 1-8
 22 
 23 # Now let's keep track of some information just in case anything goes wrong.
 24 
 25 echo "=========================================================="
 26 echo "Starting on : $(date)"
 27 echo "Running on node : $(hostname)"
 28 echo "Current directory : $(pwd)"
 29 echo "Current job ID : $JOB_ID"
 30 echo "Current job name : $JOB_NAME"
 31 echo "Task index number : $SGE_TASK_ID"
 32 echo "=========================================================="
 33 
 34 # Run some commands
 35 
 36 export PATH=/opt/hpc/bin:$PATH
 37 export PATH=$HOME/bin:$PATH
 38 
 39 parent_tophat=/data/bsr/tforcier/tophat_results
 40 
 41 folder_array=(tophat_WTyoungRep1take2_out tophat_WTyoungRep2_out tophat_WToldRep1_out  tophat_WToldRep2take2_out tophat_Ago2youngRep1take2_out tophat_Ago2youngRep2_out tophat_Ago2oldRep1_out tophat_Ago    2oldRep2_out)
 42 
 43 i=$(($SGE_TASK_ID - 1))
 44 
 45 ##Build input
 46 
 47 input=$parent_tophat/${folder_array[$i]}/accepted_hits.bam
 48 
 49 ##Make output base name
 50 
 51 y=${folder_array[$i]#tophat_}
 52 
 53 outputBase=${y%_out}
 54 
 55 ##outputBase ~=Ago2youngRep1take2 or ~=WTyoungRep2##
 56 
 57 cp $input $TMPDIR/$outputBase.bam
 58 
 59 temporal_input=$TMPDIR/$outputBase.bam
 60 
 61 cp /data/bsr/csandova/mRNA_Seq/TileLists/Tile_Number_List.txt $TMPDIR/Tile_Number_List.txt
 62 
 63 mkdir -v $outputBase\_Split
 64 
 65 newDir=$outputBase\_Split
 66 
 67 ##newDir ~=Ago2youngRep1take2_Split or ~=WTyoungRep2_Split##
 68 
 69 
 70 #Process BAM files
 71 
 72 samtools view $temporal_input | awk -F '[\t:]' -v opath="$TMPDIR" '
 73 
 74 FNR == NR {
 75     num[$1]
 76     next
 77 }
 78 
 79 $5 in num {
 80     f = opath"/Alignments_"$5".sam";
 81     print > f
 82 } ' $TMPDIR/Tile_Number_List.txt -
 83 
 84 for x in $(find $TMPDIR -name '*.sam'); do
 85 
 86 cat SAMHeader.txt $x >$TMPDIR/${x%.sam}_Header.sam;
 87 
 88 rm $x;
 89 
 90 done
 91 
 92 for x in $(find $TMPDIR -name '*_Header.sam');
 93 
 94 do samtools view -bS $x | samtools sort - $newDir/${x%.sam}.bam ;
 95 
 96 done
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

The error message

No such file or directory

means that the directory you're trying to create the file in does not exist.

The problem is that

for x in $(find $TMPDIR -name '*.sam'); do

already stores the full path in the variable x, so you have to use

cat SAMHeader.txt $x > ${x%.sam}_Header.sam

instead of

cat SAMHeader.txt $x > $TMPDIR/${x%.sam}_Header.sam
share|improve this answer
    
Thank you! Problem solved. :) –  Carmen Sandoval May 7 '13 at 17:42
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.