所以我有一個程序,可以從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