CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
hash of hashes disappears

 

First page Previous page 1 2 Next page Last page  View All


efoss
Novice

May 31, 2009, 7:14 PM

Post #1 of 31 (5370 views)
hash of hashes disappears Can't Post

In one block of code I fill up a variable, which happens to be a hash of hashes of hashes .... In the next block of code, I go to use it. The variable has disappeared. The variable is a hash called "%type_normalName_parent1_parent2_index_measured". As I fill it up, I print it out to make sure everything is going as I think:

$type_normalName_parent1_parent2_index_measured{$type}{$normalName}{$parent1}{$parent2}{$index} = 1;
print "$type\t$normalName\t$parent1\t$parent2\t$index\t$type_normalName_parent1_parent2_index_measured{$type}{$normalName}{$parent1}{$parent2}{$index}\n";

It prints out just fine. If I put a block (to stop execution in a debugger) anywhere in that block of code, I see the variable and everything looks normal. However, if I put that block just outside of the block of code where I fill the variable, there is no more variable. It's just gone. Any ideas for what's going on? I've attached the code, for what it's worth (which I expect is nothing).

Thanks.

Eric
Attachments: multiple_splits_CC_053109_3.pl (6.79 KB)


KevinR
Veteran


May 31, 2009, 11:04 PM

Post #2 of 31 (5366 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

Can you be more specifc about where the problem is in that code you posted?

Declaring all your variables as global variables is not the way to write good code. Variables should be scoped to just the section of code they are used in.
-------------------------------------------------


efoss
Novice

Jul 21, 2009, 10:27 PM

Post #3 of 31 (5229 views)
Re: [KevinR] hash of hashes disappears [In reply to] Can't Post


In Reply To
Can you be more specifc about where the problem is in that code you posted?

Declaring all your variables as global variables is not the way to write good code. Variables should be scoped to just the section of code they are used in.


Sorry for the very late response to this.

I almost always declare all of my variables globally because I feel like it minimizes the chance of my making mistakes. Perhaps I should rethink that philosophy, but I'm quite sure that it's not what is causing me problems.

