#!/usr/bin/perl -w

#Usage:
#	loadDNAfromFastaFile.pl {input fasta format file containing the sequence}

# Description:
#	reads a DNA sequence from an external file that stores the sequence in the fasta format
# 		and then outputs the sequence back to the standard output
#Assumption:
#	only one sequence present in the input fasta file

use strict;


if(!exists($ARGV[0])) {
	# means, user has forgot to pass the file name as an argument
	print "Usage: loadDNAfromFastaFile.pl {input fasta format file containing the sequence}\n";
	exit;
}

my $sequence = "";

print "Opening file " . $ARGV[0] . "\n";

#	the dot operator above concatenates the two flanking strings 
#	it is a nice way to incrementally build the strings

open(FP,$ARGV[0]);

# start a while loop to read the first sequence one line at a time
while(<FP>) {
	# the "$_" variable is a special variable that stores the current loaded line

	#First remove the trailing "\n" character from $_
	chomp;

	print "Line = $_\n";

	# check if the line starts with the ">" sign, if so it is the name of the sequence
	if(/^>/) {
		# anything between // will be treated as a regular expression

		print "Sequence name = $_\n";
	}
	else {
		$sequence = $sequence . "$_";
		# concatenate current line to the $sequence variable
	}
} # end of while loop
close(FP);

print "The sequence is $sequence\n";

exit;




