Hello All,
I just want help to open and read a file. I have to make a script so that it
should open and read a file which is in fasta format. I have done something
with subroutine but getting some errors. May be everyone do not know the
fasta format....
Fasta format have peculiar feature: its starts with symbol " > " and
contains alpabets and numbers. So acc to that code have been given...
Can anyone please check the code n lemme know changes please!!!
Thanks...
#!/usr/bin/perl -w
use strict;
use CGI;
use CGI::Carp qw ( fatalsToBrowser );
use File::Basename;
use Bio::SeqIO;
my $q = new CGI;
my $filename = $q->param("file");
my $line;
&get_file_data($filename);
###############################################################################################################################
#subroutine to read fasta files.
sub get_file_data {
my @filename=();
my $line='';
my $j=0;
my($filename) = @_;
open(get_file_data, $filename);
foreach my $line (@_) {
chomp $line;
$line =~ s/[\s0-9]//g;
next;
# check blank line
if ($line =~ /^\s*$/) {
next;
}
# check comment line
else
{
$line =~ /^\s*#/ ;
next;
}
# check fasta header line
if($line =~ /^>/) {
next; }
else {
print STDERR "Cannot open file \"$filename\n\n";
exit;
}
close get_file_data;
}
return @_;
}
#############################################################################################################
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/