Perl hash does not print value if it begins with 2 or 22 under certain conditions -
This is really disappointing to me. I am writing scripts that indexing indexing in a hash and then using those index numbers To remove values from the array.
The strange thing is that if the price starts with 2 or 22 then it will not be printed. Any other number works I will show you two variations and the script's output.
First variation This is the script that I want to do. Print the chromosome, position, value.
#! Use / usr / bin / perl strict; Use warnings; File :: Use Search; Use scalar :: Util qw (looks_like_number); IN open, "/home/big/scratch/affy_map.txt" or dead "can not open context \ n"; My% ref; My $ head = & lt; IN & gt; My $ index = 0; While (& lt; IN & gt;) {chomp $ _; My @ro = partition / \ t /, $ _; My $ value = "\ t", $ line [1], $ line [2]; If ($ line [1] == 2 & amp; amp; $ line [2] & lt; = 50000 & amp; amp; $ line [2] & lt; = 51113178) {$ ref {$ index} = $ Value; Print $ $. "\ T". $ Value "\ N";} If ($ line [1] == 22 & amp; amp; $ line [2] & lt; = 16300001 & quot; line [2] & lt; = 20500000) {$ ref {$ Index} = $ value; Print $ Index. "\ T". $ Value "\ N"; } $ Index ++; } draw close); My files; My $ masterdirect = "/ nfs / archive02 / big / norm / norm_gcc /"; Find (& amp; file_names, $ masterDirect); Sub file_names {if (-f & $ file :: search :: name = ~ / .nzd $ /) {push @files, $ file :: find :: name; }} My $ count = 0; Foreign (@file) {$ count ++; If ($ count% 100 == 0) {print "\ n", "-" x 10, "$ count", "-" x 10, "\ n";} undef my @probes; Open, $ _; #filename my @ indie = split "\ /", $ _; My $ id = pop (@indire); $ Id = ~ s / \. Gcc.nzd $ //; #header test $ head = & lt; IN & gt; If (looks_like_number ($ head)) {push @probes, $ head; } #Open Output Open OUt, "& gt; / Home / Large / Scratch / Phase 1_fi / D.A. Id." _ Select_probeset.txt "; #load inquiry array @probes = & lt; IN & gt;; close); forward my $ key (sort keys to% ref) {# indentanded function print out $ ref {$ of} } "$ T [$ key]; #testing my @temp = split" \ t ", $ ref {$ key}; Foreach (@temp) {if ($ temp [0] == 2) { Print $ key. "\ T". $ Ref {$ key}. "\ T". $ Check [$ key];}}} Close (outside);}
here Output has been given for the test. Printing from the reference file is flawless The first number $ key or index number is $ second to $ check Why $ {$ key} $ ref {$ key} is missing?
146529 0.777314368326637 146529 0.777314368326637 146530 0.116241153901913 146530 0.116241153901913 146531 0.940593233609167 146531 0.940593233609167
variation 2.
... foreign currency my $ key (sort key% ref) {print out $ ref {$ key}. "\ T." $ Check [ $ Key]; My @temp = partition "\ t", $ ref {$ key}; Foreach (@temp) {if ($ temp [0] == 2) {Print $ key. "\ T". $ Ref {$ key} "\ N";}}}
and its output see that it's printing correctly $ key and $ ref {$ key}
146542 2 31852 146542 2 31852 146543 2 37693 146543 2 37693 146544 2 40415 146544 2 40415 146545 2 40814 I thought it was a DOS-> UNIX file The problem may be, but I have done all the input for perl -pi -e 's / \ r / \ n / g' input_files.txt
the script sees this prints the same value twice Because there are two elements in the @temp array, I actually have a loss in fact I.
Here is an indication for the possible issue,
If ($ line [1] == 2 & amp; amp; $ line [2] & lt; = 50000 & amp; $ line [2] & lt; = 51113178) {$ ref {$ index} = $ value; Print $ $. "\ T". $ Value "\ N";}
Note that you used two "& lt; =" for the $ line [2], which looks awkward in the next line such as " Problem "is also please check it again, otherwise you can filter them in the first place.
Comments
Post a Comment