Hi All, I've got this piece of code below to calculate the coverage of small pieces of strings across the genome (large string). The script works fine when I set 0 children. Setting children to 1 or 2 doesn't work (takes really long). Does anybody have an idea what is going wrong?
#!/usr/local/bin/perl -w use Parallel::ForkManager; use strict; if(scalar(@ARGV) != 3){ print "Please use the correct parameters\nUsage: bowtie2wiggle.pl +-infile -outfile- -processes-\n"; exit(); } my $pm = new Parallel::ForkManager($ARGV[2]); my %hash=(); open (IN, $ARGV[0]); while (<IN>){ $pm->start and next; $_ =~ s/\n|\r//; my @element=split(/\t/,$_); $element[2] =~ s/T//; for (my $i=1;$i<=length($element[4]);$i++){ $hash{$element[2]}{($element[3]+$i)}{coverage}++; } $pm->finish; } $pm->wait_all_children; close IN; open (OUT, ">$ARGV[1]"); print OUT 'track type=wiggle_0 name="'.$ARGV[0].'" description="theore +tical coverage from '.$ARGV[0].'" visibility=full autoScale=on color= +50,150,255'."\n"; my $old=""; foreach my $chromosome (sort keys %hash){ print OUT "variableStep chrom=chr$chromosome span=1\n"; foreach my $position (sort {$a<=>$b} keys %{$hash{$chromosome}}){ if ($old ne "" && $old != ($position-1)){ print OUT "variableStep chrom=chr$chromosome span=1\n"; } print OUT "$position $hash{$chromosome}{$position}{coverage}\n +"; $old=$position; } } close OUT; #######Input data: HWI-EAS384:7:1:1124:2949#TCTANN/1 - chr18 20832586 GCAGATC +ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGCAAAAACCTGTCTCTACTAAAAATACAA + T^TY^Y]\\^adT_a^^^\Ta__aa`][^YT^T\aTT`]KY_^_YY`^[T_b]bYeeff\ffbff` +ddddd^dda 1 20:T>C,22:C>A HWI-EAS384:7:1:1124:2949#TCTANN/1 - chr3 159753225 GCAGATC +ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGCAAAAACCTGTCTCTACTAAAAATACAA + T^TY^Y]\\^adT_a^^^\Ta__aa`][^YT^T\aTT`]KY_^_YY`^[T_b]bYeeff\ffbff` +ddddd^dda 0 26:G>A,36:T>C HWI-EAS384:7:1:1124:2949#TCTANN/1 - chr2 26523236 GCAGATCA +CCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGCAAAAACCTGTCTCTACTAAAAATACAA + T^TY^Y]\\^adT_a^^^\Ta__aa`][^YT^T\aTT`]KY_^_YY`^[T_b]bYeeff\ffbff`d +dddd^dda 0 26:G>A,53:A>G HWI-EAS384:7:1:1124:2949#TCTANN/1 - chr6 122836749 GCAGATC +ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGCAAAAACCTGTCTCTACTAAAAATACAA + T^TY^Y]\\^adT_a^^^\Ta__aa`][^YT^T\aTT`]KY_^_YY`^[T_b]bYeeff\ffbff` +ddddd^dda 0 26:G>A,49:C>G HWI-EAS384:7:1:1124:2949#TCTANN/1 - chr3 12482979 GCAGATCA +CCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGCAAAAACCTGTCTCTACTAAAAATACAA + T^TY^Y]\\^adT_a^^^\Ta__aa`][^YT^T\aTT`]KY_^_YY`^[T_b]bYeeff\ffbff`d +dddd^dda 3 22:C>A HWI-EAS384:7:1:1124:2949#TCTANN/1 - chr16 85386061 GCAGATC +ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGCAAAAACCTGTCTCTACTAAAAATACAA + T^TY^Y]\\^adT_a^^^\Ta__aa`][^YT^T\aTT`]KY_^_YY`^[T_b]bYeeff\ffbff` +ddddd^dda 3 22:C>A HWI-EAS384:7:1:1124:2949#TCTANN/1 - chr8 74059852 GCAGATCA +CCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGCAAAAACCTGTCTCTACTAAAAATACAA + T^TY^Y]\\^adT_a^^^\Ta__aa`][^YT^T\aTT`]KY_^_YY`^[T_b]bYeeff\ffbff`d +dddd^dda 3 22:C>A HWI-EAS384:7:1:1124:2949#TCTANN/1 - chr13 34357600 GCAGATC +ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGCAAAAACCTGTCTCTACTAAAAATACAA + T^TY^Y]\\^adT_a^^^\Ta__aa`][^YT^T\aTT`]KY_^_YY`^[T_b]bYeeff\ffbff` +ddddd^dda 3 22:C>A HWI-EAS384:7:1:1124:2949#TCTANN/1 - chr12 31386168 GCAGATC +ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGCAAAAACCTGTCTCTACTAAAAATACAA + T^TY^Y]\\^adT_a^^^\Ta__aa`][^YT^T\aTT`]KY_^_YY`^[T_b]bYeeff\ffbff` +ddddd^dda 1 22:C>A,72:G>A HWI-EAS384:7:1:1124:2949#TCTANN/1 - chrX 134915278 GCAGATC +ACCTGAGGTCAGGAGTTCGAGACCAGCCTGGCCAACATGGCAAAAACCTGTCTCTACTAAAAATACAA + T^TY^Y]\\^adT_a^^^\Ta__aa`][^YT^T\aTT`]KY_^_YY`^[T_b]bYeeff\ffbff` +ddddd^dda 1 22:C>A,72:G>A

In reply to parallel::forkmanager takes too long setting children by Jaap1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.