Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
为什么在prinseqlite perl循环中没有写入输出文件?_Perl_File_Loops_Output_Sh - Fatal编程技术网

为什么在prinseqlite perl循环中没有写入输出文件?

为什么在prinseqlite perl循环中没有写入输出文件?,perl,file,loops,output,sh,Perl,File,Loops,Output,Sh,我对这种类型的编码/命令行是完全陌生的,所以如果我以错误的方式问这个问题,我很抱歉 我想循环一个目录中的所有文件(我是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_tai

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

我想循环一个目录中的所有文件(我是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

有一个简单的原因/答案吗?

这个问题与Perl没有任何关系

/proj/forhot/qfiltered/looptest/$i_filtered.fastq
被shell读取为插入
i_filtered
的内容。没有这样的shell变量,因此此参数将变为
/proj/forhot/qfiltered/looptest/.fastq
$i_filtered
将变为零)

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

修理

请注意,这将为输入文件
60782\u merged\u rRNA.fastq\u filtered.fastq
提供例如
60782\u merged\u rRNA.fastq
。如果您想消除重复的
.fastq
部分,您需要如下内容:

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

“如果我以非循环方式运行代码”-您使用的确切命令行是什么?您好,我编辑了post,包括有效的代码行-这就是您的意思吗?@melpomene我想她在单个文件上运行它,而不是
$I
EDIT:我看到它被编辑了。@Mathilde是的,这就是他问的:)@GerhardBarnard是的,但如何操作?从编辑中,您可以看到
-out\u file
参数完全不同(例如,no
\u filtered
)。你们太棒了非常感谢。虽然我无法使“.fastq”的减少生效,但这确实是一件小事。
... -out_good /proj/forhot/qfiltered/looptest/"${i%.fastq}"_filtered.fastq