There are three parameters for the function count_pwm_num. The first one is $pwm, which is from list @ciona_pwm_array and is the motif feature. The second and third are DNA strings. The function is to calculate the motif number (how many?)using motif feature $pwm in the DNA strings. The aim of the function count_pwm_num is to report the motif number from both strings. The following table is the report from the program. However, I calculated the same DNA strings 100 times ( the first for-loop) and used same motif list (@ciona_pwm_array, the second for-loop), there is always missed motif(s) in the report. For example, row a (first row), the program reported all six motif number from A-F. row b missed the number of the motif A (because they were same DNA strings, the output should keep the same). row c missed the number of motif B.row d missed the number for motif A and B. It seemed the missed motif numbers were randomly selected. So my question is: why count_pwm_num randomly skip some $pwm and do not perform the function of count_pwm_num?my $multi_cpu_num = 13; my @ciona_pwm_array = getCionaPWM(); my $output_temp = 'temp.ciona.temp'; my $output_temp_handle = FileHandle->new(">output_temp"); my $output_handle = FileHandle->new(">ciona.matrix.result"); my $result_buffer = undef; foreach my $id (1..100) { my $seq_1 = 'gatctatcgtagcagcta'; my $seq_2 = 'agtctacatgctacgatg'; my $pm = Parallel::ForkManager->new( $multi_cpu_num ); PWM: for my $pwm (@ciona_pwm_array) { $pm->start and next PWM; my $count = count_pwm_num($pwm,$seq_1,$seq_2); if($count != 0) { $output_temp_handle->print($id); $output_temp_handle->print("\t$pwm\t1\n"); } else { $output_temp_handle->print($id); $output_temp_handle->print("\t$pwm\t0\n"); } $pm->finish; } $pm->wait_all_children; } $output_temp_handle->close; # catch the Parallel::ForkManager output # the temporary output looks like that # a A 1 # b B 0 # c C 1 # a B 1 # in real code , I used 1, 2,3, instead of a, b, c ,d. my $reopen_handle = FileHandle->new($output_temp); while(my $line = $reopen_handle->getline) { chomp $line; my @buffer = split/\t/,$line; $result_buffer->{$buffer[0]}->{$buffer[1]} = $buffer[2]; } $reopen_handle->close; unlink 'temp.ciona.temp'; # print output_header_information :row 1 in program result table; $output_handle->print("id"); foreach my $pwm (@ciona_pwm_array) { $output_handle->print("\t$pwm"); } $output_handle->print("\n"); # print the content of program result table foreach my $id (1..100}) { $output_handle->print("$id"); foreach my $pwm (@ciona_pwm_array) { my $count = $result_buffer->{$id}->{$pwm}; $output_handle->print("\t$count"); } $output_handle->print("\n"); } $output_handle->close; sub ciona_pwm_num {} sub getCionaPWM {] exit(0);
program result table:
id A B C D E F a 1 1 0 1 1 0 b 1 0 1 1 0 c 1 0 1 1 0 d 0 1 1 0 e 1 1 0 1 1 0 .. Expected result id A B C D E F a 1 1 0 1 1 0 b 1 1 0 1 1 0 c 1 1 0 1 1 0 d 1 1 0 1 1 0 e 1 1 0 1 1 0 ..
In reply to missing values when using Parallel::ForkManager by plagent
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |