#!/usr/bin/perl -w
use strict;

my $usage = "Usage: $0 <chromosome-fasta-file> <start> <stop>\n";
my $genomeFile = $ARGV[0] or die $usage;
my $start = $ARGV[1] or die $usage;
my $stop = $ARGV[2] or die $usage;

my $defline;
my $sequence;
open(GF,$genomeFile) or die "Could not open genome file: $genomeFile\n";
while(<GF>) {
    chomp; # remove new line
    if(/>/) {
	## if it is a defline, store it.
	$defline = $_;
    } else {
	## otherwise, append the sequence.
	$sequence .= $_
    }    
}
# now the the genome is stored as "$sequence", print the substring.
print "$defline:$start..$stop\n";
print substr($sequence,$start,$stop-$start+1), "\n";
