use strict;
use warnings;
my $dir = 'c:\seqs';
opendir(DIR,$dir)
or die "unable to open directory $dir:$!";
foreach my $file ( grep{/\.seq$/ && -f "$dir/$_"}readdir DIR)
{
my $output_path = "$dir/$file.seq";
my $input_path = "$dir/$file";
open (my $in, '<', $input_path) or
die "Unable to open $input_path: $!";
open (my $out, '>', $output_path) or
die "Unable to open $output_path: $!";
while (<$in>)
{
my $locus =~ /LOCUS\s*(\w+)/;
s/\^\^/>$locus\n^^\n/g;
print $out $_;
}
close ($in);
close ($out);
unlink ($input_path)
or die "unable to unlink $input_path: $!";
rename ($output_path, $input_path) or
die "Unable to rename $output_path to $input_path:$!";
}
####
while (<$in>) {
if $in =~ /^^/ { s/\^\^/\n^^/g;
print $out $_;
else { s/[a]|[c]|[t]|[g]{6}/^^\n }
####
while (<$in>)
{
my $locus =~ /LOCUS\s*(\w+)/;
s/\^\^/>$locus\n^^\n/g;
print $out $_;
}
####
Created: Tuesday, July 12, 2005 4:17 PM
LOCUS AJ877263 663 bp DNA linear INV 15-APR-2005