in reply to Uninitialized Value Hash Lookup Gene Symbol
By the way, understand that "uninitialized" is a warning, not an error. Because you have use warnings; in your script (which is good), you are learning about things that are simply not going as expected; the script continues to run, and empty strings are being printed where you might be expecting non-empty strings. Given that this is the case, try to figure out where your expectations are not being met.
Here's a modified version of the OP script, reformatted to be more compact (and "more perlish") - note how I'm adding some lines to check for unexpected conditions, and report them:
Also, I added "use strict", and re-arranged things so that declarations of variables are placed closer to where the variables are actually used.#!/usr/bin/perl use strict; use warnings; use diagnostics; my %geneSymbolConversion; my $input1 = '/scratch/Drosophila/fb_synonym_fb_2014_05.tsv'; open(INF1,"<", $input1 ) or die "$input1: $!\n"; while (<INF1>){ chomp; if ( /^FBgn\d+/ ) { my @fields = split "\t"; $geneSymbolConversion{ $fields[0] } = $fields[1]; } } warn sprintf( "loaded %d gene symbols from %s\n", scalar keys %geneSym +bolConversion, $input1 ); my $input2 = '/scratch/Drosophila/FlyRNAi_data_baseline_vs_EGF.txt'; open(INF2,"<", $input2) or die "$input2: $!\n"; open(OUTF1,">",'FLYRNAi_data_baseline_vs_EGFSymbol.txt') or die $!; while (<INF2>) { chomp; my ($geneID, $EGF_Base, $EGF_Stimulus) = split "\t"; if ( $geneID and $EGF_Base and $EGF_Stimulus ) { my $geneSymbol = $geneSymbolConversion{$geneID} || 'NA'; print OUTF1 join("\t", $geneID, $geneSymbol, $EGF_Base, $EGF_S +timulus), "\n"; } else { warn "$input2: line $.: incomplete data: $_\n"; } }
(UPDATE: I added a bit more to report how many gene symbols were loaded from the first input, just in case that's informative.)
|
|---|