I just ran in to this same problem again in an entirely unrelated script. Here I'm making a hash of hashes (not sure if that's relevant to this or if it could happen with just any variable) and it disappears. This time I've put a debugger "block" in outside of the block of code where I filled the variable and everything is still fine - the variable is there and filled as I had intended. Then I start stepping through the code in the debugger and at one completely innocuous step (opening a file or writing something to a file), my stored variable just disappears. It's not that it empties out and is filled with nothing - it's just gone. It's not even there in the debugger. And when I run the script from a terminal, I get the same result. It seems to me that this has to be a problem with the interpreter. I don't see what else it could possibly be, although I'm certainly aware that mistakes generally lie with the person writing the code rather than some widely distributed tool. (I'm using the perl that came on my Mac OS X Leopard.)

I have attached all of my code, though I don't expect that this will help anyone. Really the question is: How can a variable disappear when you click one step through on your debugger and that step has absolutely nothing to do with the variable that disappears?


(This post was edited by efoss on Jul 21, 2009, 10:36 PM)
Attachments: clique_maps_072109_1.pl (8.63 KB)


FishMonger
Veteran / Moderator

Jul 22, 2009, 5:32 AM

Post #4 of 31 (5220 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

How do you expect anyone to help you troubleshoot why the variable "disappears" when you don't tell us which variable or in which part of the script it "disappears"?

There are a number of problems in your code that I can point out which are unrelated to your question, but I'll leave those alone for now.


efoss
Novice

Jul 22, 2009, 9:37 AM

Post #5 of 31 (5213 views)
Re: [FishMonger] hash of hashes disappears [In reply to] Can't Post


In Reply To
How do you expect anyone to help you troubleshoot why the variable "disappears" when you don't tell us which variable or in which part of the script it "disappears"?

There are a number of problems in your code that I can point out which are unrelated to your question, but I'll leave those alone for now.


Sorry about that. Here is a specific example with this code:

I put a block in the debugger at this line:

open (OUTPUT2, ">cliques_mapped_bin_counts_072109_1.xls");

The variable called "%type_normalName_cutoff_chromosomes" is there, it's filled correctly, etc.

I step through to the next line, which is this:

print OUTPUT1 "type_of_measurement\tclique\tcutoff_percent\tchromosome\tposition\tgenomic_position\t$binSize"."_bin\thighest_position\thighest_bin_number_starting_with_bin_number_1\n";


Now the variable called "%type_normalName_cutoff_chromosomes" is gone.

This isn't the only instance where this happens - if I continue stepping through the code, another one disappears. So I'd love to get an answer to this.

I'd also appreciate hearing your other criticisms of my code. I'm self taught and write this code for work in a laboratory where none of my colleagues know anything about programming. (They're bench scientists, which is what I was before I taught myself some programming.) I'm sure there are all sorts of ways that my coding practices can be improved and I'd very much appreciate hearing about them.

Thanks.

Eric


FishMonger
Veteran / Moderator

Jul 22, 2009, 10:06 AM

Post #6 of 31 (5209 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post


Quote
The variable called "%type_normalName_cutoff_chromosomes" is there, it's filled correctly, etc.


It's not in the code you posted.

Where do you expect it to be and where is it getting filled?

If it was in your code at some point and is now gone, then you need to ask yourself or your co-workers "who edited the script, and when?".


efoss
Novice

Jul 22, 2009, 10:47 AM

Post #7 of 31 (5205 views)
Re: [FishMonger] hash of hashes disappears [In reply to] Can't Post


In Reply To

Quote
The variable called "%type_normalName_cutoff_chromosomes" is there, it's filled correctly, etc.


It's not in the code you posted.

Where do you expect it to be and where is it getting filled?

If it was in your code at some point and is now gone, then you need to ask yourself or your co-workers "who edited the script, and when?".


It's in the code I posted and I'm filling it with this line:

push (@{ $type_normalName_cutoff_chromosomes{$type}{$normalName}{$cutoff} }, $chromosome);


FishMonger
Veteran / Moderator

Jul 22, 2009, 10:55 AM

Post #8 of 31 (5204 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

No, it's NOT in the code you posted. In fact the code you posted doesn't even have the word chromosome as part of any variable.

Did you look at the code you posted?

The obvious answer is that you have multiple versions of the script and you're getting them confused.


efoss
Novice

Jul 22, 2009, 11:02 AM

Post #9 of 31 (5202 views)
Re: [FishMonger] hash of hashes disappears [In reply to] Can't Post


In Reply To
No, it's NOT in the code you posted. In fact the code you posted doesn't even have the word chromosome as part of any variable.

Did you look at the code you posted?

The obvious answer is that you have multiple versions of the script and you're getting them confused.


I see the source of confusion (I think). I posted code yesterday with my question yesterday, and it is in that code. It is not in the code I posted in my original post.


FishMonger
Veteran / Moderator

Jul 22, 2009, 11:10 AM

Post #10 of 31 (5198 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

Ah, I see now.

That's exemplifies the reason for needing to post a new question rather than adding it onto an unrelated question.


FishMonger
Veteran / Moderator

Jul 22, 2009, 12:37 PM

Post #11 of 31 (5192 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

So, %type_normalName_cutoff_chromosomes is being loaded on line 137 and the next time it's accessed is on line 194 and finally on line 195.

The print statement you referenced is on line 226.

Are you saying that when line 194 is executed, the hash is no longer assigned?

Have you tried using Data::Dumper to see what it holds and its structure at each point?


KevinR
Veteran


Jul 22, 2009, 12:39 PM

Post #12 of 31 (5191 views)
Re: [FishMonger] hash of hashes disappears [In reply to] Can't Post


In Reply To
Ah, I see now.

That's exemplifies the reason for needing to post a new question rather than adding it onto an unrelated question.


Its just old age creeping up on you Fish Unsure

I looked over the code and can't see why the hash would be there, then not be there. Then again, I'm getting old too. Mad
-------------------------------------------------


efoss
Novice

Jul 22, 2009, 12:46 PM

Post #13 of 31 (5188 views)
Re: [FishMonger] hash of hashes disappears [In reply to] Can't Post


In Reply To
So, %type_normalName_cutoff_chromosomes is being loaded on line 137 and the next time it's accessed is on line 194 and finally on line 195.

The print statement you referenced is on line 226.

Are you saying that when line 194 is executed, the hash is no longer assigned?

Have you tried using Data::Dumper to see what it holds and its structure at each point?


No. When line 194 is executed, the hash is still there and everything is fine. When I block in my debugger before line 224 is executed, the hash is still there and everything is fine. Then when I execute line 224 (just stepping to the next line, which is line 226, and not yet executing that one), then the hash has vanished into thin air.


FishMonger
Veteran / Moderator

Jul 22, 2009, 12:49 PM

Post #14 of 31 (5188 views)
Re: [KevinR] hash of hashes disappears [In reply to] Can't Post

Old age is not creeping up on me, it caught me awhile ago. Unsure

I think the problem is related to the overuse of global vars and some of them are getting clobbered.


FishMonger
Veteran / Moderator

Jul 22, 2009, 1:00 PM

Post #15 of 31 (5186 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

Add this near the top.

Code
use Data::Dumper;


Add this at line 228.

Code
print Dumper \%type_normalName_cutoff_chromosomes;



FishMonger
Veteran / Moderator

Jul 22, 2009, 1:04 PM

Post #16 of 31 (5184 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

Since the var is never used beyond line 195, why are you concerned about its status when you get to line 226.

I suspect that part of the problem may be your misunderstanding of the debugger.


efoss
Novice

Jul 22, 2009, 1:11 PM

Post #17 of 31 (5182 views)
Re: [FishMonger] hash of hashes disappears [In reply to] Can't Post


In Reply To
Add this near the top.

Code
use Data::Dumper;


Add this at line 228.

Code
print Dumper \%type_normalName_cutoff_chromosomes;



Did that. It prints out my variable in the output - and the variable looks good. I don't know what that's telling me, though.


efoss
Novice

Jul 22, 2009, 1:15 PM

Post #18 of 31 (5181 views)
Re: [FishMonger] hash of hashes disappears [In reply to] Can't Post


In Reply To
Since the var is never used beyond line 195, why are you concerned about its status when you get to line 226.

I suspect that part of the problem may be your misunderstanding of the debugger.


I'm concerned because if the variable doesn't exist, I'll never get past this statement, which is after line 226:

if ($type_clique_cutoff_chromosomes{$type}{$clique}{$cutoff}) {

This is not an issue of my not understanding my debugger. For example, I usually run my programs from a terminal while I'm writing them in the debugger, and I get the same result that way (i.e. I'll end up with output files that have a header line and then nothing else, which is a consequence of not getting into the "if" statement above).


FishMonger
Veteran / Moderator

Jul 22, 2009, 1:52 PM

Post #19 of 31 (5180 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post


In Reply To

In Reply To
Add this near the top.

Code
use Data::Dumper;


Add this at line 228.

Code
print Dumper \%type_normalName_cutoff_chromosomes;



Did that. It prints out my variable in the output - and the variable looks good. I don't know what that's telling me, though.


That's telling you that the variable exists and is fully populated at and after the point in the script that concerns you.


FishMonger
Veteran / Moderator

Jul 22, 2009, 1:58 PM

Post #20 of 31 (5177 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

Can you post the console output of the debug session and indicate how you determined that the var "disappears"?


efoss
Novice

Jul 22, 2009, 2:06 PM

Post #21 of 31 (5175 views)
Re: [FishMonger] hash of hashes disappears [In reply to] Can't Post


In Reply To
Can you post the console output of the debug session and indicate how you determined that the var "disappears"?


I'll paste the console output below. I determined that the variable disappeared because:

1. If I just look at the variable in my debugger, it is initially there, filled correctly (as it is in the output below) and then I execute one line that's unrelated to the variable and it's then gone.

2. I never get into the "if" statement mentioned above. I have the "if" statement there because only some combinations of "types", "cliques" and "cutoffs" will have "chromosomes" associated with them, and it's only those where there will be things to print out to my output file.

3. As expected if the variable disappears, I don't print anything to my output file other than the first line.

As I mentioned above, this happens to another variable too. It doesn't disappear at the same line, but it does disappear a little later. I think this must be a problem with the interpreter. I'll try to run it on a different machine.

Here's the console output:

the length of the entire genome is 12070811
the highest bin number is 604
type_of_measurement normal_name chromosome position
type_of_measurement normal_name chromosome position
type_of_measurement normal_name chromosome position
type_of_measurement normal_name chromosome position
complete_graphs_proteins_070309_3.txt
complete_graphs_transcripts_070309_3.txt
type_of_measurement clique_number normal_name
type_of_measurement clique_number normal_name
$VAR1 = {
'transcript' => {
'URA4' => {
'1' => [
'5',
'5'
],
'5' => [
'5',
'5'
]
},
'SSA2' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'DLD2' => {
'1' => [
'14'
],
'5' => [
'14',
'14'
]
},
'RPL9A' => {},
'GLN1' => {
'5' => [
'2',
'5',
'14'
]
},
'GAS1' => {},
'CYS3' => {
'5' => [
'2'
]
},
'SER1' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'PGM2' => {
'1' => [
'15',
'15'
],
'5' => [
'15',
'15'
]
},
'CHC1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'ADH1' => {
'1' => [
'14',
'14'
],
'5' => [
'14',
'14'
]
},
'"ADE5,7"' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'YCP4' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'PXA2' => {
'5' => [
'12'
]
},
'RPS2' => {
'5' => [
'2'
]
},
'TIM9' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'YPP1' => {
'1' => [
'12',
'15',
'15'
],
'5' => [
'12',
'15',
'15'
]
},
'LYS21' => {},
'CDC33' => {},
'ILS1' => {
'5' => [
'15'
]
},
'GRX2' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'GIS2' => {},
'CPR1' => {
'5' => [
'12'
]
},
'ADE4' => {
'1' => [
'13'
],
'5' => [
'13'
]
},
'EFB1' => {},
'CMD1' => {
'5' => [
'8'
]
},
'GPM1' => {
'1' => [
'14',
'15'
],
'5' => [
'14',
'15'
]
},
'UGA1' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'GLR1' => {
'1' => [
'16',
'16'
],
'5' => [
'16',
'16'
]
},
'SAM1' => {
'5' => [
'2'
]
},
'ARO1' => {},
'DED81' => {
'1' => [
'2',
'14'
],
'5' => [
'2',
'14'
]
},
'UNG1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'ARB1' => {
'1' => [
'2'
],
'5' => [
'2'
]
},
'HSP10' => {
'1' => [
'14',
'14'
],
'5' => [
'14',
'14'
]
},
'ILV5' => {
'1' => [
'3',
'13',
'13'
],
'5' => [
'3',
'13',
'13'
]
},
'RPL17A' => {},
'CDC48' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'ADH2' => {
'1' => [
'14'
],
'5' => [
'13',
'14',
'14'
]
},
'ABP1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'RPL24A' => {},
'ACB1' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'SOD2' => {
'5' => [
'12',
'12'
]
},
'TPS1' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'RPP0' => {},
'SEC3' => {
'5' => [
'8'
]
},
'HSP82' => {
'5' => [
'10'
]
},
'ALD6' => {
'1' => [
'13',
'13',
'13'
],
'5' => [
'13',
'13',
'13'
]
},
'RPS7A' => {},
'ECM32' => {
'5' => [
'15'
]
},
'FPR3' => {
'1' => [
'15'
],
'5' => [
'15',
'15'
]
},
'IPP1' => {
'1' => [
'2'
],
'5' => [
'2'
]
},
'GLY1' => {},
'ADE3' => {},
'IDP1' => {
'1' => [
'3',
'3',
'16'
],
'5' => [
'3',
'3',
'16'
]
},
'RPL4A' => {},
'RPS5' => {},
'RPL6B' => {
'5' => [
'12'
]
},
'WBP1' => {
'1' => [
'2',
'14'
],
'5' => [
'2',
'14'
]
},
'LSP1' => {
'1' => [
'15',
'15'
],
'5' => [
'15',
'15'
]
},
'DBP2' => {
'1' => [
'2',
'2'
],
'5' => [
'2',
'2'
]
},
'RPL24B' => {},
'RIB4' => {
'1' => [
'5',
'5'
],
'5' => [
'5',
'5'
]
},
'VAS1' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'URA1' => {
'1' => [
'5',
'5'
],
'5' => [
'5',
'5'
]
},
'UBA1' => {
'1' => [
'11'
],
'5' => [
'11'
]
},
'FRS1' => {},
'SUB2' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'RPP1B' => {},
'COR1' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'RPP2B' => {},
'GDH1' => {
'1' => [
'3',
'3'
],
'5' => [
'3',
'3',
'5'
]
},
'THR4' => {
'1' => [
'15'
],
'5' => [
'15',
'15'
]
},
'YNL208W' => {
'1' => [
'2'
],
'5' => [
'2'
]
},
'CYC1' => {
'1' => [
'12',
'12'
],
'5' => [
'12',
'12'
]
},
'ATP2' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'GUA1' => {},
'COX6' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'CAR2' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'YNL134C' => {
'1' => [
'14',
'14'
],
'5' => [
'14',
'14'
]
},
'GUK1' => {},
'ATP5' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'RPS20' => {},
'NOP56' => {
'1' => [
'2',
'12'
],
'5' => [
'2',
'12'
]
},
'PSA1' => {
'1' => [
'2',
'2'
],
'5' => [
'2',
'2'
]
},
'YGP1' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'ACS2' => {
'1' => [
'12',
'12'
],
'5' => [
'12',
'12'
]
},
'TOM20' => {
'1' => [
'14'
],
'5' => [
'12',
'14'
]
},
'YHB1' => {
'1' => [
'12',
'12'
],
'5' => [
'7',
'12',
'12'
]
},
'DPM1' => {
'1' => [
'2',
'2'
],
'5' => [
'2',
'2'
]
},
'BAT1' => {
'1' => [
'3',
'3'
],
'5' => [
'3',
'3'
]
},
'EGD2' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'RPL21A' => {},
'ERG10' => {
'1' => [
'12',
'12'
],
'5' => [
'12',
'12'
]
},
'HMO1' => {
'1' => [
'2'
],
'5' => [
'2'
]
},
'ARC1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'ZUO1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'RPL33B' => {},
'YDJ1' => {},
'DLD3' => {
'1' => [
'3',
'3',
'16'
],
'5' => [
'3',
'3',
'16'
]
},
'YJL171C' => {
'1' => [
'3',
'10'
],
'5' => [
'3',
'10'
]
},
'ARG1' => {
'1' => [
'3'
],
'5' => [
'3',
'16'
]
},
'ARG8' => {},
'URA2' => {
'1' => [
'5'
],
'5' => [
'5',
'5'
]
},
'PCK1' => {
'1' => [
'11'
],
'5' => [
'11'
]
},
'OAC1' => {
'1' => [
'3',
'3'
],
'5' => [
'3',
'3'
]
},
'YOP1' => {
'1' => [
'15',
'16',
'16'
],
'5' => [
'15',
'16',
'16'
]
},
'MDH1' => {
'1' => [
'13',
'15'
],
'5' => [
'13',
'15'
]
},
'LYS12' => {
'5' => [
'3'
]
},
'HIS1' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'RPL5' => {},
'ATP7' => {
'1' => [
'15',
'15'
],
'5' => [
'15',
'15'
]
},
'GCV3' => {
'1' => [
'13'
],
'5' => [
'13',
'13'
]
},
'MVD1' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'NOP1' => {},
'TPM1' => {
'5' => [
'14'
]
},
'ALD5' => {
'1' => [
'3',
'3',
'13'
],
'5' => [
'3',
'3',
'13',
'16'
]
},
'PIL1' => {
'1' => [
'15',
'15'
],
'5' => [
'15',
'15'
]
},
'FAS1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'AAT2' => {
'1' => [
'3'
],
'5' => [
'3',
'16'
]
},
'MRPL35' => {
'1' => [
'14'
],
'5' => [
'14',
'14'
]
},
'ACO1' => {
'1' => [
'7',
'13'
],
'5' => [
'7',
'13'
]
},
'ARO2' => {
'5' => [
'15'
]
},
'POR1' => {
'1' => [
'14',
'15'
],
'5' => [
'14',
'15'
]
},
'RNR2' => {
'1' => [
'12',
'12',
'12'
],
'5' => [
'12',
'12',
'12'
]
},
'ACC1' => {
'5' => [
'7'
]
},
'RPL8B' => {},
'RVS167' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'SRO9' => {
'5' => [
'2'
]
},
'MET6' => {
'1' => [
'5'
],
'5' => [
'5'
]
},
'FRS2' => {
'1' => [
'6'
],
'5' => [
'6'
]
},
'WTM1' => {
'5' => [
'14'
]
},
'CPR3' => {
'1' => [
'13'
],
'5' => [
'13',
'13'
]
},
'ERV14' => {
'1' => [
'13'
],
'5' => [
'13'
]
},
'ADE8' => {
'1' => [
'13'
],
'5' => [
'13'
]
},
'KAP123' => {
'1' => [
'2',
'2'
],
'5' => [
'2',
'2'
]
},
'RPL8A' => {},
'VMA5' => {},
'TMA19' => {
'5' => [
'12'
]
},
'RPL6A' => {},
'SSE1' => {
'1' => [
'15',
'16'
],
'5' => [
'15',
'16',
'16'
]
},
'FAA1' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'PET10' => {
'1' => [
'12',
'12',
'12'
],
'5' => [
'12',
'12',
'12'
]
},
'TRP2' => {
'1' => [
'16'
],
'5' => [
'16'
]
},
'DUG1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'SHM2' => {
'1' => [
'13'
],
'5' => [
'13',
'15'
]
},
'ARP3' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'EGD1' => {},
'VMA2' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'CWP1' => {
'1' => [
'11',
'15'
],
'5' => [
'11',
'15',
'15'
]
},
'PEX32' => {
'1' => [
'2',
'2'
],
'5' => [
'2',
'2',
'2'
]
},
'HIS4' => {
'1' => [
'3'
],
'5' => [
'3',
'13'
]
},
'ORC1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'SRV2' => {
'5' => [
'14'
]
},
'ILV3' => {
'1' => [
'3',
'3'
],
'5' => [
'3',
'3',
'13',
'16'
]
},
'OYE2' => {
'1' => [
'12'
],
'5' => [
'12',
'12'
]
},
'RPS12' => {},
'CCT2' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'GRS1' => {},
'TPO1' => {
'1' => [
'12',
'15',
'15'
],
'5' => [
'12',
'15',
'15'
]
},
'PGI1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'RPL28' => {},
'ERG13' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'TEF4' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'GPD1' => {
'1' => [
'2'
],
'5' => [
'2',
'15'
]
},
'SCW4' => {
'1' => [
'6',
'7'
],
'5' => [
'6',
'7'
]
},
'LYS20' => {},
'LYS1' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'HIS7' => {
'1' => [
'3'
],
'5' => [
'3',
'4',
'13'
]
},
'PFY1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'TYS1' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'RPL13B' => {},
'RPL15A' => {},
'STB5' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'OLA1' => {},
'ASC1' => {},
'ADO1' => {},
'LEU4' => {
'1' => [
'3',
'3',
'12'
],
'5' => [
'3',
'3',
'12'
]
},
'ERG6' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'YGL160W' => {
'1' => [
'12',
'12'
],
'5' => [
'12',
'12'
]
},
'TRX2' => {
'1' => [
'7',
'12'
],
'5' => [
'7',
'12'
]
},
'HAS1' => {
'1' => [
'2',
'2'
],
'5' => [
'2',
'2'
]
},
'RPS21B' => {},
'ARO4' => {
'1' => [
'16'
],
'5' => [
'3',
'15',
'16'
]
},
'LAT1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'PKH1' => {
'5' => [
'4'
]
},
'RPS3' => {},
'PEP4' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'RPL3' => {},
'TAL1' => {
'1' => [
'12'
],
'5' => [
'3',
'12',
'12'
]
},
'STI1' => {
'1' => [
'7'
],
'5' => [
'7',
'7'
]
},
'ECM40' => {
'1' => [
'3'
],
'5' => [
'3',
'16'
]
},
'UGP1' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'ALA1' => {
'5' => [
'14'
]
},
'not_part_of_the_354' => {},
'YDR341C' => {
'1' => [
'15'
],
'5' => [
'15',
'15'
]
},
'RPL25' => {},
'NTF2' => {
'1' => [
'2',
'2'
],
'5' => [
'2',
'2'
]
},
'HOM6' => {
'1' => [
'14'
],
'5' => [
'14',
'14'
]
},
'GUS1' => {
'1' => [
'14'
],
'5' => [
'14',
'15'
]
},
'HXK1' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'ARO3' => {
'1' => [
'3'
],
'5' => [
'3',
'3',
'13'
]
},
'RPP2A' => {},
'RPA190' => {},
'YSA1' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'IMD3' => {
'1' => [
'2',
'14'
],
'5' => [
'2',
'14'
]
},
'RPL38' => {},
'HEM15' => {
'1' => [
'15'
],
'5' => [
'5',
'15'
]
},
'ARF1' => {
'1' => [
'12',
'12'
],
'5' => [
'12',
'12'
]
},
'IMD2' => {
'1' => [
'13',
'13',
'14'
],
'5' => [
'13',
'13',
'13',
'14'
]
},
'ARO8' => {},
'YDL124W' => {
'1' => [
'4'
],
'5' => [
'4'
]
},
'RPL32' => {},
'YLR179C' => {
'1' => [
'3',
'12'
],
'5' => [
'3',
'12'
]
},
'SNU13' => {},
'RIP1' => {
'1' => [
'12',
'12'
],
'5' => [
'12',
'12',
'15'
]
},
'HYP2' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'RPL16A' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'SUI2' => {},
'RPL9B' => {
'5' => [
'2'
]
},
'TUB2' => {},
'MIR1' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'GPH1' => {
'1' => [
'15'
],
'5' => [
'15',
'15'
]
},
'HSP31' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'OSH2' => {
'1' => [
'15'
],
'5' => [
'15',
'15'
]
},
'MBF1' => {
'5' => [
'7'
]
},
'ERG20' => {
'1' => [
'12',
'12'
],
'5' => [
'12',
'12'
]
},
'PUP3' => {},
'PNC1' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'ILV2' => {
'1' => [
'3',
'3',
'13'
],
'5' => [
'3',
'3',
'13'
]
},
'MAE1' => {
'1' => [
'3',
'3',
'5'
],
'5' => [
'3',
'3',
'5'
]
},
'ATP4' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'TRP5' => {},
'PST2' => {
'1' => [
'15'
],
'5' => [
'15',
'15'
]
},
'VMA4' => {
'5' => [
'13'
]
},
'YEF3' => {
'1' => [
'2'
],
'5' => [
'2',
'2',
'2',
'2'
]
},
'RNR4' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'AHP1' => {
'1' => [
'13'
],
'5' => [
'2',
'2',
'13'
]
},
'MMF1' => {
'1' => [
'13'
],
'5' => [
'13',
'13'
]
},
'KRS1' => {
'1' => [
'15'
],
'5' => [
'15',
'15',
'16'
]
},
'RPS7B' => {},
'YRB1' => {},
'LEU1' => {
'1' => [
'3',
'3'
],
'5' => [
'3',
'3'
]
},
'SUI1' => {},
'HMF1' => {
'1' => [
'9'
],
'5' => [
'9'
]
},
'SUP45' => {
'1' => [
'2',
'2',
'2'
],
'5' => [
'2',
'2',
'2'
]
},
'RPS31' => {},
'NSR1' => {
'1' => [
'2'
],
'5' => [
'2',
'2'
]
},
'MET17' => {
'5' => [
'16'
]
},
'DED1' => {
'1' => [
'2'
],
'5' => [
'2'
]
},
'ADE6' => {
'1' => [
'15'
],
'5' => [
'15'
]
},
'GCV1' => {
'1' => [
'13',
'13'
],
'5' => [
'13',
'13'
]
},
'SES1' => {
'5' => [
'14',
'15'
]
},
'PMI40' => {
'1' => [
'3',
'14'
],
'5' => [
'3',
'3',
'14'
]
},
'STM1' => {
'5' => [
'12'
]
},
'RPL22A' => {},
'HOM2' => {
'1' => [
'3'
],
'5' => [
'3',
'3',
'16'
]
},
'HSP104' => {
'1' => [
'12',
'15',
'15'
],
'5' => [
'12',
'15',
'15'
]
},
'HXK2' => {
'5' => [
'15'
]
},
'YGR207C' => {
'1' => [
'13'
],
'5' => [
'13'
]
},
'ASN1' => {
'1' => [
'15',
'15'
],
'5' => [
'15',
'15',
'16'
]
},
'TRM44' => {},
'PGK1' => {
'1' => [
'14',
'14',
'14',
'15'
],
'5' => [
'14',
'14',
'15'
]
},
'RPS15' => {}
},
'peptide' => {
'RPL10' => {
'1' => [
'3',
'14'
],
'5' => [
'3',
'14'
]
},
'VMA5' => {},
'GFA1' => {
'5' => [
'13'
]
},
'SSA2' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'RPL9A' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'PDA1' => {
'1' => [
'3'
],
'5' => [
'3',
'13'
]
},
'TMA19' => {},
'CYS3' => {
'1' => [
'2'
],
'5' => [
'2'
]
},
'SER1' => {
'1' => [
'2',
'13'
],
'5' => [
'2',
'2',
'13'
]
},
'PGM2' => {
'5' => [
'7'
]
},
'RPL16B' => {},
'SSE1' => {
'1' => [
'3'
],
'5' => [
'3',
'13'
]
},
'PRE5' => {
'5' => [
'1'
]
},
'ADH1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'CPR6' => {},
'PXA2' => {
'5' => [
'2'
]
},
'RPS2' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'SHM2' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13'
]
},
'ARP3' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'ILS1' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13',
'13'
]
},
'VMA2' => {},
'PDC1' => {
'5' => [
'3'
]
},
'GPM1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'YMR226C' => {
'1' => [
'2',
'14'
],
'5' => [
'2',
'14',
'14'
]
},
'TRR1' => {
'1' => [
'2'
],
'5' => [
'2'
]
},
'TSA1' => {
'5' => [
'2',
'12'
]
},
'SAM1' => {
'1' => [
'3',
'12',
'13'
],
'5' => [
'3',
'12',
'13',
'13'
]
},
'PFK2' => {
'5' => [
'12'
]
},
'RPS12' => {},
'UNG1' => {},
'HSP10' => {},
'PGI1' => {},
'ERG13' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'RPL28' => {
'1' => [
'14',
'14'
],
'5' => [
'14'
]
},
'RTN1' => {
'5' => [
'3'
]
},
'TEF4' => {},
'CDC48' => {
'1' => [
'2'
],
'5' => [
'2'
]
},
'ADH2' => {
'5' => [
'2'
]
},
'SCP160' => {
'1' => [
'16'
],
'5' => [
'15',
'16'
]
},
'LYS20' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13'
]
},
'ACT1' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'TYS1' => {},
'ATP1' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'OLA1' => {},
'SOD2' => {},
'ADO1' => {},
'LEU4' => {
'1' => [
'13'
],
'5' => [
'13'
]
},
'RPS21A' => {},
'ERG6' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'YGL160W' => {
'1' => [
'2'
],
'5' => [
'2'
]
},
'SEC3' => {},
'TRX2' => {},
'RPP0' => {},
'HAS1' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13'
]
},
'SAM2' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13'
]
},
'ARO4' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13'
]
},
'ALD6' => {
'5' => [
'13',
'13'
]
},
'RPS7A' => {},
'ECM32' => {
'5' => [
'2'
]
},
'RPS3' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'12',
'13'
]
},
'RPL3' => {},
'BMH1' => {
'5' => [
'2'
]
},
'PEP4' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'BGL2' => {
'5' => [
'3'
]
},
'GLY1' => {
'1' => [
'3'
],
'5' => [
'3',
'3',
'13'
]
},
'TAL1' => {
'1' => [
'12',
'12'
],
'5' => [
'12',
'12'
]
},
'ADE3' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'RPS5' => {
'5' => [
'3'
]
},
'LSP1' => {},
'RPL24B' => {},
'UGP1' => {
'1' => [
'2'
],
'5' => [
'2',
'2'
]
},
'RIB4' => {
'1' => [
'5'
],
'5' => [
'5'
]
},
'not_part_of_the_354' => {},
'ALA1' => {
'5' => [
'3'
]
},
'SSC1' => {},
'YDR341C' => {
'1' => [
'3'
],
'5' => [
'3',
'13'
]
},
'HOM6' => {},
'GUS1' => {},
'RPP2A' => {},
'ARO3' => {
'5' => [
'3'
]
},
'HXK1' => {
'1' => [
'3'
],
'5' => [
'3',
'13'
]
},
'TPM2' => {
'5' => [
'4'
]
},
'PRO2' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'YSA1' => {
'1' => [
'3'
],
'5' => [
'3',
'13'
]
},
'COR1' => {
'1' => [
'2',
'2'
],
'5' => [
'2',
'2'
]
},
'RNA1' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'PDI1' => {
'1' => [
'3'
],
'5' => [
'3',
'9'
]
},
'RPL38' => {
'5' => [
'3'
]
},
'SGT2' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'RPP2B' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'THR4' => {
'1' => [
'7'
],
'5' => [
'7',
'7'
]
},
'ARO8' => {
'1' => [
'3'
],
'5' => [
'3',
'13'
]
},
'GDH1' => {
'1' => [
'3'
],
'5' => [
'3',
'3'
]
},
'RPL32' => {},
'YDL124W' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'ATP2' => {
'5' => [
'4'
]
},
'GUA1' => {},
'HFD1' => {},
'HYP2' => {
'1' => [
'12',
'12'
],
'5' => [
'12',
'12'
]
},
'RPL16A' => {
'5' => [
'13'
]
},
'RPL9B' => {
'1' => [
'7'
],
'5' => [
'7'
]
},
'RPS20' => {
'1' => [
'7'
],
'5' => [
'7'
]
},
'NOP56' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'PSA1' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'PET9' => {
'1' => [
'7'
],
'5' => [
'7'
]
},
'PFK1' => {
'5' => [
'2'
]
},
'ACS2' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'YHB1' => {
'5' => [
'3'
]
},
'BAT1' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13'
]
},
'DPM1' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'RPL21A' => {},
'OSH2' => {
'1' => [
'3'
],
'5' => [
'3',
'13'
]
},
'UGO1' => {
'5' => [
'2'
]
},
'ERG10' => {
'1' => [
'12'
],
'5' => [
'12'
]
},
'ERG20' => {},
'KAR2' => {
'1' => [
'2'
],
'5' => [
'2'
]
},
'PNC1' => {},
'ADK1' => {
'5' => [
'3'
]
},
'RPS13' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'YDJ1' => {
'5' => [
'3',
'14'
]
},
'RPL33B' => {
'5' => [
'7'
]
},
'TRP5' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'PST2' => {},
'SSB2' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'DLD3' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13'
]
},
'YJL171C' => {
'1' => [
'12'
],
'5' => [
'12',
'12'
]
},
'YMR315W' => {
'5' => [
'8'
]
},
'ARG1' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'VMA4' => {
'5' => [
'3',
'5'
]
},
'INO1' => {
'1' => [
'2',
'2'
],
'5' => [
'2',
'2'
]
},
'URA2' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13'
]
},
'YEF3' => {},
'RNR4' => {
'5' => [
'3'
]
},
'MMF1' => {
'1' => [
'13',
'13'
],
'5' => [
'13',
'13'
]
},
'KRS1' => {
'5' => [
'3'
]
},
'MDH1' => {
'1' => [
'14'
],
'5' => [
'14'
]
},
'RPS7B' => {
'1' => [
'7'
],
'5' => [
'7'
]
},
'LYS12' => {
'1' => [
'3',
'14'
],
'5' => [
'3',
'14'
]
},
'LEU1' => {},
'HIS1' => {
'1' => [
'13'
],
'5' => [
'13'
]
},
'SUP45' => {},
'MDH3' => {
'5' => [
'2'
]
},
'ATP7' => {
'5' => [
'10'
]
},
'GCV3' => {},
'MET17' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13'
]
},
'MVD1' => {
'5' => [
'12'
]
},
'TRX1' => {
'1' => [
'2',
'7'
],
'5' => [
'2',
'7'
]
},
'YHR020W' => {
'1' => [
'3',
'3'
],
'5' => [
'3',
'3'
]
},
'AAT2' => {
'1' => [
'13'
],
'5' => [
'3',
'13'
]
},
'PIL1' => {
'1' => [
'2'
],
'5' => [
'2',
'2'
]
},
'ALD5' => {
'5' => [
'3'
]
},
'MRPL35' => {},
'PMI40' => {
'1' => [
'14'
],
'5' => [
'3',
'14'
]
},
'HOM2' => {
'1' => [
'3'
],
'5' => [
'3',
'13'
]
},
'ACO1' => {
'5' => [
'16'
]
},
'ARO2' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'POR1' => {
'1' => [
'14'
],
'5' => [
'14',
'14'
]
},
'RNR2' => {},
'YGR207C' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'FPR1' => {
'5' => [
'14'
]
},
'ASN1' => {
'1' => [
'3',
'13'
],
'5' => [
'3',
'13'
]
},
'MET6' => {},
'TRM44' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'WTM1' => {
'1' => [
'3'
],
'5' => [
'3'
]
},
'DPS1' => {
'1' => [
'7'
],
'5' => [
'7'
]
},
'BRF1' => {},
'SYC1' => {
'1' => [
'13'
],
'5' => [
'13'
]
}
}
};
done!


