From 510c79b670474f4f899da5169d99acc2412c0a9b Mon Sep 17 00:00:00 2001 From: elserj Date: Tue, 21 Sep 2010 21:10:52 +0000 Subject: [PATCH] Modified to take input and output files as arguments (better for scripting) svn path=/; revision=41 --- interactome_scripts/fasta_header_fix.pl | 36 +++++++++++-------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/interactome_scripts/fasta_header_fix.pl b/interactome_scripts/fasta_header_fix.pl index eaaa1a8..f20fce6 100755 --- a/interactome_scripts/fasta_header_fix.pl +++ b/interactome_scripts/fasta_header_fix.pl @@ -7,29 +7,25 @@ require "$ENV{HOME}/scripts/jaiswallab/interactome_scripts/find_species.pl"; my @files; -if($#ARGV == 0) { - @files = $ARGV[0]; -}else{ - @files = glob("*.fa"); +if($#ARGV == 1) { + $input_file = $ARGV[0]; + $output_file = $ARGV[1]; } -foreach my $input_file (@files) { - open(in_file, $input_file) || die "Error: File $input_file can not be opened"; - my $output_file = $input_file . "_fixed.fa"; - open(out_file, ">$output_file"); +open(in_file, $input_file) || die "Error: File $input_file can not be opened"; +open(out_file, ">$output_file"); - my $species = find_species($input_file); +my $species = find_species($input_file); - while() { - my $line = $_; - chomp $line; - if ($line =~ /^>/) { - my $gene = find_gene($line,$species); - $line = ">" . "$gene"; - } - print out_file "$line\n"; +while() { + my $line = $_; + chomp $line; + if ($line =~ /^>/) { + my $gene = find_gene($line,$species); + $line = ">" . "$gene"; } - - close(in_file); - close(out_file); + print out_file "$line\n"; } + +close(in_file); +close(out_file);} -- 2.34.1