#!/usr/bin/perl
use strict;
use warnings;
use Term::ANSIColor;
my $file = $ARGV[0];
if (@ARGV < 1){
print STDERR "Usage: $0 input_fasta_file\n";
exit 1;
}
my ($header, $sequence);
open (A, "<", $file) or die "Check the file: $!";
while (my $line = ){
chomp $line;
if ($line =~ /^(>.*)/){
$header = $1;
}
else{
$sequence .= $line;
}
}
close (A);
$sequence =~s/[\n\s]//;
#print "$sequence\n";
=comment
my @highlights = (
[ 88, 1, 'bold red' ],
[ 101, 1, 'bold red' ],
[ 113, 1, 'bold red' ],
[ 121, 1, 'bold red' ],
[ 124, 1, 'bold red' ],
[ 134, 1, 'bold red' ],
[ 140, 1, 'bold red' ],
[ 146, 1, 'bold red' ],
);
=cut
my @highlights;
my $pos_file = "sorted_position_walk.txt";
open (A, "<", $pos_file) or die "Check the file: $!";
while (my $line = ){
chomp $line;
my $pos = (split /\t/,$line)[0];
# push(@position, $pos);
push(@highlights, "([ $pos, 1, 'bold yellow' ],)");
}
#foreach my $pp(@highlights){
# print "[ $pp, 1, 'bold red' ],\n";
#}
#print "@highlights\n";
for my $ar (@highlights) {
my ($start, $len, $color) = @$ar;
$sequence = substr($sequence, 0, $start-1) # first part
. colored(substr($sequence,$start,$len), $color) # colored part
. substr($sequence,$start+$len); # final part
}
print $sequence, "\n";