【问题标题】:Why is no output files written in prinseqlite perl loop?为什么没有在prinseqlite perl循环中写入输出文件?
【发布时间】:2019-01-29 11:15:21
【问题描述】:

我对这种类型的编码/命令行完全陌生,所以如果我以错误的方式问这个问题,我很抱歉。

我想遍历目录中的所有文件(我正在高质量修剪 DNA 测序文件(.fastq 格式))

我已经写了这个循环:

for i in *.fastq; do
perl /apps/prinseqlite/0.20.4/prinseq-lite.pl -fastq $i -min_len 220 -max_len 240 -min_qual_mean 30  -ns_max_n 5 -trim_tail_right 15 -trim_tail_left 15 -out_good /proj/forhot/qfiltered/looptest/$i_filtered.fastq -out_bad null; done

代码本身似乎可以工作,我可以在我的终端中看到它正在获取正确的文件并且正在进行修剪(它正在终端中写入摘要日志),但没有生成输出文件- 即这些:

-out_good /proj/forhot/qfiltered/looptest/$i_filtered.fastq

如果我以非循环方式运行代码,则仅在一个文件上运行(= 生成输出)。链接这个例子:

prinseq-lite.pl -fastq 60782_merged_rRNA.fastq -min_len 220 -max_len 240 -min_qual_mean 30  -ns_max_n 5 -trim_tail_right 15 -trim_tail_left 15 -out_good 60782_merged_rRNA_filt_codeTEST.fastq -out_bad null

对此有简单的原因/答案吗?

【问题讨论】:

  • "如果我以非循环方式运行代码" - 您使用的确切命令行是什么?
  • 嗨,我编辑发布包括。有效的代码行 - 这是你的意思吗?
  • @melpomene 我认为她在单个文件上运行它,而不是$i EDIT:我看到它已被编辑。
  • @Mathilde 是的,他就是这么问的 :)
  • @GerhardBarnard 是的,但是怎么做?从编辑中您可以看到-out_file 参数完全不同(例如,没有_filtered)。

标签: perl file loops output sh


【解决方案1】:

这个问题和 Perl 完全没有关系。

/proj/forhot/qfiltered/looptest/$i_filtered.fastq 被 shell 读取为插入 i_filtered 的内容。没有这样的shell变量,所以这个参数变成/proj/forhot/qfiltered/looptest/.fastq$i_filtered变成空)。

因此,您所有的prinseq-lite.pl 执行都将它们的输出放在同一个文件中,该文件(因为它的名称以. 开头)是“隐藏的”:您需要使用ls -a 来查看它,而不仅仅是@ 987654328@.

修复

... -out_good /proj/forhot/qfiltered/looptest/${i}_filtered.fastq

请注意,这会给您例如60782_merged_rRNA.fastq_filtered.fastq 用于60782_merged_rRNA.fastq 的输入文件。如果你想摆脱重复的.fastq 部分,你需要类似的东西:

... -out_good /proj/forhot/qfiltered/looptest/"${i%.fastq}"_filtered.fastq

【讨论】:

  • 你们太棒了! - 谢谢。我不能让“.fastq”的减少工作,但这真的是一件小事。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-03
  • 1970-01-01
  • 2021-06-01
  • 1970-01-01
  • 2021-01-19
  • 1970-01-01
相关资源
最近更新 更多