【问题标题】:Why am I not finding any output files in the desired location?为什么我在所需位置找不到任何输出文件?
【发布时间】:2016-08-20 11:11:18
【问题描述】:

我正在尝试编写一个处理脚本,但我一开始就卡住了。它似乎没有错,但我不能简单地理解错误在哪里,因为它正在完成执行但没有给出任何输出。有调试帮助吗?

#!/bin/sh    
#
# Call with following arguments
# sh test.sh  <output_basename> <fastq folder> <output_folder_loc>
#
#   
bn=$1
floc=$2
outloc=$3
#Create an output directory
#opdir=$bn"_processed"
mkdir $outloc/$bn"_processed"
echo "output directory for fastq $outloc/$bn"_processed" ..."

fout=$outloc/$bn"_processed"
echo "$fout ..."

echo "performing assembly to create one fastq file for each read mates ..."
zcat $floc/*R1*.fastq.gz > $fout/$bn_R1.fastq
zcat $floc/*R2*.fastq.gz > $fout/$bn_R2.fastq
echo "done"

运行命令:

sh test.sh S_13_O1_122 /home/vdas/data/floc/Sample_S_13_O1_122_S12919 /home/vdas/data/OC/RNA-Seq/STAR_run/mut_out

我在代码中没有看到任何错误,它也在正常运行,但仍然没有得到任何输出。谁能指出我的问题?

【问题讨论】:

  • 在脚本开头添加set -x,再次运行查看执行流程。

标签: bash shell sh fastq zcat


【解决方案1】:

首先尝试像这样更改两行:

mkdir -p "$outloc/${bn}_processed"
fout="$outloc/${bn}_processed"

mkdir -p$outloc 目录尚不存在时很好。

【讨论】:

  • 或者,更准确地说,mkdir -p 将创建所提供路径的缺失部分
  • 是的,我的错,因为解析基本名称的方式正在完成。这就是它不起作用的原因。现在好了。
【解决方案2】:

您可以测试您的参数(以下可能仅在 bash 中,但当 bash 作为 /bin/sh 调用时可以工作)

var=$1
if [ ${#var} -eq 0 ]; then
  echo "var is not defined" >&2
  exit 1
fi

这将测试变量是否有一定长度,您可能还想测试其他方面,例如

ls $floc/*R1*.fastq.gz

产生任何输出?

【讨论】:

  • 我在该位置有很多文件,所以我使用模式将 R1 文件放在 $floc 中,为 R2 提供一个文件和类似文件,然后将它们传递给下游的其他一些命令。
  • @vchris_ngs :这是应该包含在 Q 正文中的重要信息。祝你好运。
【解决方案3】:
 #!/bin/sh    
 #
 # Call with following arguments
 # sh test.sh  <output_basename> <fastq folder> <output_folder_loc>
 #
 #   
 bn=$1
 floc=$2
 outloc=$3
 #Create an output directory
 #opdir=$bn"_processed"
 mkdir $outloc/$bn"_processed"
 echo "output directory for fastq $outloc/$bn"_processed" ..."

 fout=$outloc/$bn"_processed"
 echo "$fout ..."

 echo "performing assembly to create one fastq file for each read mates ..."
 echo $floc/*R1*.fastq.gz
 echo $fout/$bn_R1.fastq
 zcat -v  $floc/*R1*.fastq.gz > $fout/${bn}_R1.fastq
 zcat  -v $floc/*R2*.fastq.gz > $fout/${bn}_R2.fastq
 echo "done"

`

这可能是你想要的,

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-10-25
    • 1970-01-01
    • 2014-11-01
    • 2019-08-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多