Fix this
#!/usr/bin/perl --
# consolidated.pl
# 2017-05-13-19:55:06
#
#
## perltidy -olq -csc -csci=10 -cscl="sub : BEGIN END if while for "
+-otr -opr -ce -nibc -i=4 -pt=0 "-nsak=*"
#!/usr/bin/perl --
use strict;
use warnings;
Main( @ARGV );
exit( 0 );
sub Main {
my $infile = "human_hg19_circRNAs_putative_spliced_sequence.fa";
my( $seq, $id ) = ReadHashSequences( $infile );
my( $min, $max ) = PromptMinMax();
SpecifySeqLengths( $seq, $min, $max );
}
sub ReadHashSequences {
my( $infile ) = @_;
use autodie qw/ open /;
open my( $fh ), '<', $infile;
my %seq = ();
my $id = '';
while( <$fh> ) {
chomp;
if( $_ =~ /^>(.+)/ ) {
$id = $1;
} else {
$seq{$id} .= $_;
}
}
close $fh;
return \%seq, $id;
} ## end sub ReadHashSequences
sub Prompt {
my( $msg, $default ) = @_;
...;
return $default;
}
sub PromptMinMax {
my( $def_min, $def_max ) = grep defined, @_, 0, 10;
my $min = Prompt( "Enter Max sequence length:", $def_min );
my $max = Prompt( "Enter Min sequence length:", $def_max );
return $min, $max;
}
sub SpecifySeqLengths {
my( $seq, $minlength, $maxlength ) = @_;
for my $id ( keys %$seq ) {
if( ( length $seq->{$id} <= $maxlength )
&& ( length $seq->{$id} >= $minlength ) )
{
PunchFile( "SeqLength_$minlength-$maxlength", $id, $seq->{
+$id} );
}
}
} ## end sub SpecifySeqLengths
sub PunchFile {
my( $newfile, $id, $val ) = @_;
if( -f $id ) {
print $id, " already exists. It is about to be overwritten\n";
}
use autodie qw/ open /;
open my( $newfh ), '>>', $newfile;
print $newfh $id, "\n", $val, "\n";
close $newfh;
} ## end sub PunchFile
__END__
$ perl consolidated.pl
Can't open 'human_hg19_circRNAs_putative_spliced_sequence.fa' for read
+ing: 'No such file or directory' at consolidated.p
l line 23