I'm writing a perl script that takes the numerical data from the second column of a 5 column data set and then uses the numbers in that column to extract the characters at those particular positions. For example:
The first data set consists of:
1 2 A G 0.5
1 4 G A 0.8
1 6 T C 0.9
The second consists of:
ATCGATCGTCG
The desired result is this data set (the characters at positions 2, 4, and 6 as shown by the second column of the first data set):
T
G
T
This is my script as of now:
#!/usr/bin/perl
my @array;
open(my $FH, 'file/location') or die "$!";
while(<$FH>){
push @array, (split(/\t/))[1];
open(my $file, 'file/location') or die "$!";
}
$protein = substr($file, $array-1, $array-1);
print "$protein";
How can I edit this to fit my requirements?
The first data set consists of:
1 2 A G 0.5
1 4 G A 0.8
1 6 T C 0.9
The second consists of:
ATCGATCGTCG
The desired result is this data set (the characters at positions 2, 4, and 6 as shown by the second column of the first data set):
T
G
T
This is my script as of now:
#!/usr/bin/perl
my @array;
open(my $FH, 'file/location') or die "$!";
while(<$FH>){
push @array, (split(/\t/))[1];
open(my $file, 'file/location') or die "$!";
}
$protein = substr($file, $array-1, $array-1);
print "$protein";
How can I edit this to fit my requirements?