将输出写入 $TMPDIR/$variable:文件不存在(应创建)

将输出写入 $TMPDIR/$variable:文件不存在(应创建)

我有以下.sh 脚本,我正在尝试在 $TMPDIR 中进行所有主要的写入操作。

然而,当执行到第 86 行时,返回以下错误:

/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

我以为这个文件应该是用 cat 的输出创建的,为什么它会抱怨它不存在?

谢谢,卡门

  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

答案1

错误消息

No such file or directory

意味着您尝试在其中创建文件的目录不存在。

问题是

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

已将完整路径存储在变量中X,所以你必须使用

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

代替

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

相关内容