rna_follower has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to modify my file by using Regex to replcace/substitute strings/numbers:
Example fie:>Sample_1_x80
AGGGGGGGGGTTCCC
>Sample_2_x85
TTTCCCGGGAAAA
>sample_3_x112
GGCCCCTTTGAGG
And I want to modify it to print like so(ID line should be tab-delimited):>ID1 80
AGGGGGGGGGTTCCC
>ID2 85
TTTCCCGGGAAAA
and so on ....
My best effort:
#!usr/bin/perl $file; @files; $filename; $filename = <STDIN>; open(FILENAME, "<$filename") or die "can't open file"; while($file = <FILENAME>){ chomp $file; $file =~ s/sample\_\d\_x?/ID\t/; print $file, "\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: modifying a file with regex!
by tobyink (Canon) on Mar 16, 2012 at 21:51 UTC | |
by Marshall (Canon) on Mar 16, 2012 at 22:56 UTC | |
by tobyink (Canon) on Mar 16, 2012 at 23:44 UTC | |
by Marshall (Canon) on Mar 17, 2012 at 00:31 UTC | |
by Anonymous Monk on Mar 17, 2012 at 00:42 UTC | |
| |
Re: modifying a file with regex!
by JavaFan (Canon) on Mar 16, 2012 at 21:50 UTC | |
Re: modifying a file with regex!
by Anonymous Monk on Mar 16, 2012 at 22:11 UTC | |
Re: modifying a file with regex!
by Marshall (Canon) on Mar 16, 2012 at 22:19 UTC | |
by rna_follower (Initiate) on Mar 17, 2012 at 00:15 UTC | |
A reply falls below the community's threshold of quality. You may see it by logging in. |