yueli711 has asked for the wisdom of the Perl Monks concerning the following question:
Hello, I have file here. I want to change file 1.fa to file 1.txt. Thanks in advance for great help! Best, yue
open(IN1, "1.fa") || die "Cannot open this file"; @lines = <IN1>; $i = 0; for (@lines) { $lines[$i]=~s/\nA/\tA//g; $lines[$i]=~s/\nT/\tT//g; $lines[$i]=~s/\nC/\tC//g; $lines[$i]=~s/\nG/\tG//g; $lines[$i]=~s/\nN/\tN//g; $thislines[$i]=$lines[$i]; print $thislines[$i]; $i++; } open(OUT, ">1.txt") || die "Cannot open this file"; for $thisline(@thislines){ print OUT $thisline;} close(OUT); close(IN1);
1.fa >1 AGTCGTAGCAT >2 TGAGCTACG >3 GGCATAGN >4 CGCACNCAGCTACACC >5 NGATAGCTACA
1.txt >1 AGTCGTAGCAT >2 TGAGCTACG >3 GGCATAGN >4 CGCACNCAGCTACACC >5 NGATAGCTACA
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: change \n to \t
by AnomalousMonk (Archbishop) on Aug 23, 2019 at 16:41 UTC | |
Re: change \n to \t
by hippo (Bishop) on Aug 23, 2019 at 15:28 UTC | |
by yueli711 (Sexton) on Aug 23, 2019 at 15:50 UTC | |
by Laurent_R (Canon) on Aug 23, 2019 at 16:06 UTC | |
Re: change \n to \t
by haukex (Archbishop) on Aug 24, 2019 at 09:12 UTC | |
Re: change \n to \t
by jwkrahn (Abbot) on Aug 23, 2019 at 18:35 UTC | |
Re: change \n to \t
by Marshall (Canon) on Aug 24, 2019 at 23:03 UTC |
Back to
Seekers of Perl Wisdom