У меня есть массив, который содержит некоторые последовательности ДНК как строки, хранящиеся в его элементах.
Пример: print $array[0];
вывести такой вывод: ACTAG
(# первая позиция в каждой последовательности).Индексирование значений строковых элементов из массива perl
Я написал этот код, который позволяет мне анализировать первую позицию для каждой последовательности.
#!/usr/bin/perl
$infile = @ARGV[0];
$ws= $ARGV[1];
$wsnumber= $ARGV[2];
open INFILE, $infile or die "Can't open $infile: $!"; # This opens file, but if file isn't there it mentions this will not open
my $sequence =(); # This sequence variable stores the sequences from the .fasta file
my $line; # This reads the input file one-line-at-a-time
while ($line = <INFILE>) {
chomp $line;
if ($ws ne "--ws=") {
print "no flag or invalid flag\n";
last;
}
else {
if($line =~ /^\s*$/) { # This finds lines with whitespaces from the beginning to the ending of the sequence. Removes blank line.
next;
} elsif($line =~ /^\s*#/) { # This finds lines with spaces before the hash character. Removes .fasta comment
next;
} elsif($line =~ /^>/) { # This finds lines with the '>' symbol at beginning of label. Removes .fasta label
next;
} else {
$sequence = $line;
$sequence =~ s/\s//g; # Whitespace characters are removed
@array = split //,$sequence;
$seqlength = length($sequence);}
}
$count=0;
foreach ($array[0]){
if($array[0] !~ m/A|T|C|G/){
next;
}
else {
$count += 1;
$suma += $count;
}
}
}
Но я не знаю, как изменить $ массива [0] для выполнения этого кода для каждой позиции (я только успел сделать это для конкретного постиона (в приведенном выше примере для первой позиции .?)
Может кто-то помочь мне Спасибо
** ВСЕГДА ** 'использовать строгий; используйте предупреждения; ' – Toto