efoss
Novice

Jul 22, 2009, 2:33 PM

Post #22 of 31 (5169 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

For what it's worth, I just ran this script on a different machine and got the same result.


efoss
Novice

Jul 22, 2009, 3:14 PM

Post #23 of 31 (5168 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

OK, I think I'm figuring this out. I think I'm misusing "foreach" somehow. For example the code below prints everything out fine except for the final

print "and finally file is $file\n";

Then it doesn't have the variable "$file" any more. When I'm going around in the "foreach" loop, it is treating "$file" as whatever element of @array it's dealing with and not as some independent variable called "$file". The code I linked to is filled with "foreach" loops, and I'm sure I'm making this mistake all over the place. And that, I expect, is somehow leading to this weird behavior.


#!/usr/bin/perl -w
use strict;

my @array;
my $file;
my @files;
my $path;


$path = "/Users/eric/post_disaster_mass_spec/consolidate_results/";

opendir (DIR, "$path");
@array = readdir DIR;
closedir DIR;

foreach $file (@array) {
if ($file =~ /^gold_standard_\S+051809_1\.txt$/) {
print "print file is $file\n";
$file = "$path"."$file";
push (@files, $file);
print "now file is $file\n";
}
}

print "and finally file is $file\n";

print "done!\n";


efoss
Novice

