我的fastq脚本仍然存在问题。这次我遇到了脚本如何处理输入的问题。
这是我脚本的一部分
while read Sequence_Name && read Sequence && read Quality_name && read Quality_sequence
n=1
do
if [[ ${#Sequence} != ${#Quality_sequence} ]] ; then
echo "Length of Sequence $n different from Length of Quality Sequence"
echo ${#Sequence} #line added to see the ouput
echo $Sequence #line added to see the ouput
echo ${#Quality_sequence} #line added to see the ouput
echo $Quality_sequence #line added to see the ouput
fi
n=$((n+1))
done <$1
问题是输出看起来不像输入。比如
这是输入文件中的内容:
@SRR1350630.196.1 HWUSI-EAS753_0012:8:1:7018:1029 length=24
TGTAAACATCCTACACTCTCAGCT
+SRR1350630.196.1 HWUSI-EAS753_0012:8:1:7018:1029 length=24
`__^\\aa_Z_ccccacc[a\cYc
@SRR1350630.197.1 HWUSI-EAS753_0012:8:1:8338:1032 length=24
TTTGGCAATGGTAGAACTCACACC
+SRR1350630.197.1 HWUSI-EAS753_0012:8:1:8338:1032 length=24
acaa^acc^ac[aacY^\`_cccc
但这就是输出给我的东西
Length of Sequence 196 different from Length of Quality Sequence
24 # this is the echo ${#sequence}
TGTAAACATCCTACACTCTCAGCT # this is the echo $Sequence
22 # this is the echo ${#Quality_sequence}
`__^\aa_Z_ccccacc[acYc #this is the echo $Quality_sequence
Length of Sequence 197 different from Length of Quality Sequence
24
TTTGGCAATGGTAGAACTCACACC
23
acaa^acc^ac[aacY^`_cccc
您可能已经注意到脚本会从输入中删除所有\,除了\\它被视为一个\。因此导致quality_sequence的长度发生变化。
再次感谢您的帮助
答案 0 :(得分:1)
您错过了-r
的{{1}}参数。你基本上总是想要它。它会阻止read
解释&#34;反斜杠转义序列。
有关如何正确按行/字段正确读取文件的讨论,请参阅http://mywiki.wooledge.org/BashFAQ/001(讨论read
)。