thanks a lot! i wrote this code in an attempt of reading and working with all the files in a directory but it doesnt work... yet if i specify the path of one file i get results
im still a perl beginner so don´t laugh at my code ^^
thanks!
print "Enter a directory´s path to work with all files in a folder or
+a single file path\n\n";
chomp(my $input =<STDIN>);
if ($input =~ /./){ ### attempt of recognizing a file extention
$datei = $input;
open(my $fastd,'<', $datei) or die "die datei $datei wurde nicht g
+eöffnet: $!\n";
while (my $line = <$fastd>) { #reading fasta file
chomp $line;
if ($line =~ /^>/) {
$header = $line;
$header =~ s/>//g;
}
else {
$sequences->{$header} .= $line
}
}
}elsif($input =~ /[^.]/){ #### attempt of recognizing just a folder b
+ut i know it wont work always
$path = $input;
opendir my $DIR, $path or die " the directory couldn't be opened\n
+";
my @folder = grep -f "$path/$_", readdir $DIR;
for my $file (@folder){
open (my $fastd ,'<', "$path/$file") or die "the file $file co
+uldn't be opened: $!\n";
while (my $line = <$fastd>) { #reading fasta file
chomp $line;
if ($line =~ /^>/) {
$header = $line;
$header =~ s/>//g;
}
else {
$sequences->{$header} .= $line
}
}
}
}