Leser: 16
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my $line = "DIQMTQSPSSLSASVGDRVTITCXXXXXXXXXXXWYQQKPGKAPKXXXXXXXXXXXGVPSRFSGSGSGTDFTLTISSLQPEDFATYYCXXXXXXXXTFGQGTKVEIK"; my %str; $str{pos1} = substr($line, 0, 23); $str{pos2} = substr($line, 23, 11); $str{pos3} = substr($line, 34, 11); $str{pos4} = substr($line, 45, 11); $str{pos5} = substr($line, 56, 32); $str{pos6} = substr($line, 88, 8); $str{pos7} = substr($line, 96, 11); print Dumper(\%str);
1
2
3
4
5
6
7
8
9
$VAR1 = {
'pos1' => 'DIQMTQSPSSLSASVGDRVTITC',
'pos4' => 'XXXXXXXXXXX',
'pos7' => 'TFGQGTKVEIK',
'pos5' => 'GVPSRFSGSGSGTDFTLTISSLQPEDFATYYC',
'pos3' => 'WYQQKPGKAPK',
'pos2' => 'XXXXXXXXXXX',
'pos6' => 'XXXXXXXX'
};
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#!/usr/bin/perl use strict; use warnings; my $string = 'DIQMTQSPSSLSASVGDRVTITCXXXXXXXXXXXWYQQKPGKAPKXXXXXXXXXXXGVPSRFSGSGSGTDFTLTISSLQPEDFATYYCXXXXXXXXTFGQGTKVEIK'; my @parts = split /(X+)/, $string; my $cur_pos = 0; for my $part ( @parts ) { my $start = $cur_pos + 1; my $stop = $cur_pos + length $part; print "feature $start .. $stop: $part\n"; $cur_pos = $stop; }
1 2 3 4 5 6 7 8
my $line = "DIQMTQSPSSLSASVGDRVTITCXXXXXXXXXXXWYQQKPGKAPKXXXXXXXXXXXGVPSRFSGSGSGTDFTLTISSLQPEDFATYYCXXXXXXXXTFGQGTKVEIK"; my $pos=0; while(my $pos_in=index($line,'XXXXXXXXXXX',$pos)>-1) { print "feature $pos..$pos_in\n"; $pos=$pos_in+11; } print "feature $pos..".length($line)."\n" if($pos<length($line));