所以我有一个程序,可以从fasta文件中复制和粘贴多余的换行符。如果你不知道fasta文件应该是什么样子,它应该是一个比符号更大的符号,然后是任何东西(这通常是标题信息),然后是新行。新的行应包含完整的序列(用于生物DNA或氨基酸),并重复。处理单行回车作为行尾符号
无论如何,问题是我需要的程序要足够灵活来处理任何事情:\r
,\n
或\r\n
。在任何一侧带有下划线的chomp
语句都是删除序列部分中多余行的命令。我该如何使这个chomp摆脱所有三个选项(\r
,\n
,\r\n
)?我可以设置并且有@linefeeds = "\r", "\n", "\r\n";
?
我已经在网上阅读过,我知道这个话题已经被覆盖过,但我似乎无法让它工作。
这里是我的代码在一个文件中这样做:
print "Please enter file name, using the full pathway, to save your cleaned fasta file to:\n";
chomp($new_file = <STDIN>);
open(New_File, "+>$new_file") or die "Couldn't create file. Check permissions on location.\n";
#process the file line by line, chomping all lines that do not contain "greater than" and
#removing all white space from lines that do not contain "greater than"
my $firstline = 1;
while (my $lines = <FASTA>) {
foreach ($lines) {
if (!/>/) {
_chomp($lines);_
$lines =~ s/ //g;
print New_File "$lines";
} else {
if ($firstline == 1) {
print New_File "$lines";
$firstline = 0;
} else {
print New_File "\n$lines";
next;
}
}
}
}
评论的问题是1)它实际上是全部一行(在第二个#之前没有LF)和2)它没有缩进4个空格。 – cjm 2010-12-18 09:01:48