Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Does the output exist in a hash or array?

by Riales (Hermit)
on Mar 19, 2012 at 17:11 UTC ( #960447=note: print w/ replies, xml ) Need Help??


in reply to Does the output exist in a hash or array?

I would maintain a hash of samples you have already seen. That way you could check that hash to see if you've already printed that sample before or not.

I'm a little uncertain though. Do you want only one result per sample? Or any unique sample/tab3/tab23 combination? The following assumes that you only want one result per sample...

my %seen; while (<BATCH>) { chomp; s/\r//; my $filename = $_; $out_name = $filename; $out_name =~ s/\.txt//; $out_dir_name = "apt_SNPCall_".$out_name; foreach my $lf (@list_files){ open (SAMPLE, "$out_dir_name/birdseed-v2.report.txt") || die "Erro +r to open: $!"; while (<SAMPLE>) { chomp; my @tab = split("\t", $_); if ($tab[0] eq $lf){ my $sample = $lf; $sample =~ s/\.CEL//; if (!exists $seen{$sample}) { print $sample."\t".$tab[2]."\t".$tab[22]."\n"; $seen{$sample} = 1; } } } } }


Comment on Re: Does the output exist in a hash or array?
Download Code
Replies are listed 'Best First'.
Re^2: Does the output exist in a hash or array?
by Light (Initiate) on Mar 20, 2012 at 09:57 UTC

    I only want the first result of the sample, so if the sample already exists in the output I guess, I want to skip that sample and go to the next line.

    Thanks for your help.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://960447]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (12)
As of 2015-07-30 21:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls