#!/usr/bin/perl -w
#  Read file containing a sequence in FASTA
#  format, and store the entire sequence as one string.

#  The FASTA format contains the sequence name and description on the first
#  line, and the sequence itself in subsequent lines.

#  In this program, the user is asked to enter the file name containing the
#  sequence.

# declare all variables
my ($seq_file, $seq_name, $sequence, $seq_length);
my ($line);

# receive file name from user
print "please enter file name or path: ";
$seq_file = <STDIN>;
chomp ($seq_file);

# open file for reading
open (SEQ, $seq_file) || die "cannot open \"$seq_file\": $!";

# read sequence name and description from first line
$seq_name = <SEQ>;
chomp ($seq_name);

# initialize a variable to contain the entire sequence
$sequence = "";

# read sequence lines from file
while ($line = <SEQ>) {
   chomp ($line);
   $sequence .= $line;     #add line to $sequence
}

# close file
close (SEQ);

# print sequence length on the screen, for validation
$seq_length = length ($sequence);
print "Sequence length: $seq_length\n";







