Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/local/bin/perl -w use strict; use Getopt::Long; use Tie::IxHash; my ($bpfile , $intfile, $out); my $usage = " USAGE: perl beadpool_int.pl -bpfile <file with snp,chr, +beadpoolid> -int <intensities file from b2i>\n"; GetOptions("bp=s" =>\$bpfile, "int=s" =>\$intfile, "out=s" =>\$out) || warn "Error $!\n"; if(!$bpfile) {die "\n$usage\n"}; my %beads; tie my %ints,"Tie::IxHash"; open BP, "<$bpfile" or die $!; open INT, "<$intfile" or die $!; open OUT, ">$out"or die $!; while (my $line= <BP>) { chomp $line; my @bp = split(/,/,$line); $beads{$bp[0]} = $bp[2]; } close BP; #my ($snp, @array) my @intensities; while (my $line = <INT>){ chomp $line; my $LABELS_REGEX =qr(^SNP\s+Coor); if ($line !~ $LABELS_REGEX) { my ($snp, $coor, $allele,@array) = split(/\t/,$line); $ints{$snp} = \@array; @intensities = @array; } } close INT; foreach my $snp(keys %ints) { foreach my $snpbs(keys %beads){ if($snp eq $snpbs){ my @ints; for(my $i = 0;$i<scalar(@intensities);$i++) { push @ints, $ints{$snp}[$i] ; } print OUT "$beads{$snpbs}\t$snp\t", join("\t",@ints), "\n"; } #print OUT "\n"; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: To make the comparison work faster
by Limbic~Region (Chancellor) on Dec 08, 2009 at 15:31 UTC | |
|
Re: To make the comparison work faster
by DStaal (Chaplain) on Dec 08, 2009 at 14:21 UTC |