Jul 22, 2009, 3:37 PM

Post #24 of 31 (5166 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

OK, this is now getting really bizarre. I fixed up a bunch of potential screw ups with "foreach" loops, though I'm not convinced that I made a mistake there. Then I tried again - it still doesn't work. Then I filled the variable I've been having trouble with and commented out all the rest of the code until the final line, which says:

print "done!\n";

I put a block before that line and run it and ALL of my variables are gone. Then before the commented out block of code, I put in this line:

print "check now\n";

I put a block before that and now all of my variables are there and filled correctly and everything is fine. So somehow printing "check now" and jumping over a big block of commented out code has led me to lose all of my variables. Removing the commented out code fixes the problem - then when I put a block before the final "done" line, all the variables are there.

So jumping over a block of commented out code makes my variables vanish. That's pretty messed up.


(This post was edited by efoss on Jul 22, 2009, 3:40 PM)


FishMonger
Veteran / Moderator

Jul 22, 2009, 3:48 PM

Post #25 of 31 (5163 views)
Re: [efoss] hash of hashes disappears [In reply to] Can't Post

That's not the output I was requesting, but it does prove that the var does not "disappear".

Are you using the perl debugger (i.e., do you execute it as 'perl -d yourscript.pl') or are you using some other 3rd party debugger?

Remove the print statement that I had you put in and add this to the end of the script.

Code
END { 
print Dumper \%type_normalName_cutoff_chromosomes;
}

If you get the same output, then that proves that the var is intact to the end of the script.

If your debugger tells you that it doesn't exist or that it's empty, then either your debugger has a bug or your usage of it is flawed.

First page Previous page 1 2 Next page Last page  View All
 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives