Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Matching strings from three files (three hashes)

by murugu (Curate)
on Aug 17, 2010 at 05:33 UTC ( #855397=note: print w/ replies, xml ) Need Help??


in reply to Matching strings from three files (three hashes)

FluffyBunny,

I think you are populating bwa hash with different values and you are comparing different values of bwa has with 0. As others suggested, use debugger or Dumper module to know what is in the populated hash.

I have tweaked in some of your code. Check out whether is this what you need. I am not able to understand your requirement correctly. You can modify the below code according to your requirement.

#!/usr/bin/perl -w use warnings; use strict; use Data::Dumper; # BWA alignment output (.sam) my %bwa = (); my $file1 = shift; open (FILE1, "$file1") || die "Failed to open $file1 for reading : $!" +; # Open second file while (<FILE1>) { # Reading second hash if ($_ =~ /^[^@]/s) { chomp; my @line = split /\s+/, $_; my $ID; if ($line[2] =~ /[^*]/) { $ID = $line[0]; push @{$bwa{$ID}}, @line[2,5,12,15,16,17,18]; } } } close FILE1 || die "Failed to close $file1 : $!"; # ORIGINAL Reference Amplicon File (.fa) my %Amp = (); my $file2 = shift; open (FILE2, "$file2")|| die "Failed to open $file2 for reading : $!"; + # Open first file local $/= ">"; my $first=<FILE2>; while (<FILE2>) { # Reading first hash chomp; my ($ID, $Seq) = split("\n"); $Amp{$ID} = $Seq } close FILE2 || die "Failed to close $file2 : $!"; # ORIGINAL Input FASTQ Sequencing File (.fq) my %Input = (); my $file3 = shift; open (FILE3, "$file3")|| die "Failed to open $file3 for reading : $!"; + # Open first file local $/= "@"; $first=<FILE3>; while (<FILE3>) { # Reading first hash chomp; my ($ID, $Seq,undef,undef) = split("\n"); $Input{$ID} = $Seq; } close FILE3 || die "Failed to close $file3 : $!"; foreach my $ID (keys %bwa) { if (exists $Input{$ID}){ print "Key : $ID\t AMP:\t$Amp{$bwa{$ID}[0]}\nInput\t$Input +{$ID}" if (exists $Amp{$bwa{$ID}[0]}); } }

Regards,
Murugesan Kandasamy
use perl for(;;);


Comment on Re: Matching strings from three files (three hashes)
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (14)
As of 2014-08-22 19:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (163 votes), past polls