【发布时间】:2016-08-16 14:59:36
【问题描述】:
我的输入目录中有一些bam 文件,对于每个bam 文件,我想计算映射读取的数量(使用Samtools view 命令)并打印该数字以及bam 的名称文件转换为输出文件。虽然它正在工作,但我没有得到我想要的输出。
这是我的代码的样子
for file in input/*;
do
echo $file >> test.out;
samtools view -F 4 $file | wc -l >> output;
done
这很好用,但问题是它会在不同的行中输出文件名和读取次数。这是一个例子
sample_data/wgEncodeUwRepliSeqBg02esG1bAlnRep1.bam
1784867
sample_data/wgEncodeUwRepliSeqBg02esG2AlnRep1.bam
2280544
我试图通过这样做将换行符转换为制表符
for file in input/*;
do
echo $file >> output;
samtools view -F 4 $file | wc -l >> output;
tr '\n' '\t' < output > output2
done
这是相同的输出
sample_data/wgEncodeUwRepliSeqBg02esG1bAlnRep1.bam 1784867 sample_data/wgEncodeUwRepliSeqBg02esG2AlnRep1.bam 2280544
现在如何在每行之后插入换行符?例如
sample_data/wgEncodeUwRepliSeqBg02esG1bAlnRep1.bam 1784867
sample_data/wgEncodeUwRepliSeqBg02esG2AlnRep1.bam 2280544
谢谢
【问题讨论】:
-
为什么不建生产线?
echo -e "$file\t$var",其中$var包含samtools view...的输出。