怎么用perl 提取文本中的数字
RLTmr1I001CACTCAGAGTACACCCCCAGGAGCCGCGGAGAGCTGCGGGACGGTACCTACACGCCGCACE012CAACCTTGAAA...
RLTmr1
I001CACTCAGAGTACACCCCCAGGAGCCGCGGAGAGCTGCGGGACGGTACCTACACGCCGCAC
E012CAACCTTGAAAGTGACGGTATCTACATCATCAACCTGAAGAGGACTTGGGAGAAGCTGTTGTTAGCC
I001 300 TATACCGACGGAAGAGACACG 320 605
E012 30 TCTACAAAAGGAAAAGTGACG 50 100
21 42
Rps2
I001CACTCAGACACAATGACCCGAGACTAGAACGCCGGACCCGACACCCTTAGGCACCTGTAGGCCTGCCTGTGTC
E012GCCGCGGTCGAGGCCGCGGGGCTCAGTCTGAGATTATTGACTTTTTCCTGGGTGCATCTCTAAAGGATGAAGT
I001 78 CCGTCGAGGCGCCTGGG 94 135
E012 5 CGGTCGAGGCCGCGGGG 21 100
17 49
I002CATCCACACCCGGCGACCGCCTCGCCCGACGAGTGGGAGACGTGCCTCTACGTCGGGAAACTGACTAGAGAAGGAAGTC
E034TCATGCCAGTGCAGAAGCAGACTCGCGCTATTGGGGACTACAATGGCCACGTTGGTCTTGGTGTTAA
I002 57 GAAACTGACTAGAGAAGG 74 80
E034 14 GAAGCAGACTCGGGCTGG 31 100
18 36
提取上面序列中的数字,
1 提取以E开头数字,比如E012后的 30 50 100
2 批量处理后结果为:
30 50 100
5 21 100
14 31 100 展开
I001CACTCAGAGTACACCCCCAGGAGCCGCGGAGAGCTGCGGGACGGTACCTACACGCCGCAC
E012CAACCTTGAAAGTGACGGTATCTACATCATCAACCTGAAGAGGACTTGGGAGAAGCTGTTGTTAGCC
I001 300 TATACCGACGGAAGAGACACG 320 605
E012 30 TCTACAAAAGGAAAAGTGACG 50 100
21 42
Rps2
I001CACTCAGACACAATGACCCGAGACTAGAACGCCGGACCCGACACCCTTAGGCACCTGTAGGCCTGCCTGTGTC
E012GCCGCGGTCGAGGCCGCGGGGCTCAGTCTGAGATTATTGACTTTTTCCTGGGTGCATCTCTAAAGGATGAAGT
I001 78 CCGTCGAGGCGCCTGGG 94 135
E012 5 CGGTCGAGGCCGCGGGG 21 100
17 49
I002CATCCACACCCGGCGACCGCCTCGCCCGACGAGTGGGAGACGTGCCTCTACGTCGGGAAACTGACTAGAGAAGGAAGTC
E034TCATGCCAGTGCAGAAGCAGACTCGCGCTATTGGGGACTACAATGGCCACGTTGGTCTTGGTGTTAA
I002 57 GAAACTGACTAGAGAAGG 74 80
E034 14 GAAGCAGACTCGGGCTGG 31 100
18 36
提取上面序列中的数字,
1 提取以E开头数字,比如E012后的 30 50 100
2 批量处理后结果为:
30 50 100
5 21 100
14 31 100 展开
展开全部
#!/usr/bin/perl
use strict;
use Data::Dumper;
my $str = "RLTmr1
I001CACTCAGAGTACACCCCCAGGAGCCGCGGAGAGCTGCGGGACGGTACCTACACGCCGCAC
E012CAACCTTGAAAGTGACGGTATCTACATCATCAACCTGAAGAGGACTTGGGAGAAGCTGTTGTTAGCC
I001 300 TATACCGACGGAAGAGACACG 320 605
E012 30 TCTACAAAAGGAAAAGTGACG 50 100
21 42
Rps2
I001CACTCAGACACAATGACCCGAGACTAGAACGCCGGACCCGACACCCTTAGGCACCTGTAGGCCTGCCTGTGTC
E012GCCGCGGTCGAGGCCGCGGGGCTCAGTCTGAGATTATTGACTTTTTCCTGGGTGCATCTCTAAAGGATGAAGT
I001 78 CCGTCGAGGCGCCTGGG 94 135
E012 5 CGGTCGAGGCCGCGGGG 21 100
17 49
I002CATCCACACCCGGCGACCGCCTCGCCCGACGAGTGGGAGACGTGCCTCTACGTCGGGAAACTGACTAGAGAAGGAAGTC
E034TCATGCCAGTGCAGAAGCAGACTCGCGCTATTGGGGACTACAATGGCCACGTTGGTCTTGGTGTTAA
I002 57 GAAACTGACTAGAGAAGG 74 80
E034 14 GAAGCAGACTCGGGCTGG 31 100
18 36";
my @line = grep {if ($_ =~ /^E\d+(.*)/){$_ = $1;if ($1=~ /\d+/) {$_ =~ s/\D+/ /g;$_ =~ s/\s+/ /g;}}} split /\n/,$str;
print Dumper @line;
use strict;
use Data::Dumper;
my $str = "RLTmr1
I001CACTCAGAGTACACCCCCAGGAGCCGCGGAGAGCTGCGGGACGGTACCTACACGCCGCAC
E012CAACCTTGAAAGTGACGGTATCTACATCATCAACCTGAAGAGGACTTGGGAGAAGCTGTTGTTAGCC
I001 300 TATACCGACGGAAGAGACACG 320 605
E012 30 TCTACAAAAGGAAAAGTGACG 50 100
21 42
Rps2
I001CACTCAGACACAATGACCCGAGACTAGAACGCCGGACCCGACACCCTTAGGCACCTGTAGGCCTGCCTGTGTC
E012GCCGCGGTCGAGGCCGCGGGGCTCAGTCTGAGATTATTGACTTTTTCCTGGGTGCATCTCTAAAGGATGAAGT
I001 78 CCGTCGAGGCGCCTGGG 94 135
E012 5 CGGTCGAGGCCGCGGGG 21 100
17 49
I002CATCCACACCCGGCGACCGCCTCGCCCGACGAGTGGGAGACGTGCCTCTACGTCGGGAAACTGACTAGAGAAGGAAGTC
E034TCATGCCAGTGCAGAAGCAGACTCGCGCTATTGGGGACTACAATGGCCACGTTGGTCTTGGTGTTAA
I002 57 GAAACTGACTAGAGAAGG 74 80
E034 14 GAAGCAGACTCGGGCTGG 31 100
18 36";
my @line = grep {if ($_ =~ /^E\d+(.*)/){$_ = $1;if ($1=~ /\d+/) {$_ =~ s/\D+/ /g;$_ =~ s/\s+/ /g;}}} split /\n/,$str;
print Dumper @line;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询